CYExpression *expression_;
CYFalse *false_;
CYField *field_;
+ CYFinally *finally_;
CYForInitialiser *for_;
CYForInInitialiser *forin_;
CYFunctionParameter *functionParameter_;
CYProperty *property_;
CYPropertyName *propertyName_;
CYSelectorPart *selector_;
- CYSource *source_;
CYStatement *statement_;
CYString *string_;
CYThis *this_;
%type <compound_> ExpressionNoIn_
%type <expression_> ExpressionNoInOpt
%type <statement_> ExpressionStatement
-%type <statement_> FinallyOpt
+%type <finally_> FinallyOpt
%type <comprehension_> ForComprehension
%type <statement_> ForStatement
%type <for_> ForStatementInitialiser
%type <forin_> ForInStatementInitialiser
%type <functionParameter_> FormalParameterList
%type <functionParameter_> FormalParameterList_
-%type <source_> FunctionBody
-%type <source_> FunctionDeclaration
+%type <statement_> FunctionBody
+%type <statement_> FunctionDeclaration
%type <expression_> FunctionExpression
%type <identifier_> Identifier
%type <identifier_> IdentifierOpt
%type <expression_> PrimaryExpression
%type <expression_> PrimaryExpression_
%type <expression_> PrimaryExpressionNoBF
-%type <source_> Program
+%type <statement_> Program
%type <propertyName_> PropertyName
%type <property_> PropertyNameAndValueList
%type <property_> PropertyNameAndValueList_
%type <selector_> SelectorExpressionOpt
%type <expression_> ShiftExpression
%type <expression_> ShiftExpressionNoBF
-%type <source_> SourceElement
-%type <source_> SourceElements
+%type <statement_> SourceElement
+%type <statement_> SourceElements
%type <statement_> Statement
+%type <statement_> Statement_
%type <statement_> StatementList
%type <statement_> StatementListOpt
%type <statement_> SwitchStatement
%%
-TerminatorOpt
+StrictSemi
+ : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
+ ;
+
+Terminator_
: ";"
- | "\n"
- | error { yyerrok; driver.errors_.pop_back(); }
+ | "\n" StrictSemi
+ ;
+
+TerminatorOpt
+ : Terminator_
+ | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
;
Terminator
- : ";"
- | "\n"
- | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } }
+ : Terminator_
+ | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
;
/*CommaOpt
/* }}} */
/* 12 Statements {{{ */
-Statement
+Statement_
: Block { $$ = $1; }
| VariableStatement { $$ = $1; }
| EmptyStatement { $$ = $1; }
| ThrowStatement { $$ = $1; }
| TryStatement { $$ = $1; }
;
+
+Statement
+ : Statement_ { $$ = $1; }
+ ;
/* }}} */
/* 12.1 Block {{{ */
Block_
;
FinallyOpt
- : "finally" Block_ { $$ = $2; }
+ : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
| { $$ = NULL; }
;
/* }}} */
/* }}} */
/* 14 Program {{{ */
Program
- : SourceElements { driver.source_ = $1; }
+ : SourceElements { driver.program_ = $1; }
;
SourceElements
;
SourceElement
- : Statement { $$ = $1; }
+ : Statement_ { $$ = $1; }
| FunctionDeclaration { $$ = $1; }
;
/* }}} */
: ClassDefinition { $$ = $1; }
;
-Statement
+Statement_
: ClassDefinition { $$ = $1; }
| CategoryStatement { $$ = $1; }
;
: "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
;
/* }}} */
-/* JavaScript 1.7: Let Statements {{{ *//*
+/* JavaScript 1.7: let Statements {{{ *//*
LetStatement
: "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
;
: LetStatement
;
*//* }}} */
+/* JavaScript FTW: Function Statements {{{ */
+Statement
+ : FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $1; }
+ ;
+/* }}} */
%%