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
181 /* Objective-C Extensions {{{ */
183 : "," AssignmentExpression VariadicCall
193 : WordOpt ":" AssignmentExpression SelectorCall_
202 : "[" AssignmentExpression SelectorList "]"
206 /* 11.1 Primary Expressions {{{ */
217 /* 11.1.4 Array Initialiser {{{ */
219 : "[" ElementList "]"
223 : AssignmentExpression
233 : Element ElementList_
236 /* 11.1.5 Object Initialiser {{{ */
238 : "{" PropertyNameAndValueListOpt "}"
241 PropertyNameAndValueList_
242 : "," PropertyNameAndValueList
246 PropertyNameAndValueListOpt
247 : PropertyNameAndValueList
251 PropertyNameAndValueList
252 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_
265 | MemberExpression "[" Expression "]"
266 | MemberExpression "." Identifier
267 | "new" MemberExpression Arguments
272 | "new" NewExpression
276 : MemberExpression Arguments
277 | CallExpression Arguments
278 | CallExpression "[" Expression "]"
279 | CallExpression "." Identifier
293 : AssignmentExpression ArgumentList_
297 : "(" ArgumentListOpt ")"
300 LeftHandSideExpression
306 : LeftHandSideExpression
307 | LeftHandSideExpression "++"
308 | LeftHandSideExpression "--"
313 | "delete" UnaryExpression
314 | "void" UnaryExpression
315 | "typeof" UnaryExpression
316 | "++" UnaryExpression
317 | "--" UnaryExpression
318 | "+" UnaryExpression
319 | "-" UnaryExpression
320 | "~" UnaryExpression
321 | "!" UnaryExpression
322 | "*" UnaryExpression
323 | "&" UnaryExpression
326 MultiplicativeExpression
328 | MultiplicativeExpression "*" UnaryExpression
329 | MultiplicativeExpression "/" UnaryExpression
330 | MultiplicativeExpression "%" UnaryExpression
334 : MultiplicativeExpression
335 | AdditiveExpression "+" MultiplicativeExpression
336 | AdditiveExpression "-" MultiplicativeExpression
341 | ShiftExpression "<<" AdditiveExpression
342 | ShiftExpression ">>" AdditiveExpression
343 | ShiftExpression ">>>" AdditiveExpression
348 | RelationalExpression "<" ShiftExpression
349 | RelationalExpression ">" ShiftExpression
350 | RelationalExpression "<=" ShiftExpression
351 | RelationalExpression ">=" ShiftExpression
352 | RelationalExpression "instanceof" ShiftExpression
353 | RelationalExpression "in" ShiftExpression
357 : RelationalExpression
358 | EqualityExpression "==" RelationalExpression
359 | EqualityExpression "!=" RelationalExpression
360 | EqualityExpression "===" RelationalExpression
361 | EqualityExpression "!==" RelationalExpression
366 | BitwiseANDExpression "&" EqualityExpression
370 : BitwiseANDExpression
371 | BitwiseXORExpression "^" BitwiseANDExpression
375 : BitwiseXORExpression
376 | BitwiseORExpression "|" BitwiseXORExpression
380 : BitwiseORExpression
381 | LogicalANDExpression "&&" BitwiseORExpression
385 : LogicalANDExpression
386 | LogicalORExpression "||" LogicalANDExpression
389 ConditionalExpression
390 : LogicalORExpression
391 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression
395 : ConditionalExpression
396 | LeftHandSideExpression AssignmentOperator AssignmentExpression
425 : AssignmentExpression Expression_
432 | ExpressionStatement
446 : "{" StatementListOpt "}"
450 : Statement StatementListOpt
455 : "var" VariableDeclarationList ";"
458 VariableDeclarationList_
459 : "," VariableDeclarationList
463 VariableDeclarationList
464 : VariableDeclaration VariableDeclarationList_
468 : Identifier InitialiserOpt
477 : "=" AssignmentExpression
494 : "if" "(" Expression ")" Statement ElseStatementOpt
505 : "do" Statement "while" "(" Expression ")" ";"
509 : "while" "(" Expression ")" Statement
513 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement
516 ForStatementInitialiser
518 | "var" VariableDeclarationList
522 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement
525 ForInStatementInitialiser
526 : LeftHandSideExpression
527 | "var" VariableDeclaration
531 : "continue" IdentifierOpt ";"
535 : "break" IdentifierOpt ";"
539 : "return" ExpressionOpt ";"
543 : "with" "(" Expression ")" Statement
547 : "switch" "(" Expression ")" CaseBlock
551 : "{" CaseClausesOpt "}"
555 : CaseClause CaseClausesOpt
556 | DefaultClause CaseClausesOpt
561 : "case" Expression ":" StatementListOpt
565 : "default" ":" StatementListOpt
569 : Identifier ":" Statement
573 : "throw" Expression ";"
577 : "try" Block CatchOpt FinallyOpt
581 : "catch" "(" Identifier ")" Block
591 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}"
595 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}"
599 : "," FormalParameterList
604 : Identifier FormalParameterList_
617 : SourceElement SourceElements
623 | FunctionDeclaration