%token <word_> In_ "!in"
%token <word_> InstanceOf "instanceof"
%token <word_> New "new"
-%token <word_> Of "of"
%token <word_> Return "return"
%token <word_> Switch "switch"
%token <this_> This "this"
// Woah?!
%token <identifier_> Each "each"
+%token <identifier_> Of "of"
@begin E4X
// E4X Conditional
%type <expression_> FunctionExpression
%type <identifier_> Identifier
%type <identifier_> IdentifierOpt
+%type <word_> IdentifierName
%type <comprehension_> IfComprehension
%type <statement_> IfStatement
%type <expression_> Initialiser
%type <declarations_> VariableDeclarationList
%type <statement_> VariableStatement
%type <statement_> WithStatement
+%type <word_> Word
+%type <word_> WordOpt
@begin ObjectiveC
%type <statement_> CategoryStatement
%type <word_> SelectorWordOpt
%type <expression_> TypeOpt
%type <argument_> VariadicCall
-%type <word_> Word
-%type <word_> WordOpt
@end
@begin E4X
: { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
;
-Terminator_
- : ";"
- | "\n" StrictSemi
- ;
-
Terminator
- : Terminator_
+ : ";"
| error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
;
TerminatorOpt
- : Terminator_
+ : ";"
| error { yyerrok; driver.errors_.pop_back(); } StrictSemi
;
|
;*/
-@begin ObjectiveC
NewLineOpt
: "\n"
|
;
+IdentifierName
+ : Word { $$ = $1; }
+ ;
+
Word
: Identifier { $$ = $1; }
| "break" NewLineOpt { $$ = $1; }
| "if" { $$ = $1; }
| "import" { $$ = $1; }
/* XXX: | "in" { $$ = $1; } */
+ | "!in" { $$ = $1; }
/* XXX: | "instanceof" { $$ = $1; } */
// XXX: as it currently is not an Identifier
| "new" { $$ = $1; }
| "null" { $$ = $1; }
- | "of" { $$ = $1; }
| "return" NewLineOpt { $$ = $1; }
| "super" { $$ = $1; }
| "switch" { $$ = $1; }
| { $$ = NULL; }
;
+@begin ObjectiveC
PrimaryExpression
: "@" LiteralNoRE { $$ = CYNew CYBox($2); }
| "@" ArrayLiteral { $$ = CYNew CYBox($2); }
| "yield" { $$ = $1; }
| "each" { $$ = $1; }
+ | "of" { $$ = $1; }
;
IdentifierOpt
;
PropertyName_
- : Identifier { $$ = $1; }
+ : IdentifierName { $$ = $1; }
| StringLiteral { $$ = $1; }
| NumericLiteral { $$ = $1; }
;
/* 11.2 Left-Hand-Side Expressions {{{ */
MemberAccess
: "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYDirectMember(NULL, $3); }
- | "." Identifier { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
+ | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
| "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
;
/* 12.7 The continue Statement {{{ */
ContinueStatement
- : "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
+ : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
+ | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
;
/* }}} */
/* 12.8 The break Statement {{{ */
BreakStatement
- : "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
+ : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
+ | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
;
/* }}} */
/* 12.9 The return Statement {{{ */
ReturnStatement
- : "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
+ : "return" "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
+ | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
;
/* }}} */
/* 12.10 The with Statement {{{ */
/* }}} */
/* 12.13 The throw Statement {{{ */
ThrowStatement
- : "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
+ : "throw" "\n" StrictSemi { YYABORT; }
+ | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
;
/* }}} */
/* 12.14 The try Statement {{{ */
MemberAccess
: "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
- | "->" Identifier { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
+ | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
| "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
;
/* }}} */