X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/311fe5f36238b8a8c80e49fa85dbac81fec58887..bfd79faeaedfb0028661b7ad25a496def9d1f454:/Parser.ypp.in diff --git a/Parser.ypp.in b/Parser.ypp.in index ae85290..9797492 100644 --- a/Parser.ypp.in +++ b/Parser.ypp.in @@ -459,10 +459,11 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type ElementList %type ElementListOpt %type ElseStatementOpt -%type EmptyStatement +%type EmptyStatement %type EqualityExpression %type Expression %type ExpressionOpt +%type ExpressionStatement_ %type ExpressionStatement %type Finally %type ForBinding @@ -496,6 +497,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type LeftHandSideExpression %type LetOrConst %type LexicalBinding +%type LexicalDeclaration_ %type LexicalDeclaration %type Literal %type LiteralPropertyName @@ -548,6 +550,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY %type VariableDeclaration %type VariableDeclarationList_ %type VariableDeclarationList +%type VariableStatement_ %type VariableStatement %type WithStatement %type Word @@ -1275,8 +1278,12 @@ StatementListItem ; /* }}} */ /* 13.3 Let and Const Declarations {{{ */ +LexicalDeclaration_ + : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); } + ; + LexicalDeclaration - : LetOrConst BindingList Terminator { $$ = CYNew CYLet($1, $2); } + : LexicalDeclaration_ Terminator { $$ = $1; } ; LetOrConst @@ -1299,8 +1306,12 @@ LexicalBinding ; /* }}} */ /* 13.3.2 Variable Statement {{{ */ +VariableStatement_ + : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); } + ; + VariableStatement - : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); } + : VariableStatement_ Terminator { $$ = $1; } ; VariableDeclarationList_ @@ -1369,8 +1380,11 @@ EmptyStatement ; /* }}} */ /* 13.5 Expression Statement {{{ */ +ExpressionStatement_ + : Expression { $$ = CYNew CYExpress($1); } + ExpressionStatement - : Expression Terminator { $$ = CYNew CYExpress($1); } + : ExpressionStatement_ Terminator { $$ = $1; } ; /* }}} */ /* 13.6 The if Statement {{{ */ @@ -1387,15 +1401,16 @@ IfStatement IterationStatement : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); } | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); } - | "for" "(" LexPushInOn ForStatementInitializer ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); } + | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); } | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); } | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); } ; ForStatementInitializer - : ExpressionOpt { $$ = $1; } - | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); } - | LexSetRegExp LexicalDeclaration { CYNOT(@$); } + : LexSetRegExp EmptyStatement { $$ = $2; } + | ExpressionStatement_ ";" { $$ = $1; } + | LexSetRegExp VariableStatement_ ";" { $$ = $2; } + | LexSetRegExp LexicalDeclaration_ ";" { $$ = $2; } ; ForInStatementInitializer