%union { CYWord *word_; }
@begin C
+%union { CYTypeStructField *structField_; }
%union { CYTypeModifier *modifier_; }
%union { CYTypeSpecifier *specifier_; }
%union { CYTypedIdentifier *typedIdentifier_; }
@end
@begin ObjectiveC
+%union { CYImplementationField *implementationField_; }
%union { CYMessage *message_; }
%union { CYMessageParameter *messageParameter_; }
-%union { CYImplementationField *implementationField_; }
%union { CYProtocol *protocol_; }
%union { CYSelectorPart *selector_; }
@end
%token Question "?"
%token SemiColon ";"
%token NewLine "\n"
+%token __ ""
%token Comment
%token _typedef_ "typedef"
%token _unsigned_ "unsigned"
%token _signed_ "signed"
+%token _struct_ "struct"
%token _extern_ "extern"
@end
%token _package_ "package"
%token _private_ "private"
%token _protected_ "protected"
+%token ___proto___ "__proto__"
%token _prototype_ "prototype"
%token _public_ "public"
%token _set_ "set"
%token _SEL_ "SEL"
@end
-%token _auto_ "auto"
%token _each_ "each"
%token _of_ "of"
%token _of__ "!of"
@end
%token AutoComplete
-%token YieldStar
+%token YieldStar "yield *"
%token <identifier_> Identifier_
%token <number_> NumericLiteral
%type <identifier_> IdentifierNoOf
%type <identifier_> IdentifierType
%type <identifier_> IdentifierTypeNoOf
+%type <identifier_> IdentifierTypeOpt
%type <word_> IdentifierName
%type <variable_> IdentifierReference
%type <statement_> IfStatement
%type <bool_> RegularExpressionSlash
%type <expression_> RelationalExpression
%type <statement_> ReturnStatement
+%type <target_> RubyBlockExpression_
+%type <target_> RubyBlockExpression
%type <rubyProc_> RubyProcExpression
%type <functionParameter_> RubyProcParameterList_
%type <functionParameter_> RubyProcParameterList
%type <specifier_> IntegerTypeOpt
%type <typedIdentifier_> PrefixedType
%type <specifier_> PrimitiveType
+%type <structField_> StructFieldListOpt
%type <typedIdentifier_> SuffixedType
+%type <typedIdentifier_> SuffixedTypeOpt
%type <typedIdentifier_> TypeSignifier
+%type <typedIdentifier_> TypeSignifierOpt
%type <modifier_> TypeQualifierLeft
+%type <modifier_> TypeQualifierLeftOpt
%type <typedIdentifier_> TypeQualifierRight
-%type <typedIdentifier_> TypedIdentifier
+%type <typedIdentifier_> TypeQualifierRightOpt
+%type <typedIdentifier_> TypedIdentifierMaybe
+%type <typedIdentifier_> TypedIdentifierNo
+%type <typedIdentifier_> TypedIdentifierYes
%type <typedParameter_> TypedParameterList_
%type <typedParameter_> TypedParameterList
%type <typedParameter_> TypedParameterListOpt
%type <statement_> CategoryStatement
%type <expression_> ClassSuperOpt
%type <expression_> ConditionalExpressionClassic
-%type <implementationField_> ImplementationFieldListOpt
-%type <implementationField_> ImplementationFields
%type <message_> ClassMessageDeclaration
%type <message_> ClassMessageDeclarationListOpt
%type <protocol_> ClassProtocolListOpt
%type <protocol_> ClassProtocols
%type <protocol_> ClassProtocolsOpt
+%type <implementationField_> ImplementationFieldListOpt
%type <statement_> ImplementationStatement
%type <target_> MessageExpression
%type <messageParameter_> MessageParameter
LexPushReturnOn: { driver.return_.push(true); };
LexPopReturn: { driver.return_.pop(); };
+Return: "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); };
LexPushSuperOn: { driver.super_.push(true); };
LexPushSuperOff: { driver.super_.push(false); };
LexPopSuper: { driver.super_.pop(); };
+Super: "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); };
LexPushYieldOn: { driver.yield_.push(true); };
LexPushYieldOff: { driver.yield_.push(false); };
LexPopYield: { driver.yield_.pop(); };
-LexNewLine
+LexNewLineOrOpt
: { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); if (driver.newline_) { driver.hold_ = yyla.type; yyla.type = yytranslate_(cy::parser::token::NewLine); } }
;
+LexNewLineOrNot
+ : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); driver.hold_ = yyla.type; yyla.type = yytranslate_(driver.newline_ ? cy::parser::token::NewLine : cy::parser::token::__); }
+ ;
+
LexNoStar
: { CYMAP(YieldStar, Star); }
;
Word
: IdentifierNoOf[pass] { $$ = $pass; }
- | "auto" { $$ = CYNew CYWord("auto"); }
| "break" { $$ = CYNew CYWord("break"); }
| "case" { $$ = CYNew CYWord("case"); }
| "catch" { $$ = CYNew CYWord("catch"); }
: { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
;
+NewLineNot
+ : LexNewLineOrNot ""
+ ;
+
+NewLineOpt
+ : LexNewLineOrNot "\n"
+ | NewLineNot
+ ;
+
TerminatorSoft
- : ";"
- | "\n" StrictSemi
+ : LexNewLineOrNot "\n" StrictSemi
+ | NewLineNot LexOf Terminator
;
Terminator
| "package" { $$ = CYNew CYIdentifier("package"); }
| "private" { $$ = CYNew CYIdentifier("private"); }
| "protected" { $$ = CYNew CYIdentifier("protected"); }
+ | "__proto__" { $$ = CYNew CYIdentifier("__proto__"); }
| "prototype" { $$ = CYNew CYIdentifier("prototype"); }
| "public" { $$ = CYNew CYIdentifier("public"); }
| "set" { $$ = CYNew CYIdentifier("set"); }
| "of" { $$ = CYNew CYIdentifier("of"); }
;
+IdentifierTypeOpt
+ : IdentifierType[pass] { $$ = $pass; }
+ | { $$ = NULL; }
+ ;
+
IdentifierNoOf
: IdentifierTypeNoOf
| "char" { $$ = CYNew CYIdentifier("char"); }
| "static" { $$ = CYNew CYIdentifier("static"); }
| "volatile" { $$ = CYNew CYIdentifier("volatile"); }
@begin C
- | "extern" { $$ = CYNew CYIdentifier("extern"); }
| "signed" { $$ = CYNew CYIdentifier("signed"); }
- | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
+ | "struct" { $$ = CYNew CYIdentifier("struct"); }
| "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
@end
@begin ObjectiveC
/* 12.2.9 Template Literals {{{ */
TemplateLiteral
: NoSubstitutionTemplate[string] { $$ = CYNew CYTemplate($string, NULL); }
- | TemplateHead[string] TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); }
+ | TemplateHead[string] LexPushInOff TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); }
;
TemplateSpans
: Expression[value] TemplateMiddle[string] TemplateSpans[spans] { $$ = CYNew CYSpan($value, $string, $spans); }
- | Expression[value] TemplateTail[string] { $$ = CYNew CYSpan($value, $string, NULL); }
+ | Expression[value] TemplateTail[string] LexPopIn { $$ = CYNew CYSpan($value, $string, NULL); }
;
/* }}} */
;
SuperProperty
- : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); }
- | "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); }
+ : Super "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); }
+ | Super "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); }
;
MetaProperty
;
SuperCall
- : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); }
+ : Super Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); }
;
Arguments
;
LeftHandSideExpression
- : AccessExpression[pass] LexNewLine { $$ = $pass; }
+ : RubyBlockExpression[pass] { $$ = $pass; }
| IndirectExpression[pass] { $$ = $pass; }
;
/* }}} */
/* 12.4 Postfix Expressions {{{ */
PostfixExpression
- : AccessExpression[lhs] LexNewLine { $$ = $lhs; }
- | AccessExpression[lhs] LexNewLine "++" { $$ = CYNew CYPostIncrement($lhs); }
- | AccessExpression[lhs] LexNewLine "--" { $$ = CYNew CYPostDecrement($lhs); }
+ : RubyBlockExpression[pass] { $$ = $pass; }
+ | AccessExpression[lhs] LexNewLineOrOpt "++" { $$ = CYNew CYPostIncrement($lhs); }
+ | AccessExpression[lhs] LexNewLineOrOpt "--" { $$ = CYNew CYPostDecrement($lhs); }
;
/* }}} */
/* 12.5 Unary Operators {{{ */
UnaryExpression
: PostfixExpression[expression] { $$ = $expression; }
- | PostfixExpression[expression] "\n" { $$ = $expression; }
| UnaryExpression_[pass] { $$ = $pass; }
;
/* }}} */
;
ArrayBindingPattern
- : "let [" { CYNOT(@$); }
+ : "let [" BindingElementListOpt "]"
;
BindingPropertyList_
| LexOf
;
+BindingElementList
+ : BindingElementOpt[element] "," BindingElementListOpt[next]
+ | BindingRestElement[element]
+ | BindingElement[element]
+ ;
+
+BindingElementListOpt
+ : BindingElementList[pass]
+ | LexBind LexOf
+ ;
+
BindingProperty
: SingleNameBinding
| LexOf PropertyName ":" BindingElement
| LexBind LexOf BindingPattern InitializerOpt[initializer] { CYNOT(@$); }
;
+BindingElementOpt
+ : BindingElement[pass]
+ | LexBind LexOf
+ ;
+
SingleNameBinding
: BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
;
BindingRestElement
- : "..." BindingIdentifier
+ : LexBind LexOf "..." BindingIdentifier
;
/* }}} */
/* 13.4 Empty Statement {{{ */
;
ForInStatementInitializer
- : LexLet LexOf AccessExpression[pass] LexNewLine { $$ = $pass; }
+ : LexLet LexOf RubyBlockExpression[pass] { $$ = $pass; }
| LexLet LexOf IndirectExpression[pass] { $$ = $pass; }
| LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
| ForDeclaration[pass] { $$ = $pass; }
/* }}} */
/* 13.8 The continue Statement {{{ */
ContinueStatement
- : "continue" LexNewLine TerminatorSoft { $$ = CYNew CYContinue(NULL); }
- | "continue" LexNewLine Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
+ : "continue" TerminatorSoft { $$ = CYNew CYContinue(NULL); }
+ | "continue" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
;
/* }}} */
/* 13.9 The break Statement {{{ */
BreakStatement
- : "break" LexNewLine TerminatorSoft { $$ = CYNew CYBreak(NULL); }
- | "break" LexNewLine Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
+ : "break" TerminatorSoft { $$ = CYNew CYBreak(NULL); }
+ | "break" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
;
/* }}} */
/* 13.10 The return Statement {{{ */
-Return
- : "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); }
- ;
-
ReturnStatement
- : Return LexNewLine LexOf TerminatorSoft { $$ = CYNew CYReturn(NULL); }
- | Return LexNewLine Expression[value] Terminator { $$ = CYNew CYReturn($value); }
+ : Return TerminatorSoft { $$ = CYNew CYReturn(NULL); }
+ | Return NewLineNot Expression[value] Terminator { $$ = CYNew CYReturn($value); }
;
/* }}} */
/* 13.11 The with Statement {{{ */
/* }}} */
/* 13.14 The throw Statement {{{ */
ThrowStatement
- : "throw"[throw] LexNewLine LexOf TerminatorSoft { CYERR(@throw, "throw without exception"); }
- | "throw" LexNewLine Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
+ : "throw"[throw] TerminatorSoft { CYERR(@throw, "throw without exception"); }
+ | "throw" NewLineNot Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
;
/* }}} */
/* 13.15 The try Statement {{{ */
;
FormalParameterList
- : LexBind LexOf FunctionRestParameter { CYNOT(@$); }
+ : FunctionRestParameter { CYNOT(@$); }
| FormalParameter[binding] FormalParameterList_[next] { $$ = CYNew CYFunctionParameter($binding, $next); }
;
/* }}} */
/* 14.2 Arrow Function Definitions {{{ */
ArrowFunction
- : ArrowParameters[parameters] LexNewLine "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
+ : ArrowParameters[parameters] LexNewLineOrOpt "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
;
ArrowParameters
: LexPushYieldOn FunctionStatementList[code] LexPopYield { $$ = $code; }
;
-Yield
- : "!yield" LexNewLine LexNoStar
- ;
-
YieldExpression
- : Yield LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
- | Yield LexOf "\n" { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
- | Yield AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
- | Yield LexOf YieldStar AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
+ : "!yield" LexNewLineOrNot "\n" LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
+ | "!yield" LexNewLineOrNot "" LexNoStar LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
+ | "!yield" LexNewLineOrNot "" LexNoStar AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
+ | "!yield" LexNewLineOrNot "" LexNoStar LexOf "yield *" AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
;
/* }}} */
/* 14.5 Class Definitions {{{ */
/* Cycript (C): Type Encoding {{{ */
TypeSignifier
: IdentifierType[identifier] { $$ = CYNew CYTypedIdentifier(@identifier, $identifier); }
- | "(" "*" TypeQualifierRight[typed] ")" { $$ = $typed; }
+ | "(" "*" TypeQualifierRightOpt[typed] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
+ ;
+
+TypeSignifierOpt
+ : TypeSignifier[pass] { $$ = $pass; }
+ | { $$ = CYNew CYTypedIdentifier(@$); }
;
SuffixedType
- : SuffixedType[typed] "[" NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); }
- | "(" "^" TypeQualifierRight[typed] ")" "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); }
+ : SuffixedTypeOpt[typed] "[" NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); }
+ | "(" "^" TypeQualifierRightOpt[typed] ")" "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); }
| TypeSignifier[typed] "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
| "("[parenthesis] TypedParameterListOpt[parameters] ")" { $$ = CYNew CYTypedIdentifier(@parenthesis); $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
- | TypeSignifier[pass] { $$ = $pass; }
- | { $$ = CYNew CYTypedIdentifier(@$); }
+ ;
+
+SuffixedTypeOpt
+ : SuffixedType[pass] { $$ = $pass; }
+ | TypeSignifierOpt[pass] { $$ = $pass; }
;
PrefixedType
- : "*" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
+ : "*" TypeQualifierRightOpt[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
;
TypeQualifierLeft
- : { $$ = NULL; }
- | "const" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); }
- | "volatile" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); }
+ : "const" TypeQualifierLeftOpt[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); }
+ | "volatile" TypeQualifierLeftOpt[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); }
+ ;
+
+TypeQualifierLeftOpt
+ : TypeQualifierLeft[pass] { $$ = $pass; }
+ | { $$ = NULL; }
;
TypeQualifierRight
- : PrefixedType[pass] { $$ = $pass; }
- | SuffixedType[pass] { $$ = $pass; }
- | "const" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
- | "volatile" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
+ : SuffixedType[pass] { $$ = $pass; }
+ | PrefixedType[pass] { $$ = $pass; }
+ | "const" TypeQualifierRightOpt[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
+ | "volatile" TypeQualifierRightOpt[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
+ ;
+
+TypeQualifierRightOpt
+ : TypeQualifierRight[pass] { $$ = $pass; }
+ | TypeSignifierOpt[pass] { $$ = $pass; }
;
IntegerType
| { $$ = CYNew CYTypeVariable("int"); }
;
+StructFieldListOpt
+ : TypedIdentifierMaybe[typed] ";" StructFieldListOpt[next] { $$ = CYNew CYTypeStructField($typed, $next); }
+ | { $$ = NULL; }
+ ;
+
PrimitiveType
: IdentifierType[name] { $$ = CYNew CYTypeVariable($name); }
| IntegerType[pass] { $$ = $pass; }
- | "void" { $$ = CYNew CYTypeVoid(); }
| "char" { $$ = CYNew CYTypeVariable("char"); }
| "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
| "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
+ | "struct" IdentifierTypeOpt[name] "{" StructFieldListOpt[fields] "}" { $$ = CYNew CYTypeStruct($name, $fields); }
+ ;
+
+TypedIdentifierMaybe
+ : TypeQualifierLeftOpt[modifier] PrimitiveType[specifier] TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
+ | TypeQualifierLeft[modifier] "void" TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
+ | "void" TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); }
;
-TypedIdentifier
- : TypeQualifierLeft[modifier] PrimitiveType[specifier] TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
+TypedIdentifierYes
+ : TypedIdentifierMaybe[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; }
+ ;
+
+TypedIdentifierNo
+ : TypedIdentifierMaybe[typed] { if ($typed->identifier_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; }
;
PrimaryExpression
- : "@encode" "(" TypedIdentifier[typed] ")" { $$ = CYNew CYEncodedType($typed); }
+ : "@encode" "(" TypedIdentifierMaybe[typed] ")" { $$ = CYNew CYEncodedType($typed); }
;
/* }}} */
@end
;
ImplementationFieldListOpt
- : TypedIdentifier[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $next); }
+ : TypedIdentifierMaybe[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $next); }
| { $$ = NULL; }
;
-ImplementationFields
- : "{" ImplementationFieldListOpt[fields] "}" { $$ = $fields; }
- ;
-
MessageScope
: "+" { $$ = false; }
| "-" { $$ = true; }
;
TypeOpt
- : "(" TypedIdentifier[type] ")" { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); $$ = $type; }
+ : "(" TypedIdentifierNo[type] ")" { $$ = $type; }
| { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
;
;
ImplementationStatement
- : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] ImplementationFields[fields] ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); }
+ : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] "{" ImplementationFieldListOpt[fields] "}" ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); }
;
CategoryName
/* }}} */
/* Cycript (Objective-C): Block Expressions {{{ */
PrimaryExpression
- : "^" TypedIdentifier[type] { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); } "{" FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
+ : "^" TypedIdentifierNo[type] "{" FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
;
/* }}} */
/* Cycript (Objective-C): Instance Literals {{{ */
| "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
;
/* }}} */
-/* Cycript (C): auto Compatibility {{{ */
-Var_
- : "auto"
- ;
-/* }}} */
/* Cycript (C): Lambda Expressions {{{ */
TypedParameterList_
: "," TypedParameterList[parameters] { $$ = $parameters; }
;
TypedParameterList
- : TypedIdentifier[typed] TypedParameterList_[next] { $$ = CYNew CYTypedParameter($typed, $next); }
+ : TypedIdentifierMaybe[typed] TypedParameterList_[next] { $$ = CYNew CYTypedParameter($typed, $next); }
;
TypedParameterListOpt
: TypedParameterList[pass] { $$ = $pass; }
+ | "void" { $$ = NULL; }
| { $$ = NULL; }
;
PrimaryExpression
- : "[" LexOf "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifier[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
+ : "[" LexOf "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifierMaybe[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
;
/* }}} */
/* Cycript (C): Type Definitions {{{ */
+IdentifierNoOf
+ : "typedef" NewLineOpt { $$ = CYNew CYIdentifier("typedef"); }
+ ;
+
Statement__
- : "typedef" TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($typed); }
+ : "typedef" NewLineNot TypedIdentifierYes[typed] Terminator { $$ = CYNew CYTypeDefinition($typed); }
+ ;
+
+PrimaryExpression
+ : "(" LexOf "typedef" NewLineOpt TypedIdentifierNo[typed] ")" { $$ = CYNew CYTypeExpression($typed); }
;
/* }}} */
/* Cycript (C): extern "C" {{{ */
+IdentifierNoOf
+ : "extern" NewLineOpt { $$ = CYNew CYIdentifier("extern"); }
+ ;
+
Statement__
- : "extern" StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($abi, $typed); }
+ : "extern" NewLineNot StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } TypedIdentifierYes[typed] Terminator { $$ = CYNew CYExternal($abi, $typed); }
;
/* }}} */
: "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
;
-PostfixExpression
- : PostfixExpression[lhs] RubyProcExpression[rhs] LexNewLine { $$ = CYNew CYRubyBlock($lhs, $rhs); }
+RubyBlockExpression_
+ : AccessExpression[pass] LexNewLineOrOpt { $$ = $pass; }
+ | RubyBlockExpression_[lhs] RubyProcExpression[rhs] LexNewLineOrOpt { $$ = CYNew CYRubyBlock($lhs, $rhs); }
+ ;
+
+RubyBlockExpression
+ : RubyBlockExpression_[pass] "\n" { $$ = $pass; }
+ | RubyBlockExpression_[pass] { $$ = $pass; }
;
/* }}} */