]> git.saurik.com Git - cycript.git/blame - Cycript.y.in
Updated todo, license, and title.
[cycript.git] / Cycript.y.in
CommitLineData
d15b59f5 1/* Cycript - Inlining/Optimizing JavaScript Compiler
b4aa79af
JF
2 * Copyright (C) 2009 Jay Freeman (saurik)
3*/
4
5/* Modified BSD License {{{ */
6/*
7 * Redistribution and use in source and binary
8 * forms, with or without modification, are permitted
9 * provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the
12 * above copyright notice, this list of conditions
13 * and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the
15 * above copyright notice, this list of conditions
16 * and the following disclaimer in the documentation
17 * and/or other materials provided with the
18 * distribution.
19 * 3. The name of the author may not be used to endorse
20 * or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
25 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37*/
38/* }}} */
39
1dbba6cc 40%code top {
63b4c5a8 41#include "Cycript.tab.hh"
5999c315 42#define scanner driver.scanner_
693d501b 43#define YYSTACKEXPANDABLE 1
1dbba6cc
JF
44}
45
63b4c5a8
JF
46%code requires {
47#include "Parser.hpp"
63b4c5a8 48
cbaa5f0f 49@begin ObjectiveC
3c1c3635 50#include "ObjectiveC/Syntax.hpp"
4de0686f
JF
51@end
52
691e4717
JF
53@begin E4X
54#include "E4X.hpp"
55@end
56
c3c20102
JF
57typedef struct {
58 bool newline_;
59
60 union {
b09da87b
JF
61 bool bool_;
62
63cd45c9
JF
63 CYDriver::Condition condition_;
64
c3c20102 65 CYArgument *argument_;
0ff9f149 66 CYAssignment *assignment_;
c3c20102
JF
67 CYBoolean *boolean_;
68 CYClause *clause_;
37954781 69 cy::Syntax::Catch *catch_;
75b0a457 70 CYComprehension *comprehension_;
d35a3b07 71 CYCompound *compound_;
c3c20102
JF
72 CYDeclaration *declaration_;
73 CYDeclarations *declarations_;
74 CYElement *element_;
75 CYExpression *expression_;
76 CYFalse *false_;
b10bd496 77 CYFinally *finally_;
c3c20102
JF
78 CYForInitialiser *for_;
79 CYForInInitialiser *forin_;
b09da87b 80 CYFunctionParameter *functionParameter_;
c3c20102 81 CYIdentifier *identifier_;
0ff9f149 82 CYInfix *infix_;
c3c20102 83 CYLiteral *literal_;
9b5527f0 84 CYMember *member_;
c3c20102
JF
85 CYNull *null_;
86 CYNumber *number_;
3b52fd1a 87 CYProgram *program_;
c3c20102 88 CYProperty *property_;
e5bc40db 89 CYPropertyName *propertyName_;
c3c20102
JF
90 CYStatement *statement_;
91 CYString *string_;
92 CYThis *this_;
93 CYTrue *true_;
94 CYWord *word_;
4de0686f 95
cbaa5f0f 96@begin ObjectiveC
328ad766
JF
97 CYClassName *className_;
98 CYField *field_;
4de0686f
JF
99 CYMessage *message_;
100 CYMessageParameter *messageParameter_;
101 CYSelectorPart *selector_;
102@end
691e4717
JF
103
104@begin E4X
105 CYAttribute *attribute_;
106@end
c3c20102
JF
107 };
108} YYSTYPE;
109
63b4c5a8
JF
110}
111
693d501b
JF
112%code provides {
113int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
114}
115
1dbba6cc 116%name-prefix "cy"
e5332278 117
63b4c5a8 118%language "C++"
e5332278 119%locations
1dbba6cc 120
5999c315
JF
121%initial-action {
122 @$.begin.filename = @$.end.filename = &driver.filename_;
123};
124
e5332278 125%defines
1dbba6cc 126
534fb6da
JF
127//%glr-parser
128//%expect 1
cac61857 129
e5332278
JF
130%error-verbose
131
5999c315 132%parse-param { CYDriver &driver }
924f67b2 133%lex-param { void *scanner }
e5332278 134
cb02f8ae 135@begin E4X
cb02f8ae
JF
136%token XMLCDATA
137%token XMLComment
138%token XMLPI
691e4717
JF
139
140%token XMLAttributeValue
141%token XMLName
142%token XMLTagCharacters
143%token XMLText
144%token XMLWhitespace
145@end
146
147@begin E4X
148%token LeftRight "<>"
149%token LeftSlashRight "</>"
150
151%token SlashRight "/>"
152%token LeftSlash "</"
153
154%token At "@"
155%token ColonColon "::"
156%token PeriodPeriod ".."
cb02f8ae 157@end
ac9a5ce1 158
63b4c5a8
JF
159%token Ampersand "&"
160%token AmpersandAmpersand "&&"
161%token AmpersandEqual "&="
162%token Carrot "^"
163%token CarrotEqual "^="
164%token Equal "="
165%token EqualEqual "=="
166%token EqualEqualEqual "==="
167%token Exclamation "!"
168%token ExclamationEqual "!="
169%token ExclamationEqualEqual "!=="
170%token Hyphen "-"
171%token HyphenEqual "-="
172%token HyphenHyphen "--"
c3c20102 173%token HyphenHyphen_ "\n--"
63b4c5a8
JF
174%token HyphenRight "->"
175%token Left "<"
176%token LeftEqual "<="
177%token LeftLeft "<<"
178%token LeftLeftEqual "<<="
179%token Percent "%"
180%token PercentEqual "%="
181%token Period "."
182%token Pipe "|"
183%token PipeEqual "|="
184%token PipePipe "||"
185%token Plus "+"
186%token PlusEqual "+="
187%token PlusPlus "++"
c3c20102 188%token PlusPlus_ "\n++"
63b4c5a8
JF
189%token Right ">"
190%token RightEqual ">="
191%token RightRight ">>"
192%token RightRightEqual ">>="
193%token RightRightRight ">>>"
194%token RightRightRightEqual ">>>="
195%token Slash "/"
196%token SlashEqual "/="
197%token Star "*"
198%token StarEqual "*="
199%token Tilde "~"
200
201%token Colon ":"
202%token Comma ","
203%token Question "?"
204%token SemiColon ";"
c3c20102 205%token NewLine "\n"
63b4c5a8
JF
206
207%token OpenParen "("
208%token CloseParen ")"
924f67b2 209
63b4c5a8
JF
210%token OpenBrace "{"
211%token CloseBrace "}"
924f67b2 212
63b4c5a8
JF
213%token OpenBracket "["
214%token CloseBracket "]"
215
b09da87b 216%token AtClass "@class"
e7ed5354 217%token AtSelector "@selector"
d35a3b07 218%token AtEnd "@end"
e7ed5354 219
534fb6da
JF
220%token <false_> False "false"
221%token <null_> Null "null"
222%token <true_> True "true"
223
224// ES3/ES5/WIE/JSC Reserved
cf7d4c69
JF
225%token <word_> Break "break"
226%token <word_> Case "case"
227%token <word_> Catch "catch"
228%token <word_> Continue "continue"
229%token <word_> Default "default"
230%token <word_> Delete "delete"
231%token <word_> Do "do"
232%token <word_> Else "else"
cf7d4c69
JF
233%token <word_> Finally "finally"
234%token <word_> For "for"
235%token <word_> Function "function"
236%token <word_> If "if"
237%token <word_> In "in"
238%token <word_> InstanceOf "instanceof"
239%token <word_> New "new"
cf7d4c69
JF
240%token <word_> Return "return"
241%token <word_> Switch "switch"
242%token <this_> This "this"
243%token <word_> Throw "throw"
cf7d4c69
JF
244%token <word_> Try "try"
245%token <word_> TypeOf "typeof"
246%token <word_> Var "var"
247%token <word_> Void "void"
248%token <word_> While "while"
249%token <word_> With "with"
63b4c5a8 250
534fb6da 251// ES3/IE6 Future, ES5/JSC Reserved
d35a3b07 252%token <word_> Debugger "debugger"
534fb6da
JF
253
254// ES3/ES5/IE6 Future, JSC Reserved
255%token <word_> Const "const"
256
257// ES3/ES5/IE6/JSC Future
258%token <word_> Class "class"
d35a3b07
JF
259%token <word_> Enum "enum"
260%token <word_> Export "export"
261%token <word_> Extends "extends"
d35a3b07 262%token <word_> Import "import"
d35a3b07 263%token <word_> Super "super"
d35a3b07 264
534fb6da
JF
265// ES3 Future, ES5 Strict Future
266%token <identifier_> Implements "implements"
267%token <identifier_> Interface "interface"
268%token <identifier_> Package "package"
269%token <identifier_> Private "private"
270%token <identifier_> Protected "protected"
271%token <identifier_> Public "public"
272%token <identifier_> Static "static"
273
274// ES3 Future
275%token <identifier_> Abstract "abstract"
276%token <identifier_> Boolean "boolean"
277%token <identifier_> Byte "byte"
278%token <identifier_> Char "char"
279%token <identifier_> Double "double"
280%token <identifier_> Final "final"
281%token <identifier_> Float "float"
282%token <identifier_> Goto "goto"
283%token <identifier_> Int "int"
284%token <identifier_> Long "long"
285%token <identifier_> Native "native"
286%token <identifier_> Short "short"
287%token <identifier_> Synchronized "synchronized"
288%token <identifier_> Throws "throws"
289%token <identifier_> Transient "transient"
290%token <identifier_> Volatile "volatile"
291
292// ES5 Strict
cac61857 293%token <identifier_> Let "let"
534fb6da
JF
294%token <identifier_> Yield "yield"
295
296// Woah?!
297%token <identifier_> Each "each"
75b0a457 298
691e4717
JF
299@begin E4X
300// E4X Conditional
301%token <identifier_> Namespace "namespace"
302%token <identifier_> XML "xml"
303@end
304
75b0a457 305%token <identifier_> Identifier_
63b4c5a8
JF
306%token <number_> NumericLiteral
307%token <string_> StringLiteral
63cd45c9 308%token <literal_> RegularExpressionLiteral
1dbba6cc 309
cf7d4c69 310%type <expression_> AdditiveExpression
693d501b 311%type <expression_> AdditiveExpressionNoBF
cf7d4c69
JF
312%type <argument_> ArgumentList
313%type <argument_> ArgumentList_
314%type <argument_> ArgumentListOpt
315%type <argument_> Arguments
316%type <literal_> ArrayLiteral
9b5527f0 317%type <expression_> AssigneeExpression
9b5527f0 318%type <expression_> AssigneeExpressionNoBF
cf7d4c69 319%type <expression_> AssignmentExpression
0ff9f149 320%type <assignment_> AssignmentExpression_
693d501b
JF
321%type <expression_> AssignmentExpressionNoBF
322%type <expression_> AssignmentExpressionNoIn
cf7d4c69 323%type <expression_> BitwiseANDExpression
693d501b
JF
324%type <expression_> BitwiseANDExpressionNoBF
325%type <expression_> BitwiseANDExpressionNoIn
cf7d4c69 326%type <statement_> Block
cac61857 327%type <statement_> Block_
cf7d4c69
JF
328%type <boolean_> BooleanLiteral
329%type <expression_> BitwiseORExpression
693d501b
JF
330%type <expression_> BitwiseORExpressionNoBF
331%type <expression_> BitwiseORExpressionNoIn
cf7d4c69 332%type <expression_> BitwiseXORExpression
693d501b
JF
333%type <expression_> BitwiseXORExpressionNoBF
334%type <expression_> BitwiseXORExpressionNoIn
cf7d4c69
JF
335%type <statement_> BreakStatement
336%type <expression_> CallExpression
693d501b 337%type <expression_> CallExpressionNoBF
cf7d4c69
JF
338%type <clause_> CaseBlock
339%type <clause_> CaseClause
340%type <clause_> CaseClausesOpt
341%type <catch_> CatchOpt
75b0a457
JF
342%type <comprehension_> ComprehensionList
343%type <comprehension_> ComprehensionListOpt
cf7d4c69 344%type <expression_> ConditionalExpression
693d501b
JF
345%type <expression_> ConditionalExpressionNoBF
346%type <expression_> ConditionalExpressionNoIn
cf7d4c69
JF
347%type <statement_> ContinueStatement
348%type <clause_> DefaultClause
349%type <statement_> DoWhileStatement
350%type <expression_> Element
5befe15e 351%type <expression_> ElementOpt
cf7d4c69 352%type <element_> ElementList
5befe15e 353%type <element_> ElementListOpt
cf7d4c69
JF
354%type <statement_> ElseStatementOpt
355%type <statement_> EmptyStatement
356%type <expression_> EqualityExpression
693d501b
JF
357%type <expression_> EqualityExpressionNoBF
358%type <expression_> EqualityExpressionNoIn
cf7d4c69 359%type <expression_> Expression
cf7d4c69 360%type <expression_> ExpressionOpt
d35a3b07 361%type <compound_> Expression_
693d501b
JF
362%type <expression_> ExpressionNoBF
363%type <expression_> ExpressionNoIn
d35a3b07 364%type <compound_> ExpressionNoIn_
693d501b 365%type <expression_> ExpressionNoInOpt
cf7d4c69 366%type <statement_> ExpressionStatement
b10bd496 367%type <finally_> FinallyOpt
75b0a457 368%type <comprehension_> ForComprehension
cf7d4c69
JF
369%type <statement_> ForStatement
370%type <for_> ForStatementInitialiser
371%type <statement_> ForInStatement
372%type <forin_> ForInStatementInitialiser
b09da87b
JF
373%type <functionParameter_> FormalParameterList
374%type <functionParameter_> FormalParameterList_
b10bd496
JF
375%type <statement_> FunctionBody
376%type <statement_> FunctionDeclaration
cf7d4c69 377%type <expression_> FunctionExpression
75b0a457 378%type <identifier_> Identifier
cf7d4c69 379%type <identifier_> IdentifierOpt
75b0a457 380%type <comprehension_> IfComprehension
cf7d4c69
JF
381%type <statement_> IfStatement
382%type <expression_> Initialiser
383%type <expression_> InitialiserOpt
693d501b
JF
384%type <expression_> InitialiserNoIn
385%type <expression_> InitialiserNoInOpt
cf7d4c69
JF
386%type <statement_> IterationStatement
387%type <statement_> LabelledStatement
388%type <expression_> LeftHandSideExpression
693d501b 389%type <expression_> LeftHandSideExpressionNoBF
534fb6da 390//%type <statement_> LetStatement
cf7d4c69
JF
391%type <literal_> Literal
392%type <expression_> LogicalANDExpression
693d501b
JF
393%type <expression_> LogicalANDExpressionNoBF
394%type <expression_> LogicalANDExpressionNoIn
cf7d4c69 395%type <expression_> LogicalORExpression
693d501b
JF
396%type <expression_> LogicalORExpressionNoBF
397%type <expression_> LogicalORExpressionNoIn
9b5527f0 398%type <member_> MemberAccess
cf7d4c69 399%type <expression_> MemberExpression
693d501b
JF
400%type <expression_> MemberExpression_
401%type <expression_> MemberExpressionNoBF
cf7d4c69 402%type <expression_> MultiplicativeExpression
693d501b 403%type <expression_> MultiplicativeExpressionNoBF
cf7d4c69 404%type <expression_> NewExpression
693d501b
JF
405%type <expression_> NewExpression_
406%type <expression_> NewExpressionNoBF
cf7d4c69
JF
407%type <null_> NullLiteral
408%type <literal_> ObjectLiteral
cf7d4c69 409%type <expression_> PostfixExpression
693d501b 410%type <expression_> PostfixExpressionNoBF
cf7d4c69 411%type <expression_> PrimaryExpression
693d501b
JF
412%type <expression_> PrimaryExpression_
413%type <expression_> PrimaryExpressionNoBF
697d6fd2 414%type <expression_> PrimaryExpressionNoBF_
b10bd496 415%type <statement_> Program
e5bc40db 416%type <propertyName_> PropertyName
cf7d4c69
JF
417%type <property_> PropertyNameAndValueList
418%type <property_> PropertyNameAndValueList_
419%type <property_> PropertyNameAndValueListOpt
420%type <expression_> RelationalExpression
0ff9f149 421%type <infix_> RelationalExpression_
693d501b
JF
422%type <expression_> RelationalExpressionNoBF
423%type <expression_> RelationalExpressionNoIn
0ff9f149 424%type <infix_> RelationalExpressionNoIn_
cf7d4c69 425%type <statement_> ReturnStatement
cf7d4c69 426%type <expression_> ShiftExpression
693d501b 427%type <expression_> ShiftExpressionNoBF
b10bd496 428%type <statement_> SourceElement
697d6fd2 429%type <statement_> SourceElement_
b10bd496 430%type <statement_> SourceElements
cf7d4c69 431%type <statement_> Statement
b10bd496 432%type <statement_> Statement_
693d501b 433%type <statement_> StatementList
cf7d4c69
JF
434%type <statement_> StatementListOpt
435%type <statement_> SwitchStatement
436%type <statement_> ThrowStatement
437%type <statement_> TryStatement
697d6fd2 438%type <expression_> UnaryAssigneeExpression
cf7d4c69 439%type <expression_> UnaryExpression
693d501b
JF
440%type <expression_> UnaryExpression_
441%type <expression_> UnaryExpressionNoBF
cf7d4c69 442%type <declaration_> VariableDeclaration
693d501b 443%type <declaration_> VariableDeclarationNoIn
cf7d4c69
JF
444%type <declarations_> VariableDeclarationList
445%type <declarations_> VariableDeclarationList_
693d501b
JF
446%type <declarations_> VariableDeclarationListNoIn
447%type <declarations_> VariableDeclarationListNoIn_
cf7d4c69 448%type <statement_> VariableStatement
cf7d4c69
JF
449%type <statement_> WhileStatement
450%type <statement_> WithStatement
cf7d4c69 451
cbaa5f0f 452@begin ObjectiveC
328ad766
JF
453%type <statement_> CategoryStatement
454%type <expression_> ClassExpression
455%type <statement_> ClassStatement
456%type <expression_> ClassSuperOpt
457%type <field_> ClassFieldList
458%type <message_> ClassMessageDeclaration
459%type <message_> ClassMessageDeclarationListOpt
460%type <className_> ClassName
461%type <className_> ClassNameOpt
693d501b 462%type <expression_> MessageExpression
328ad766
JF
463%type <messageParameter_> MessageParameter
464%type <messageParameter_> MessageParameters
465%type <messageParameter_> MessageParameterList
466%type <messageParameter_> MessageParameterListOpt
467%type <bool_> MessageScope
693d501b
JF
468%type <argument_> SelectorCall
469%type <argument_> SelectorCall_
328ad766
JF
470%type <selector_> SelectorExpression
471%type <selector_> SelectorExpression_
472%type <selector_> SelectorExpressionOpt
693d501b 473%type <argument_> SelectorList
328ad766 474%type <expression_> TypeOpt
693d501b 475%type <argument_> VariadicCall
328ad766
JF
476%type <word_> Word
477%type <word_> WordOpt
478@end
693d501b 479
691e4717
JF
480@begin E4X
481%type <identifier_> PropertyIdentifier_
482%type <identifier_> PropertySelector
483%type <identifier_> PropertySelector_
484%type <identifier_> QualifiedIdentifier
485%type <identifier_> QualifiedIdentifier_
486%type <identifier_> WildcardIdentifier
487%type <identifier_> XMLComment
488%type <identifier_> XMLCDATA
489%type <identifier_> XMLElement
490%type <identifier_> XMLElementContent
491%type <identifier_> XMLMarkup
492%type <identifier_> XMLPI
493
494%type <attribute_> AttributeIdentifier
495%type <statement_> DefaultXMLNamespaceStatement
496%type <expression_> PropertyIdentifier
497%type <expression_> XMLListInitialiser
498%type <expression_> XMLInitialiser
499@end
500
501/*
cde525f7
JF
502%left "*" "/" "%"
503%left "+" "-"
504%left "<<" ">>" ">>>"
505%left "<" ">" "<=" ">=" "instanceof" "in"
506%left "==" "!=" "===" "!=="
507%left "&"
508%left "^"
509%left "|"
510%left "&&"
511%left "||"
512
513%right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
691e4717 514*/
cde525f7 515
c3c20102
JF
516%nonassoc "if"
517%nonassoc "else"
518
693d501b 519%start Program
e5332278 520
693d501b 521%%
c3c20102 522
691e4717
JF
523/* Lexer State {{{ */
524LexSetRegExp
525 : { driver.SetCondition(CYDriver::RegExpCondition); }
526 ;
527/* }}} */
528
b10bd496
JF
529StrictSemi
530 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
531 ;
532
533Terminator_
c3c20102 534 : ";"
b10bd496
JF
535 | "\n" StrictSemi
536 ;
537
538TerminatorOpt
539 : Terminator_
540 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
c3c20102
JF
541 ;
542
543Terminator
b10bd496
JF
544 : Terminator_
545 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
c3c20102
JF
546 ;
547
cac61857 548/*CommaOpt
693d501b
JF
549 : ","
550 |
cac61857 551 ;*/
693d501b 552
cbaa5f0f 553@begin ObjectiveC
c3c20102 554NewLineOpt
693d501b 555 : "\n"
c3c20102
JF
556 |
557 ;
1dbba6cc 558
36cd3cb9 559WordOpt
cf7d4c69
JF
560 : Word { $$ = $1; }
561 | { $$ = NULL; }
2bf24581
JF
562 ;
563
36cd3cb9 564Word
cf7d4c69 565 : Identifier { $$ = $1; }
c3c20102 566 | "break" NewLineOpt { $$ = $1; }
cf7d4c69
JF
567 | "case" { $$ = $1; }
568 | "catch" { $$ = $1; }
d35a3b07
JF
569 | "class" { $$ = $1; }
570 | "const" { $$ = $1; }
c3c20102 571 | "continue" NewLineOpt { $$ = $1; }
d35a3b07 572 | "debugger" { $$ = $1; }
cf7d4c69
JF
573 | "default" { $$ = $1; }
574 | "delete" { $$ = $1; }
575 | "do" { $$ = $1; }
576 | "else" { $$ = $1; }
d35a3b07
JF
577 | "enum" { $$ = $1; }
578 | "export" { $$ = $1; }
579 | "extends" { $$ = $1; }
cf7d4c69
JF
580 | "false" { $$ = $1; }
581 | "finally" { $$ = $1; }
582 | "for" { $$ = $1; }
583 | "function" { $$ = $1; }
584 | "if" { $$ = $1; }
d35a3b07 585 | "import" { $$ = $1; }
693d501b
JF
586 /* XXX: | "in" { $$ = $1; } */
587 /* XXX: | "instanceof" { $$ = $1; } */
cf7d4c69
JF
588 | "new" { $$ = $1; }
589 | "null" { $$ = $1; }
c3c20102 590 | "return" NewLineOpt { $$ = $1; }
d35a3b07 591 | "super" { $$ = $1; }
cf7d4c69
JF
592 | "switch" { $$ = $1; }
593 | "this" { $$ = $1; }
c3c20102 594 | "throw" NewLineOpt { $$ = $1; }
cf7d4c69
JF
595 | "true" { $$ = $1; }
596 | "try" { $$ = $1; }
597 | "typeof" { $$ = $1; }
598 | "var" { $$ = $1; }
599 | "void" { $$ = $1; }
600 | "while" { $$ = $1; }
601 | "with" { $$ = $1; }
2bf24581 602 ;
328ad766 603@end
2bf24581 604
75b0a457
JF
605Identifier
606 : Identifier_ { $$ = $1; }
534fb6da
JF
607
608 | "implements" { $$ = $1; }
609 | "interface" { $$ = $1; }
610 | "package" { $$ = $1; }
611 | "private" { $$ = $1; }
612 | "protected" { $$ = $1; }
613 | "public" { $$ = $1; }
614 | "static" { $$ = $1; }
615
616 | "abstract" { $$ = $1; }
617 | "boolean" { $$ = $1; }
618 | "byte" { $$ = $1; }
619 | "char" { $$ = $1; }
620 | "double" { $$ = $1; }
621 | "final" { $$ = $1; }
622 | "float" { $$ = $1; }
623 | "goto" { $$ = $1; }
624 | "int" { $$ = $1; }
625 | "long" { $$ = $1; }
626 | "native" { $$ = $1; }
627 | "short" { $$ = $1; }
628 | "synchronized" { $$ = $1; }
629 | "throws" { $$ = $1; }
630 | "transient" { $$ = $1; }
631 | "volatile" { $$ = $1; }
632
cac61857 633 | "let" { $$ = $1; }
534fb6da
JF
634 | "yield" { $$ = $1; }
635
636 | "each" { $$ = $1; }
75b0a457
JF
637 ;
638
36cd3cb9 639IdentifierOpt
cf7d4c69
JF
640 : Identifier { $$ = $1; }
641 | { $$ = NULL; }
1dbba6cc
JF
642 ;
643
36cd3cb9 644Literal
cf7d4c69
JF
645 : NullLiteral { $$ = $1; }
646 | BooleanLiteral { $$ = $1; }
647 | NumericLiteral { $$ = $1; }
648 | StringLiteral { $$ = $1; }
697d6fd2 649 | RegularExpressionLiteral { $$ = $1; }
1dbba6cc
JF
650 ;
651
36cd3cb9 652NullLiteral
cf7d4c69 653 : "null" { $$ = $1; }
1dbba6cc
JF
654 ;
655
36cd3cb9 656BooleanLiteral
cf7d4c69
JF
657 : "true" { $$ = $1; }
658 | "false" { $$ = $1; }
1dbba6cc
JF
659 ;
660
1dbba6cc 661/* 11.1 Primary Expressions {{{ */
693d501b 662PrimaryExpression_
697d6fd2
JF
663 : ObjectLiteral { $$ = $1; }
664 | PrimaryExpressionNoBF_ { $$ = $1; }
665 ;
666
667PrimaryExpressionNoBF_
cf7d4c69 668 : "this" { $$ = $1; }
b1ff2d78 669 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
cf7d4c69
JF
670 | Literal { $$ = $1; }
671 | ArrayLiteral { $$ = $1; }
36cd3cb9 672 | "(" Expression ")" { $$ = $2; }
693d501b
JF
673 ;
674
675PrimaryExpression
691e4717 676 : LexSetRegExp PrimaryExpression_ { $$ = $2; }
693d501b
JF
677 ;
678
679PrimaryExpressionNoBF
697d6fd2 680 : PrimaryExpressionNoBF_ { $$ = $1; }
1dbba6cc
JF
681 ;
682/* }}} */
683/* 11.1.4 Array Initialiser {{{ */
36cd3cb9 684ArrayLiteral
d35a3b07 685 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
1dbba6cc
JF
686 ;
687
36cd3cb9 688Element
cf7d4c69 689 : AssignmentExpression { $$ = $1; }
5befe15e
JF
690 ;
691
692ElementOpt
693 : Element { $$ = $1; }
691e4717 694 | LexSetRegExp { $$ = NULL; }
1dbba6cc
JF
695 ;
696
5befe15e
JF
697ElementListOpt
698 : ElementList { $$ = $1; }
691e4717 699 | LexSetRegExp { $$ = NULL; }
1dbba6cc
JF
700 ;
701
36cd3cb9 702ElementList
5befe15e
JF
703 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
704 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
1dbba6cc
JF
705 ;
706/* }}} */
707/* 11.1.5 Object Initialiser {{{ */
36cd3cb9 708ObjectLiteral
5befe15e 709 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
1dbba6cc
JF
710 ;
711
36cd3cb9 712PropertyNameAndValueList_
cf7d4c69 713 : "," PropertyNameAndValueList { $$ = $2; }
cac61857 714 | { $$ = NULL; }
1dbba6cc
JF
715 ;
716
36cd3cb9 717PropertyNameAndValueListOpt
cf7d4c69 718 : PropertyNameAndValueList { $$ = $1; }
36cd3cb9 719 | { $$ = NULL; }
1dbba6cc
JF
720 ;
721
36cd3cb9
JF
722PropertyNameAndValueList
723 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
1dbba6cc
JF
724 ;
725
726PropertyName
36cd3cb9
JF
727 : Identifier { $$ = $1; }
728 | StringLiteral { $$ = $1; }
729 | NumericLiteral { $$ = $1; }
1dbba6cc
JF
730 ;
731/* }}} */
732
63cd45c9 733/* 11.2 Left-Hand-Side Expressions {{{ */
693d501b
JF
734MemberExpression_
735 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
736 ;
737
9b5527f0
JF
738MemberAccess
739 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
740 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
741 ;
742
36cd3cb9 743MemberExpression
cf7d4c69
JF
744 : PrimaryExpression { $$ = $1; }
745 | FunctionExpression { $$ = $1; }
9b5527f0 746 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
691e4717 747 | LexSetRegExp MemberExpression_ { $$ = $2; }
693d501b
JF
748 ;
749
750MemberExpressionNoBF
751 : PrimaryExpressionNoBF { $$ = $1; }
9b5527f0 752 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
693d501b
JF
753 | MemberExpression_ { $$ = $1; }
754 ;
755
756NewExpression_
757 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
1dbba6cc
JF
758 ;
759
36cd3cb9 760NewExpression
cf7d4c69 761 : MemberExpression { $$ = $1; }
691e4717 762 | LexSetRegExp NewExpression_ { $$ = $2; }
693d501b
JF
763 ;
764
765NewExpressionNoBF
766 : MemberExpressionNoBF { $$ = $1; }
767 | NewExpression_ { $$ = $1; }
1dbba6cc
JF
768 ;
769
36cd3cb9 770CallExpression
b1ff2d78
JF
771 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
772 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
9b5527f0 773 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
1dbba6cc
JF
774 ;
775
693d501b
JF
776CallExpressionNoBF
777 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
778 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
9b5527f0 779 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
693d501b
JF
780 ;
781
36cd3cb9 782ArgumentList_
cf7d4c69
JF
783 : "," ArgumentList { $$ = $2; }
784 | { $$ = NULL; }
1dbba6cc
JF
785 ;
786
36cd3cb9 787ArgumentListOpt
cf7d4c69 788 : ArgumentList { $$ = $1; }
691e4717 789 | LexSetRegExp { $$ = NULL; }
1dbba6cc
JF
790 ;
791
36cd3cb9
JF
792ArgumentList
793 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
1dbba6cc
JF
794 ;
795
796Arguments
36cd3cb9 797 : "(" ArgumentListOpt ")" { $$ = $2; }
1dbba6cc
JF
798 ;
799
36cd3cb9 800LeftHandSideExpression
cf7d4c69
JF
801 : NewExpression { $$ = $1; }
802 | CallExpression { $$ = $1; }
693d501b
JF
803 ;
804
805LeftHandSideExpressionNoBF
806 : NewExpressionNoBF { $$ = $1; }
807 | CallExpressionNoBF { $$ = $1; }
1dbba6cc 808 ;
63cd45c9
JF
809/* }}} */
810/* 11.3 Postfix Expressions {{{ */
36cd3cb9 811PostfixExpression
9b5527f0 812 : AssigneeExpression { $$ = $1; }
b1ff2d78
JF
813 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
814 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
1dbba6cc
JF
815 ;
816
693d501b 817PostfixExpressionNoBF
9b5527f0 818 : AssigneeExpressionNoBF { $$ = $1; }
693d501b
JF
819 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
820 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
821 ;
63cd45c9
JF
822/* }}} */
823/* 11.4 Unary Operators {{{ */
693d501b
JF
824UnaryExpression_
825 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
36cd3cb9
JF
826 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
827 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
828 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
829 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
830 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
831 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
c0bc320e 832 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
36cd3cb9
JF
833 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
834 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
835 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
693d501b
JF
836 ;
837
838UnaryExpression
839 : PostfixExpression { $$ = $1; }
691e4717 840 | LexSetRegExp UnaryExpression_ { $$ = $2; }
693d501b
JF
841 ;
842
843UnaryExpressionNoBF
844 : PostfixExpressionNoBF { $$ = $1; }
845 | UnaryExpression_ { $$ = $1; }
1dbba6cc 846 ;
63cd45c9
JF
847/* }}} */
848/* 11.5 Multiplicative Operators {{{ */
36cd3cb9 849MultiplicativeExpression
cf7d4c69 850 : UnaryExpression { $$ = $1; }
36cd3cb9
JF
851 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
852 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
853 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
1dbba6cc
JF
854 ;
855
693d501b
JF
856MultiplicativeExpressionNoBF
857 : UnaryExpressionNoBF { $$ = $1; }
858 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
859 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
860 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
861 ;
63cd45c9
JF
862/* }}} */
863/* 11.6 Additive Operators {{{ */
36cd3cb9 864AdditiveExpression
cf7d4c69 865 : MultiplicativeExpression { $$ = $1; }
36cd3cb9
JF
866 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
867 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
1dbba6cc
JF
868 ;
869
693d501b
JF
870AdditiveExpressionNoBF
871 : MultiplicativeExpressionNoBF { $$ = $1; }
872 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
873 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
874 ;
63cd45c9
JF
875/* }}} */
876/* 11.7 Bitwise Shift Operators {{{ */
36cd3cb9 877ShiftExpression
cf7d4c69 878 : AdditiveExpression { $$ = $1; }
36cd3cb9
JF
879 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
880 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
881 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1dbba6cc
JF
882 ;
883
693d501b
JF
884ShiftExpressionNoBF
885 : AdditiveExpressionNoBF { $$ = $1; }
886 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
887 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
888 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
889 ;
63cd45c9
JF
890/* }}} */
891/* 11.8 Relational Operators {{{ */
0ff9f149
JF
892RelationalExpressionNoIn_
893 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
894 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
895 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
896 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
897 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
898 ;
899
900RelationalExpression_
901 : RelationalExpressionNoIn_ { $$ = $1; }
902 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
903 ;
904
36cd3cb9 905RelationalExpression
cf7d4c69 906 : ShiftExpression { $$ = $1; }
0ff9f149 907 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1dbba6cc
JF
908 ;
909
693d501b
JF
910RelationalExpressionNoIn
911 : ShiftExpression { $$ = $1; }
0ff9f149 912 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
693d501b
JF
913 ;
914
915RelationalExpressionNoBF
916 : ShiftExpressionNoBF { $$ = $1; }
0ff9f149 917 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
693d501b 918 ;
63cd45c9
JF
919/* }}} */
920/* 11.9 Equality Operators {{{ */
36cd3cb9 921EqualityExpression
cf7d4c69 922 : RelationalExpression { $$ = $1; }
36cd3cb9
JF
923 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
924 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
925 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
926 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1dbba6cc
JF
927 ;
928
693d501b
JF
929EqualityExpressionNoIn
930 : RelationalExpressionNoIn { $$ = $1; }
931 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
932 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
933 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
934 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
935 ;
936
937EqualityExpressionNoBF
938 : RelationalExpressionNoBF { $$ = $1; }
939 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
940 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
941 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
942 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
943 ;
63cd45c9
JF
944/* }}} */
945/* 11.10 Binary Bitwise Operators {{{ */
36cd3cb9 946BitwiseANDExpression
cf7d4c69 947 : EqualityExpression { $$ = $1; }
36cd3cb9 948 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1dbba6cc
JF
949 ;
950
693d501b
JF
951BitwiseANDExpressionNoIn
952 : EqualityExpressionNoIn { $$ = $1; }
953 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
954 ;
955
956BitwiseANDExpressionNoBF
957 : EqualityExpressionNoBF { $$ = $1; }
958 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
959 ;
960
36cd3cb9 961BitwiseXORExpression
cf7d4c69 962 : BitwiseANDExpression { $$ = $1; }
36cd3cb9 963 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1dbba6cc
JF
964 ;
965
693d501b
JF
966BitwiseXORExpressionNoIn
967 : BitwiseANDExpressionNoIn { $$ = $1; }
968 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
969 ;
970
971BitwiseXORExpressionNoBF
972 : BitwiseANDExpressionNoBF { $$ = $1; }
973 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
974 ;
975
36cd3cb9 976BitwiseORExpression
cf7d4c69 977 : BitwiseXORExpression { $$ = $1; }
36cd3cb9 978 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1dbba6cc
JF
979 ;
980
693d501b
JF
981BitwiseORExpressionNoIn
982 : BitwiseXORExpressionNoIn { $$ = $1; }
983 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
984 ;
985
986BitwiseORExpressionNoBF
987 : BitwiseXORExpressionNoBF { $$ = $1; }
988 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
989 ;
63cd45c9
JF
990/* }}} */
991/* 11.11 Binary Logical Operators {{{ */
36cd3cb9 992LogicalANDExpression
cf7d4c69 993 : BitwiseORExpression { $$ = $1; }
36cd3cb9 994 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1dbba6cc
JF
995 ;
996
693d501b
JF
997LogicalANDExpressionNoIn
998 : BitwiseORExpressionNoIn { $$ = $1; }
999 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1000 ;
1001
1002LogicalANDExpressionNoBF
1003 : BitwiseORExpressionNoBF { $$ = $1; }
1004 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1005 ;
1006
36cd3cb9 1007LogicalORExpression
cf7d4c69 1008 : LogicalANDExpression { $$ = $1; }
36cd3cb9 1009 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1dbba6cc
JF
1010 ;
1011
693d501b
JF
1012LogicalORExpressionNoIn
1013 : LogicalANDExpressionNoIn { $$ = $1; }
1014 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1015 ;
1016
1017LogicalORExpressionNoBF
1018 : LogicalANDExpressionNoBF { $$ = $1; }
1019 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1020 ;
63cd45c9
JF
1021/* }}} */
1022/* 11.12 Conditional Operator ( ? : ) {{{ */
36cd3cb9 1023ConditionalExpression
cf7d4c69 1024 : LogicalORExpression { $$ = $1; }
36cd3cb9 1025 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1dbba6cc
JF
1026 ;
1027
693d501b
JF
1028ConditionalExpressionNoIn
1029 : LogicalORExpressionNoIn { $$ = $1; }
1030 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1031 ;
1032
1033ConditionalExpressionNoBF
1034 : LogicalORExpressionNoBF { $$ = $1; }
1035 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1036 ;
63cd45c9
JF
1037/* }}} */
1038/* 11.13 Assignment Operators {{{ */
0ff9f149
JF
1039AssignmentExpression_
1040 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1041 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1042 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1043 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1044 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1045 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1046 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1047 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1048 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1049 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1050 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1051 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1052 ;
1053
9b5527f0
JF
1054AssigneeExpression
1055 : LeftHandSideExpression { $$ = $1; }
691e4717 1056 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
9b5527f0
JF
1057 ;
1058
1059AssigneeExpressionNoBF
1060 : LeftHandSideExpressionNoBF { $$ = $1; }
697d6fd2 1061 | UnaryAssigneeExpression { $$ = $1; }
9b5527f0
JF
1062 ;
1063
36cd3cb9 1064AssignmentExpression
cf7d4c69 1065 : ConditionalExpression { $$ = $1; }
9b5527f0 1066 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
36cd3cb9
JF
1067 ;
1068
693d501b
JF
1069AssignmentExpressionNoIn
1070 : ConditionalExpressionNoIn { $$ = $1; }
9b5527f0
JF
1071 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1072 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1073 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1074 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1075 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1076 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1077 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1078 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1079 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1080 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1081 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1082 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
693d501b
JF
1083 ;
1084
1085AssignmentExpressionNoBF
1086 : ConditionalExpressionNoBF { $$ = $1; }
9b5527f0 1087 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
693d501b 1088 ;
63cd45c9
JF
1089/* }}} */
1090/* 11.14 Comma Operator {{{ */
36cd3cb9 1091Expression_
d35a3b07 1092 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
cf7d4c69 1093 | { $$ = NULL; }
1dbba6cc
JF
1094 ;
1095
693d501b 1096ExpressionNoIn_
d35a3b07 1097 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
693d501b
JF
1098 | { $$ = NULL; }
1099 ;
1100
36cd3cb9 1101ExpressionOpt
cf7d4c69 1102 : Expression { $$ = $1; }
691e4717 1103 | LexSetRegExp { $$ = NULL; }
1dbba6cc
JF
1104 ;
1105
693d501b
JF
1106ExpressionNoInOpt
1107 : ExpressionNoIn { $$ = $1; }
691e4717 1108 | LexSetRegExp { $$ = NULL; }
693d501b
JF
1109 ;
1110
36cd3cb9 1111Expression
d35a3b07 1112 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1dbba6cc
JF
1113 ;
1114
693d501b 1115ExpressionNoIn
d35a3b07 1116 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
693d501b
JF
1117 ;
1118
1119ExpressionNoBF
d35a3b07 1120 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
693d501b 1121 ;
63cd45c9 1122/* }}} */
693d501b 1123
63cd45c9 1124/* 12 Statements {{{ */
b10bd496 1125Statement_
36cd3cb9
JF
1126 : Block { $$ = $1; }
1127 | VariableStatement { $$ = $1; }
1128 | EmptyStatement { $$ = $1; }
1129 | ExpressionStatement { $$ = $1; }
cf7d4c69
JF
1130 | IfStatement { $$ = $1; }
1131 | IterationStatement { $$ = $1; }
36cd3cb9
JF
1132 | ContinueStatement { $$ = $1; }
1133 | BreakStatement { $$ = $1; }
1134 | ReturnStatement { $$ = $1; }
cf7d4c69
JF
1135 | WithStatement { $$ = $1; }
1136 | LabelledStatement { $$ = $1; }
36cd3cb9
JF
1137 | SwitchStatement { $$ = $1; }
1138 | ThrowStatement { $$ = $1; }
1139 | TryStatement { $$ = $1; }
1dbba6cc 1140 ;
b10bd496
JF
1141
1142Statement
691e4717 1143 : LexSetRegExp Statement_ { $$ = $2; }
b10bd496 1144 ;
63cd45c9
JF
1145/* }}} */
1146/* 12.1 Block {{{ */
cac61857
JF
1147Block_
1148 : "{" StatementListOpt "}" { $$ = $2; }
1149 ;
1150
36cd3cb9 1151Block
cac61857 1152 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1dbba6cc
JF
1153 ;
1154
693d501b 1155StatementList
cf7d4c69 1156 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
693d501b
JF
1157 ;
1158
1159StatementListOpt
1160 : StatementList { $$ = $1; }
691e4717 1161 | LexSetRegExp { $$ = NULL; }
1dbba6cc 1162 ;
63cd45c9
JF
1163/* }}} */
1164/* 12.2 Variable Statement {{{ */
36cd3cb9 1165VariableStatement
cac61857 1166 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1dbba6cc
JF
1167 ;
1168
36cd3cb9 1169VariableDeclarationList_
cf7d4c69
JF
1170 : "," VariableDeclarationList { $$ = $2; }
1171 | { $$ = NULL; }
1dbba6cc
JF
1172 ;
1173
693d501b
JF
1174VariableDeclarationListNoIn_
1175 : "," VariableDeclarationListNoIn { $$ = $2; }
1176 | { $$ = NULL; }
1177 ;
1178
36cd3cb9 1179VariableDeclarationList
b1ff2d78 1180 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1dbba6cc
JF
1181 ;
1182
693d501b
JF
1183VariableDeclarationListNoIn
1184 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1185 ;
1186
36cd3cb9
JF
1187VariableDeclaration
1188 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1dbba6cc
JF
1189 ;
1190
693d501b
JF
1191VariableDeclarationNoIn
1192 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1193 ;
1194
36cd3cb9 1195InitialiserOpt
cf7d4c69 1196 : Initialiser { $$ = $1; }
36cd3cb9 1197 | { $$ = NULL; }
1dbba6cc
JF
1198 ;
1199
693d501b
JF
1200InitialiserNoInOpt
1201 : InitialiserNoIn { $$ = $1; }
1202 | { $$ = NULL; }
1203 ;
1204
36cd3cb9
JF
1205Initialiser
1206 : "=" AssignmentExpression { $$ = $2; }
1dbba6cc
JF
1207 ;
1208
693d501b
JF
1209InitialiserNoIn
1210 : "=" AssignmentExpressionNoIn { $$ = $2; }
1211 ;
63cd45c9
JF
1212/* }}} */
1213/* 12.3 Empty Statement {{{ */
36cd3cb9 1214EmptyStatement
b1ff2d78 1215 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1dbba6cc 1216 ;
63cd45c9
JF
1217/* }}} */
1218/* 12.4 Expression Statement {{{ */
36cd3cb9 1219ExpressionStatement
693d501b 1220 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1dbba6cc 1221 ;
63cd45c9
JF
1222/* }}} */
1223/* 12.5 The if Statement {{{ */
36cd3cb9
JF
1224ElseStatementOpt
1225 : "else" Statement { $$ = $2; }
c3c20102 1226 | %prec "if" { $$ = NULL; }
1dbba6cc
JF
1227 ;
1228
36cd3cb9
JF
1229IfStatement
1230 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1dbba6cc 1231 ;
63cd45c9 1232/* }}} */
1dbba6cc 1233
63cd45c9 1234/* 12.6 Iteration Statements {{{ */
36cd3cb9
JF
1235IterationStatement
1236 : DoWhileStatement { $$ = $1; }
cf7d4c69
JF
1237 | WhileStatement { $$ = $1; }
1238 | ForStatement { $$ = $1; }
1239 | ForInStatement { $$ = $1; }
1dbba6cc 1240 ;
63cd45c9
JF
1241/* }}} */
1242/* 12.6.1 The do-while Statement {{{ */
36cd3cb9
JF
1243DoWhileStatement
1244 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1dbba6cc 1245 ;
63cd45c9
JF
1246/* }}} */
1247/* 12.6.2 The while Statement {{{ */
36cd3cb9
JF
1248WhileStatement
1249 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1dbba6cc 1250 ;
63cd45c9
JF
1251/* }}} */
1252/* 12.6.3 The for Statement {{{ */
36cd3cb9
JF
1253ForStatement
1254 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1dbba6cc
JF
1255 ;
1256
36cd3cb9 1257ForStatementInitialiser
693d501b 1258 : ExpressionNoInOpt { $$ = $1; }
691e4717 1259 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1dbba6cc 1260 ;
63cd45c9
JF
1261/* }}} */
1262/* 12.6.4 The for-in Statement {{{ */
36cd3cb9
JF
1263ForInStatement
1264 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1dbba6cc
JF
1265 ;
1266
36cd3cb9
JF
1267ForInStatementInitialiser
1268 : LeftHandSideExpression { $$ = $1; }
691e4717 1269 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1dbba6cc 1270 ;
63cd45c9 1271/* }}} */
1dbba6cc 1272
63cd45c9 1273/* 12.7 The continue Statement {{{ */
36cd3cb9
JF
1274ContinueStatement
1275 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1dbba6cc 1276 ;
63cd45c9
JF
1277/* }}} */
1278/* 12.8 The break Statement {{{ */
36cd3cb9
JF
1279BreakStatement
1280 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1dbba6cc 1281 ;
63cd45c9
JF
1282/* }}} */
1283/* 12.9 The return Statement {{{ */
36cd3cb9 1284ReturnStatement
c3c20102 1285 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1dbba6cc 1286 ;
63cd45c9
JF
1287/* }}} */
1288/* 12.10 The with Statement {{{ */
36cd3cb9
JF
1289WithStatement
1290 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1dbba6cc 1291 ;
63cd45c9 1292/* }}} */
1dbba6cc 1293
63cd45c9 1294/* 12.11 The switch Statement {{{ */
36cd3cb9
JF
1295SwitchStatement
1296 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1dbba6cc
JF
1297 ;
1298
1299CaseBlock
36cd3cb9 1300 : "{" CaseClausesOpt "}" { $$ = $2; }
1dbba6cc
JF
1301 ;
1302
36cd3cb9 1303CaseClausesOpt
cf7d4c69
JF
1304 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1305 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1306 | { $$ = NULL; }
1dbba6cc
JF
1307 ;
1308
36cd3cb9
JF
1309CaseClause
1310 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1dbba6cc
JF
1311 ;
1312
36cd3cb9
JF
1313DefaultClause
1314 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1dbba6cc 1315 ;
63cd45c9
JF
1316/* }}} */
1317/* 12.12 Labelled Statements {{{ */
36cd3cb9 1318LabelledStatement
3b52fd1a 1319 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1dbba6cc 1320 ;
63cd45c9
JF
1321/* }}} */
1322/* 12.13 The throw Statement {{{ */
36cd3cb9 1323ThrowStatement
37954781 1324 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1dbba6cc 1325 ;
63cd45c9
JF
1326/* }}} */
1327/* 12.14 The try Statement {{{ */
36cd3cb9 1328TryStatement
37954781 1329 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1dbba6cc
JF
1330 ;
1331
1332CatchOpt
37954781 1333 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
cf7d4c69 1334 | { $$ = NULL; }
1dbba6cc
JF
1335 ;
1336
1337FinallyOpt
b10bd496 1338 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
cf7d4c69 1339 | { $$ = NULL; }
1dbba6cc 1340 ;
63cd45c9 1341/* }}} */
1dbba6cc 1342
63cd45c9 1343/* 13 Function Definition {{{ */
36cd3cb9 1344FunctionDeclaration
fb98ac0c 1345 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1dbba6cc
JF
1346 ;
1347
36cd3cb9 1348FunctionExpression
691e4717 1349 : LexSetRegExp "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($3, $5, $8); }
1dbba6cc
JF
1350 ;
1351
1352FormalParameterList_
36cd3cb9 1353 : "," FormalParameterList { $$ = $2; }
cf7d4c69 1354 | { $$ = NULL; }
1dbba6cc
JF
1355 ;
1356
1357FormalParameterList
b09da87b 1358 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
cf7d4c69 1359 | { $$ = NULL; }
1dbba6cc
JF
1360 ;
1361
36cd3cb9
JF
1362FunctionBody
1363 : SourceElements { $$ = $1; }
1dbba6cc 1364 ;
63cd45c9
JF
1365/* }}} */
1366/* 14 Program {{{ */
1dbba6cc 1367Program
3b52fd1a 1368 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1dbba6cc
JF
1369 ;
1370
36cd3cb9
JF
1371SourceElements
1372 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
691e4717 1373 | LexSetRegExp { $$ = NULL; }
1dbba6cc
JF
1374 ;
1375
697d6fd2 1376SourceElement_
b10bd496 1377 : Statement_ { $$ = $1; }
36cd3cb9 1378 | FunctionDeclaration { $$ = $1; }
1dbba6cc 1379 ;
697d6fd2
JF
1380
1381SourceElement
691e4717 1382 : LexSetRegExp SourceElement_ { $$ = $2; }
697d6fd2 1383 ;
63cd45c9 1384/* }}} */
e5332278 1385
cbaa5f0f 1386@begin ObjectiveC
4de0686f 1387/* Cycript (Objective-C): @class Declaration {{{ */
b09da87b 1388ClassSuperOpt
697d6fd2 1389 /* XXX: why the hell did I choose MemberExpressionNoBF? */
691e4717 1390 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
b09da87b
JF
1391 | { $$ = NULL; }
1392 ;
1393
1394ClassFieldList
1395 : "{" "}" { $$ = NULL; }
1396 ;
1397
1398MessageScope
1399 : "+" { $$ = false; }
1400 | "-" { $$ = true; }
1401 ;
1402
1403TypeOpt
1404 : "(" Expression ")" { $$ = $2; }
1405 | { $$ = NULL; }
1406 ;
1407
1408MessageParameter
75b0a457 1409 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
b09da87b
JF
1410 ;
1411
1412MessageParameterListOpt
1413 : MessageParameterList { $$ = $1; }
1414 | { $$ = NULL; }
1415 ;
1416
1417MessageParameterList
1418 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1419 ;
1420
1421MessageParameters
1422 : MessageParameterList { $$ = $1; }
75b0a457 1423 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
b09da87b
JF
1424 ;
1425
1426ClassMessageDeclaration
75b0a457 1427 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
b09da87b
JF
1428 ;
1429
1430ClassMessageDeclarationListOpt
4e8c99fb 1431 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
b09da87b
JF
1432 | { $$ = NULL; }
1433 ;
1434
e5bc40db
JF
1435ClassName
1436 : Identifier { $$ = $1; }
1437 | "(" AssignmentExpression ")" { $$ = $2; }
1438 ;
1439
367eebb1
JF
1440ClassNameOpt
1441 : ClassName { $$ = $1; }
1442 | { $$ = NULL; }
b09da87b
JF
1443 ;
1444
fb98ac0c
JF
1445ClassExpression
1446 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); }
1447 ;
1448
1449ClassStatement
1450 : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); }
367eebb1
JF
1451 ;
1452
1453CategoryStatement
75b0a457 1454 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
367eebb1
JF
1455 ;
1456
697d6fd2 1457PrimaryExpression_
fb98ac0c 1458 : ClassExpression { $$ = $1; }
367eebb1
JF
1459 ;
1460
b10bd496 1461Statement_
fb98ac0c 1462 : ClassStatement { $$ = $1; }
365abb0a 1463 | CategoryStatement { $$ = $1; }
b09da87b 1464 ;
cac61857 1465/* }}} */
4de0686f 1466/* Cycript (Objective-C): Send Message {{{ */
693d501b
JF
1467VariadicCall
1468 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1469 | { $$ = NULL; }
1470 ;
1471
1472SelectorCall_
1473 : SelectorCall { $$ = $1; }
1474 | VariadicCall { $$ = $1; }
1475 ;
1476
1477SelectorCall
1478 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1479 ;
1480
1481SelectorList
1482 : SelectorCall { $$ = $1; }
1483 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1484 ;
1485
1486MessageExpression
cacd1a88 1487 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
691e4717 1488 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
693d501b
JF
1489 ;
1490
e7ed5354
JF
1491SelectorExpressionOpt
1492 : SelectorExpression_ { $$ = $1; }
1493 | { $$ = NULL; }
1494 ;
1495
1496SelectorExpression_
62014ea9 1497 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
e7ed5354
JF
1498 ;
1499
1500SelectorExpression
1501 : SelectorExpression_ { $$ = $1; }
62014ea9 1502 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
e7ed5354
JF
1503 ;
1504
697d6fd2 1505PrimaryExpressionNoBF_
693d501b 1506 : MessageExpression { $$ = $1; }
75b0a457 1507 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
693d501b
JF
1508 ;
1509/* }}} */
4de0686f
JF
1510@end
1511
1512@begin C
1513/* Cycript (C): Pointer Indirection/Addressing {{{ */
697d6fd2 1514UnaryAssigneeExpression
691e4717 1515 : "^" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); }
693d501b
JF
1516 ;
1517
1518UnaryExpression_
1519 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1520 ;
1521
9b5527f0 1522MemberAccess
3b52fd1a
JF
1523 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1524 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
9b5527f0 1525 ;
cac61857 1526/* }}} */
4de0686f
JF
1527@end
1528
cb02f8ae 1529@begin E4X
691e4717
JF
1530/* Lexer State {{{ */
1531LexPushRegExp
1532 : { driver.PushCondition(CYDriver::RegExpCondition); }
1533 ;
1534
1535LexPushXMLContent
1536 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1537 ;
1538
1539LexPushXMLTag
1540 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1541 ;
1542
1543LexPop
1544 : { driver.PopCondition(); }
1545 ;
1546
1547LexSetXMLContent
1548 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1549 ;
1550
1551LexSetXMLTag
1552 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1553 ;
1554/* }}} */
1555
1556XMLWhitespaceOpt
1557 : XMLWhitespace
1558 |
1559 ;
1560
1561/* 8.1 Context Keywords {{{ */
1562Identifier
1563 : "namespace" { $$ = $1; }
1564 | "xml" { $$ = $1; }
1565 ;
1566/* }}} */
cb02f8ae
JF
1567/* 8.3 XML Initialiser Input Elements {{{ */
1568XMLMarkup
691e4717
JF
1569 : XMLComment { $$ = $1; }
1570 | XMLCDATA { $$ = $1; }
1571 | XMLPI { $$ = $1; }
cb02f8ae
JF
1572 ;
1573/* }}} */
1574/* 11.1 Primary Expressions {{{ */
697d6fd2 1575PrimaryExpressionNoBF_
691e4717
JF
1576 : PropertyIdentifier { $$ = $1; }
1577 | XMLInitialiser { $$ = $1; }
1578 | XMLListInitialiser { $$ = $1; }
cb02f8ae
JF
1579 ;
1580
1581PropertyIdentifier
691e4717
JF
1582 : AttributeIdentifier { $$ = $1; }
1583 | QualifiedIdentifier { $$ = $1; }
1584 | WildcardIdentifier { $$ = $1; }
cb02f8ae
JF
1585 ;
1586/* }}} */
1587/* 11.1.1 Attribute Identifiers {{{ */
1588AttributeIdentifier
691e4717
JF
1589 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1590 ;
1591
1592PropertySelector_
1593 : PropertySelector
1594 | "[" Expression "]"
cb02f8ae
JF
1595 ;
1596
1597PropertySelector
691e4717
JF
1598 : Word { $$ = $1; }
1599 | WildcardIdentifier { $$ = $1; }
cb02f8ae
JF
1600 ;
1601/* }}} */
1602/* 11.1.2 Qualified Identifiers {{{ */
691e4717
JF
1603QualifiedIdentifier_
1604 : PropertySelector_ { $$ = $1; }
1605 | QualifiedIdentifier { $$ = $1; }
1606 ;
1607
cb02f8ae 1608QualifiedIdentifier
691e4717 1609 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQName($1, $3); }
cb02f8ae
JF
1610 ;
1611/* }}} */
1612/* 11.1.3 Wildcard Identifiers {{{ */
1613WildcardIdentifier
691e4717 1614 : "*" { $$ = new(driver.pool_) CYWildcard(); }
cb02f8ae
JF
1615 ;
1616/* }}} */
1617/* 11.1.4 XML Initialiser {{{ */
1618XMLInitialiser
691e4717
JF
1619 : XMLMarkup { $$ = $1; }
1620 | XMLElement { $$ = $1; }
cb02f8ae
JF
1621 ;
1622
1623XMLElement
691e4717
JF
1624 : "<" XMLTagContent_ "/>" LexPop
1625 | "<" XMLTagContent_ ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1626 ;
1627
1628XMLTagContent_
1629 : LexPushXMLTag XMLTagContent XMLWhitespaceOpt
cb02f8ae
JF
1630 ;
1631
1632XMLTagContent
1633 : XMLTagName XMLAttributesOpt
1634 ;
1635
691e4717
JF
1636XMLExpression
1637 : "{" LexPushRegExp Expression "}" LexPop
1638 ;
1639
cb02f8ae 1640XMLTagName
691e4717 1641 : XMLExpression
cb02f8ae
JF
1642 | XMLName
1643 ;
1644
1645XMLAttributes
691e4717 1646 : XMLWhitespace XMLExpression
cb02f8ae
JF
1647 | XMLAttributeOpt XMLAttributes
1648 ;
1649
1650XMLAttributesOpt
1651 : XMLAttributes
1652 |
1653 ;
1654
691e4717
JF
1655XMLAttributeValue_
1656 : XMLExpression
1657 | XMLAttributeValue
1658 ;
1659
cb02f8ae 1660XMLAttribute
691e4717 1661 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
cb02f8ae
JF
1662 ;
1663
1664XMLAttributeOpt
1665 : XMLAttribute
1666 |
1667 ;
1668
1669XMLElementContent
691e4717 1670 : XMLExpression XMLElementContentOpt
cb02f8ae
JF
1671 | XMLMarkup XMLElementContentOpt
1672 | XMLText XMLElementContentOpt
1673 | XMLElement XMLElementContentOpt
1674 ;
1675
1676XMLElementContentOpt
1677 : XMLElementContent
1678 |
1679 ;
1680/* }}} */
1681/* 11.1.5 XMLList Initialiser {{{ */
1682XMLListInitialiser
691e4717
JF
1683 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1684 ;
1685/* }}} */
1686/* 11.2 Left-Hand-Side Expressions {{{ */
1687PropertyIdentifier_
1688 : Word { $$ = $1; }
1689 | PropertyIdentifier { $$ = $1; }
1690 ;
1691
1692MemberAccess
1693 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1694 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1695 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1696 ;
1697/* }}} */
1698/* 12.1 The default xml namespace Statement {{{ */
1699DefaultXMLNamespaceStatement
1700 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1701 ;
1702
1703Statement_
1704 : DefaultXMLNamespaceStatement { $$ = $1; }
cb02f8ae
JF
1705 ;
1706/* }}} */
1707@end
1708
cac61857
JF
1709/* ECMAScript5: Object Literal Trailing Comma {{{ */
1710PropertyNameAndValueList_
1711 : "," { $$ = NULL; }
1712 ;
1713/* }}} */
1714/* JavaScript 1.7: Array Comprehensions {{{ */
367eebb1 1715IfComprehension
75b0a457 1716 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
367eebb1
JF
1717 ;
1718
1719ForComprehension
75b0a457
JF
1720 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1721 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
367eebb1
JF
1722 ;
1723
1724ComprehensionListOpt
75b0a457
JF
1725 : ComprehensionList { $$ = $1; }
1726 | IfComprehension { $$ = $1; }
1727 | { $$ = NULL; }
367eebb1
JF
1728 ;
1729
1730ComprehensionList
75b0a457 1731 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
367eebb1
JF
1732 ;
1733
697d6fd2 1734PrimaryExpressionNoBF_
75b0a457 1735 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
367eebb1 1736 ;
cac61857
JF
1737/* }}} */
1738/* JavaScript 1.7: for each {{{ */
1739ForInStatement
1740 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1741 ;
1742/* }}} */
b10bd496 1743/* JavaScript 1.7: let Statements {{{ *//*
cac61857
JF
1744LetStatement
1745 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1746 ;
1747
697d6fd2 1748Statement_
cac61857
JF
1749 : LetStatement
1750 ;
534fb6da 1751*//* }}} */
b10bd496
JF
1752/* JavaScript FTW: Function Statements {{{ */
1753Statement
691e4717 1754 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }
b10bd496
JF
1755 ;
1756/* }}} */
367eebb1 1757
e5332278 1758%%