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