2 #include "Cycript.tab.hh"
3 int cylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
4 #define scanner driver->scanner_
12 CYExpression *expression_;
13 CYTokenIdentifier *identifier_;
14 CYTokenNumber *number_;
15 CYTokenString *string_;
29 %parse-param { CYParser *driver }
30 %lex-param { void *scanner }
33 %token AmpersandAmpersand "&&"
34 %token AmpersandEqual "&="
36 %token CarrotEqual "^="
38 %token EqualEqual "=="
39 %token EqualEqualEqual "==="
40 %token Exclamation "!"
41 %token ExclamationEqual "!="
42 %token ExclamationEqualEqual "!=="
44 %token HyphenEqual "-="
45 %token HyphenHyphen "--"
46 %token HyphenRight "->"
50 %token LeftLeftEqual "<<="
52 %token PercentEqual "%="
61 %token RightEqual ">="
62 %token RightRight ">>"
63 %token RightRightEqual ">>="
64 %token RightRightRight ">>>"
65 %token RightRightRightEqual ">>>="
67 %token SlashEqual "/="
83 %token OpenBracket "["
84 %token CloseBracket "]"
89 %token Continue "continue"
90 %token Default "default"
91 %token Delete "delete"
95 %token Finally "finally"
97 %token Function "function"
100 %token InstanceOf "instanceof"
103 %token Return "return"
104 %token Switch "switch"
109 %token TypeOf "typeof"
115 %token <identifier_> Identifier
116 %token <number_> NumericLiteral
117 %token <string_> StringLiteral
144 /* Objective-C Extensions {{{ */
146 : "," AssignmentExpression VariadicCall
156 : IdentifierOpt ":" AssignmentExpression SelectorCall_
165 : "[" AssignmentExpression SelectorList "]"
169 /* 11.1 Primary Expressions {{{ */
180 /* 11.1.4 Array Initialiser {{{ */
182 : "[" ElementList "]"
186 : AssignmentExpression
196 : Element ElementList_
199 /* 11.1.5 Object Initialiser {{{ */
201 : "{" PropertyNameAndValueListOpt "}"
204 PropertyNameAndValueList_
205 : "," PropertyNameAndValueList
209 PropertyNameAndValueListOpt
210 : PropertyNameAndValueList
214 PropertyNameAndValueList
215 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_
228 | MemberExpression "[" Expression "]"
229 | MemberExpression "." Identifier
230 | "new" MemberExpression Arguments
235 | "new" NewExpression
239 : MemberExpression Arguments
240 | CallExpression Arguments
241 | CallExpression "[" Expression "]"
242 | CallExpression "." Identifier
256 : AssignmentExpression ArgumentList_
260 : "(" ArgumentListOpt ")"
263 LeftHandSideExpression
269 : LeftHandSideExpression
270 | LeftHandSideExpression "++"
271 | LeftHandSideExpression "--"
276 | "delete" UnaryExpression
277 | "void" UnaryExpression
278 | "typeof" UnaryExpression
279 | "++" UnaryExpression
280 | "--" UnaryExpression
281 | "+" UnaryExpression
282 | "-" UnaryExpression
283 | "~" UnaryExpression
284 | "!" UnaryExpression
285 | "*" UnaryExpression
286 | "&" UnaryExpression
289 MultiplicativeExpression
291 | MultiplicativeExpression "*" UnaryExpression
292 | MultiplicativeExpression "/" UnaryExpression
293 | MultiplicativeExpression "%" UnaryExpression
297 : MultiplicativeExpression
298 | AdditiveExpression "+" MultiplicativeExpression
299 | AdditiveExpression "-" MultiplicativeExpression
304 | ShiftExpression "<<" AdditiveExpression
305 | ShiftExpression ">>" AdditiveExpression
306 | ShiftExpression ">>>" AdditiveExpression
311 | RelationalExpression "<" ShiftExpression
312 | RelationalExpression ">" ShiftExpression
313 | RelationalExpression "<=" ShiftExpression
314 | RelationalExpression ">=" ShiftExpression
315 | RelationalExpression "instanceof" ShiftExpression
316 | RelationalExpression "in" ShiftExpression
320 : RelationalExpression
321 | EqualityExpression "==" RelationalExpression
322 | EqualityExpression "!=" RelationalExpression
323 | EqualityExpression "===" RelationalExpression
324 | EqualityExpression "!==" RelationalExpression
329 | BitwiseANDExpression "&" EqualityExpression
333 : BitwiseANDExpression
334 | BitwiseXORExpression "^" BitwiseANDExpression
338 : BitwiseXORExpression
339 | BitwiseORExpression "|" BitwiseXORExpression
343 : BitwiseORExpression
344 | LogicalANDExpression "&&" BitwiseORExpression
348 : LogicalANDExpression
349 | LogicalORExpression "||" LogicalANDExpression
352 ConditionalExpression
353 : LogicalORExpression
354 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression
358 : ConditionalExpression
359 | LeftHandSideExpression AssignmentOperator AssignmentExpression
388 : AssignmentExpression Expression_
395 | ExpressionStatement
409 : "{" StatementListOpt "}"
413 : Statement StatementListOpt
418 : "var" VariableDeclarationList ";"
421 VariableDeclarationList_
422 : "," VariableDeclarationList
426 VariableDeclarationList
427 : VariableDeclaration VariableDeclarationList_
431 : Identifier InitialiserOpt
440 : "=" AssignmentExpression
457 : "if" "(" Expression ")" Statement ElseStatementOpt
468 : "do" Statement "while" "(" Expression ")" ";"
472 : "while" "(" Expression ")" Statement
476 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement
479 ForStatementInitialiser
481 | "var" VariableDeclarationList
485 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement
488 ForInStatementInitialiser
489 : LeftHandSideExpression
490 | "var" VariableDeclaration
494 : "continue" IdentifierOpt ";"
498 : "break" IdentifierOpt ";"
502 : "return" ExpressionOpt ";"
506 : "with" "(" Expression ")" Statement
510 : "switch" "(" Expression ")" CaseBlock
514 : "{" CaseClausesOpt "}"
518 : CaseClause CaseClausesOpt
519 | DefaultClause CaseClausesOpt
524 : "case" Expression ":" StatementListOpt
528 : "default" ":" StatementListOpt
532 : Identifier ":" Statement
536 : "throw" Expression ";"
540 : "try" Block CatchOpt FinallyOpt
544 : "catch" "(" Identifier ")" Block
554 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}"
558 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}"
562 : "," FormalParameterList
567 : Identifier FormalParameterList_
580 : SourceElement SourceElements
586 | FunctionDeclaration