]> git.saurik.com Git - cycript.git/blame - Cycript.yy.in
Add a debug.sh script that configures with -g3 -O0.
[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
55fc1817 414%type <expression_> RelationalExpression
cf7d4c69 415%type <statement_> ReturnStatement
6c093cce 416%type <rubyProc_> RubyProcExpression
6c093cce 417%type <functionParameter_> RubyProcParameterList_
55fc1817 418%type <functionParameter_> RubyProcParameterList
d7205a63 419%type <functionParameter_> RubyProcParameters
6c093cce 420%type <functionParameter_> RubyProcParametersOpt
cf7d4c69 421%type <expression_> ShiftExpression
c8a0500b 422%type <declaration_> SingleNameBinding
3ea7eed0 423%type <statement_> Statement__
b10bd496 424%type <statement_> Statement_
55fc1817 425%type <statement_> Statement
693d501b 426%type <statement_> StatementList
cf7d4c69 427%type <statement_> StatementListOpt
c8a0500b 428%type <statement_> StatementListItem
cf7d4c69
JF
429%type <statement_> SwitchStatement
430%type <statement_> ThrowStatement
431%type <statement_> TryStatement
693d501b 432%type <expression_> UnaryExpression_
55fc1817 433%type <expression_> UnaryExpression
cf7d4c69 434%type <declaration_> VariableDeclaration
cf7d4c69 435%type <declarations_> VariableDeclarationList_
55fc1817 436%type <declarations_> VariableDeclarationList
cf7d4c69 437%type <statement_> VariableStatement
cf7d4c69
JF
438%type <statement_> WhileStatement
439%type <statement_> WithStatement
cf7d4c69 440
cbaa5f0f 441@begin ObjectiveC
328ad766
JF
442%type <statement_> CategoryStatement
443%type <expression_> ClassExpression
444%type <statement_> ClassStatement
445%type <expression_> ClassSuperOpt
446%type <field_> ClassFieldList
447%type <message_> ClassMessageDeclaration
448%type <message_> ClassMessageDeclarationListOpt
449%type <className_> ClassName
450%type <className_> ClassNameOpt
64b8d29f
JF
451%type <protocol_> ClassProtocolListOpt
452%type <protocol_> ClassProtocols
453%type <protocol_> ClassProtocolsOpt
693d501b 454%type <expression_> MessageExpression
328ad766
JF
455%type <messageParameter_> MessageParameter
456%type <messageParameter_> MessageParameters
457%type <messageParameter_> MessageParameterList
458%type <messageParameter_> MessageParameterListOpt
459%type <bool_> MessageScope
693d501b 460%type <argument_> SelectorCall_
55fc1817 461%type <argument_> SelectorCall
328ad766 462%type <selector_> SelectorExpression_
55fc1817 463%type <selector_> SelectorExpression
328ad766 464%type <selector_> SelectorExpressionOpt
693d501b 465%type <argument_> SelectorList
7e5391fd 466%type <word_> SelectorWordOpt
328ad766 467%type <expression_> TypeOpt
693d501b 468%type <argument_> VariadicCall
328ad766
JF
469%type <word_> Word
470%type <word_> WordOpt
471@end
693d501b 472
691e4717 473@begin E4X
b92ceddb 474%type <propertyIdentifier_> PropertyIdentifier_
b92ceddb 475%type <selector_> PropertySelector_
55fc1817 476%type <selector_> PropertySelector
691e4717 477%type <identifier_> QualifiedIdentifier_
55fc1817 478%type <identifier_> QualifiedIdentifier
691e4717
JF
479%type <identifier_> WildcardIdentifier
480%type <identifier_> XMLComment
481%type <identifier_> XMLCDATA
482%type <identifier_> XMLElement
483%type <identifier_> XMLElementContent
484%type <identifier_> XMLMarkup
485%type <identifier_> XMLPI
486
487%type <attribute_> AttributeIdentifier
b92ceddb 488/* XXX: %type <statement_> DefaultXMLNamespaceStatement */
691e4717
JF
489%type <expression_> PropertyIdentifier
490%type <expression_> XMLListInitialiser
491%type <expression_> XMLInitialiser
492@end
493
3ea7eed0
JF
494%nonassoc ""
495%left "++" "--"
b92ceddb
JF
496
497%nonassoc "if"
498%nonassoc "else"
499
693d501b 500%start Program
e5332278 501
693d501b 502%%
c3c20102 503
691e4717 504/* Lexer State {{{ */
3ea7eed0
JF
505LexPushInOn
506 : { driver.in_.push(true); }
507 ;
508
509LexPushInOff
510 : { driver.in_.push(false); }
511 ;
512
513LexPopIn
514 : { driver.in_.pop(); }
515 ;
516
691e4717
JF
517LexSetRegExp
518 : { driver.SetCondition(CYDriver::RegExpCondition); }
519 ;
3ea7eed0
JF
520
521LexSetStatement
066da9f6
JF
522 : { switch (yychar) {
523 case token::Function:
524 yychar = token::Function_;
525 break;
526
527 case token::OpenBrace:
528 case token::OpenBrace_:
529 yychar = token::OpenBrace__;
530 break;
531 } }
3ea7eed0 532 ;
691e4717
JF
533/* }}} */
534
3ea7eed0 535BRACE
6c093cce
JF
536 : "{"
537 | "\n{"
538 ;
539
b10bd496
JF
540StrictSemi
541 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
542 ;
543
544Terminator_
c3c20102 545 : ";"
b10bd496
JF
546 | "\n" StrictSemi
547 ;
548
55fc1817 549Terminator
b10bd496 550 : Terminator_
9ab1d5c5 551 | error { if (yychar != 0 && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
c3c20102
JF
552 ;
553
55fc1817 554TerminatorOpt
b10bd496 555 : Terminator_
55fc1817 556 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
c3c20102
JF
557 ;
558
cac61857 559/*CommaOpt
693d501b
JF
560 : ","
561 |
cac61857 562 ;*/
693d501b 563
cbaa5f0f 564@begin ObjectiveC
c3c20102 565NewLineOpt
693d501b 566 : "\n"
c3c20102
JF
567 |
568 ;
1dbba6cc 569
36cd3cb9 570Word
cf7d4c69 571 : Identifier { $$ = $1; }
c3c20102 572 | "break" NewLineOpt { $$ = $1; }
cf7d4c69
JF
573 | "case" { $$ = $1; }
574 | "catch" { $$ = $1; }
d35a3b07
JF
575 | "class" { $$ = $1; }
576 | "const" { $$ = $1; }
c3c20102 577 | "continue" NewLineOpt { $$ = $1; }
d35a3b07 578 | "debugger" { $$ = $1; }
cf7d4c69
JF
579 | "default" { $$ = $1; }
580 | "delete" { $$ = $1; }
581 | "do" { $$ = $1; }
582 | "else" { $$ = $1; }
d35a3b07
JF
583 | "enum" { $$ = $1; }
584 | "export" { $$ = $1; }
585 | "extends" { $$ = $1; }
cf7d4c69
JF
586 | "false" { $$ = $1; }
587 | "finally" { $$ = $1; }
561ac418 588 /* XXX: | "for" { $$ = $1; } */
cf7d4c69
JF
589 | "function" { $$ = $1; }
590 | "if" { $$ = $1; }
d35a3b07 591 | "import" { $$ = $1; }
693d501b
JF
592 /* XXX: | "in" { $$ = $1; } */
593 /* XXX: | "instanceof" { $$ = $1; } */
cf7d4c69
JF
594 | "new" { $$ = $1; }
595 | "null" { $$ = $1; }
c3c20102 596 | "return" NewLineOpt { $$ = $1; }
d35a3b07 597 | "super" { $$ = $1; }
cf7d4c69
JF
598 | "switch" { $$ = $1; }
599 | "this" { $$ = $1; }
c3c20102 600 | "throw" NewLineOpt { $$ = $1; }
cf7d4c69
JF
601 | "true" { $$ = $1; }
602 | "try" { $$ = $1; }
603 | "typeof" { $$ = $1; }
604 | "var" { $$ = $1; }
605 | "void" { $$ = $1; }
606 | "while" { $$ = $1; }
607 | "with" { $$ = $1; }
2bf24581 608 ;
f2f0d1d1 609
55fc1817
JF
610WordOpt
611 : Word { $$ = $1; }
612 | { $$ = NULL; }
613 ;
614
3ea7eed0 615PrimaryExpression
f2f0d1d1
JF
616 : "@" LiteralNoRE { $$ = CYNew CYBox($2); }
617 | "@" ArrayLiteral { $$ = CYNew CYBox($2); }
618 | "@" ObjectLiteral { $$ = CYNew CYBox($2); }
3ea7eed0 619 | "@" Parenthetical { $$ = CYNew CYBox($2); }
f2f0d1d1 620 ;
328ad766 621@end
2bf24581 622
75b0a457
JF
623Identifier
624 : Identifier_ { $$ = $1; }
534fb6da
JF
625
626 | "implements" { $$ = $1; }
627 | "interface" { $$ = $1; }
628 | "package" { $$ = $1; }
629 | "private" { $$ = $1; }
630 | "protected" { $$ = $1; }
631 | "public" { $$ = $1; }
632 | "static" { $$ = $1; }
633
634 | "abstract" { $$ = $1; }
635 | "boolean" { $$ = $1; }
636 | "byte" { $$ = $1; }
637 | "char" { $$ = $1; }
638 | "double" { $$ = $1; }
639 | "final" { $$ = $1; }
640 | "float" { $$ = $1; }
641 | "goto" { $$ = $1; }
642 | "int" { $$ = $1; }
643 | "long" { $$ = $1; }
644 | "native" { $$ = $1; }
645 | "short" { $$ = $1; }
646 | "synchronized" { $$ = $1; }
647 | "throws" { $$ = $1; }
648 | "transient" { $$ = $1; }
649 | "volatile" { $$ = $1; }
650
c8a0500b 651 // XXX: is this allowed?! | "let" { $$ = $1; }
534fb6da
JF
652 | "yield" { $$ = $1; }
653
654 | "each" { $$ = $1; }
75b0a457
JF
655 ;
656
36cd3cb9 657IdentifierOpt
cf7d4c69
JF
658 : Identifier { $$ = $1; }
659 | { $$ = NULL; }
1dbba6cc
JF
660 ;
661
561ac418 662LiteralNoRE
cf7d4c69
JF
663 : NullLiteral { $$ = $1; }
664 | BooleanLiteral { $$ = $1; }
665 | NumericLiteral { $$ = $1; }
666 | StringLiteral { $$ = $1; }
561ac418
JF
667 ;
668
561ac418
JF
669Literal
670 : LiteralNoRE { $$ = $1; }
3ea7eed0 671 | RegularExpressionLiteral { $$ = $1; }
1dbba6cc
JF
672 ;
673
36cd3cb9 674NullLiteral
cf7d4c69 675 : "null" { $$ = $1; }
1dbba6cc
JF
676 ;
677
36cd3cb9 678BooleanLiteral
cf7d4c69
JF
679 : "true" { $$ = $1; }
680 | "false" { $$ = $1; }
1dbba6cc
JF
681 ;
682
1dbba6cc 683/* 11.1 Primary Expressions {{{ */
3ea7eed0
JF
684Parenthetical
685 : "(" LexPushInOff Expression LexPopIn ")" { $$ = $3; }
561ac418
JF
686 ;
687
3ea7eed0 688PrimaryExpression
cf7d4c69 689 : "this" { $$ = $1; }
2eb8215d 690 | Identifier { $$ = CYNew CYVariable($1); }
cf7d4c69
JF
691 | Literal { $$ = $1; }
692 | ArrayLiteral { $$ = $1; }
3ea7eed0
JF
693 | ObjectLiteral { $$ = $1; }
694 | FunctionExpression { $$ = $1; }
695 | Parenthetical { $$ = $1; }
696 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
1dbba6cc
JF
697 ;
698/* }}} */
3ea7eed0 699/* 11.1.4.1 Array Initialiser {{{ */
36cd3cb9 700ArrayLiteral
3ea7eed0 701 : "[" LexPushInOff ElementListOpt LexPopIn "]" { $$ = CYNew CYArray($3); }
1dbba6cc
JF
702 ;
703
36cd3cb9 704Element
cf7d4c69 705 : AssignmentExpression { $$ = $1; }
5befe15e
JF
706 ;
707
708ElementOpt
709 : Element { $$ = $1; }
691e4717 710 | LexSetRegExp { $$ = NULL; }
1dbba6cc
JF
711 ;
712
36cd3cb9 713ElementList
2eb8215d
JF
714 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
715 | Element { $$ = CYNew CYElement($1, NULL); }
1dbba6cc 716 ;
55fc1817
JF
717
718ElementListOpt
719 : ElementList { $$ = $1; }
720 | LexSetRegExp { $$ = NULL; }
721 ;
1dbba6cc
JF
722/* }}} */
723/* 11.1.5 Object Initialiser {{{ */
36cd3cb9 724ObjectLiteral
3ea7eed0 725 : BRACE LexPushInOff PropertyNameAndValueListOpt LexPopIn "}" { $$ = CYNew CYObject($3); }
1dbba6cc
JF
726 ;
727
36cd3cb9 728PropertyNameAndValueList_
cf7d4c69 729 : "," PropertyNameAndValueList { $$ = $2; }
cac61857 730 | { $$ = NULL; }
1dbba6cc
JF
731 ;
732
55fc1817
JF
733PropertyNameAndValueList
734 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = CYNew CYProperty($1, $3, $4); }
735 ;
736
36cd3cb9 737PropertyNameAndValueListOpt
cf7d4c69 738 : PropertyNameAndValueList { $$ = $1; }
36cd3cb9 739 | { $$ = NULL; }
1dbba6cc
JF
740 ;
741
b92ceddb 742PropertyName_
36cd3cb9
JF
743 : Identifier { $$ = $1; }
744 | StringLiteral { $$ = $1; }
745 | NumericLiteral { $$ = $1; }
1dbba6cc 746 ;
b92ceddb
JF
747
748PropertyName
749 : LexSetRegExp PropertyName_ { $$ = $2; }
750 ;
1dbba6cc
JF
751/* }}} */
752
63cd45c9 753/* 11.2 Left-Hand-Side Expressions {{{ */
9b5527f0 754MemberAccess
3ea7eed0 755 : "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYDirectMember(NULL, $3); }
2eb8215d 756 | "." Identifier { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
7e5391fd 757 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
9b5527f0
JF
758 ;
759
55fc1817 760MemberExpression_
3ea7eed0
JF
761 : MemberExpression { $$ = $1; }
762 //| "super" { $$ = $1; }
55fc1817
JF
763 ;
764
36cd3cb9 765MemberExpression
3ea7eed0
JF
766 : LexSetRegExp PrimaryExpression { $$ = $2; }
767 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
768 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1dbba6cc
JF
769 ;
770
36cd3cb9 771NewExpression
cf7d4c69 772 : MemberExpression { $$ = $1; }
3ea7eed0 773 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1dbba6cc
JF
774 ;
775
3ea7eed0
JF
776CallExpression_
777 : MemberExpression_
778 | CallExpression
b1589845
JF
779 ;
780
36cd3cb9 781CallExpression
3ea7eed0 782 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
7e5391fd 783 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1dbba6cc
JF
784 ;
785
3ea7eed0
JF
786Arguments
787 : "(" LexPushInOff ArgumentListOpt LexPopIn ")" { $$ = $3; }
b1589845
JF
788 ;
789
36cd3cb9 790ArgumentList_
cf7d4c69
JF
791 : "," ArgumentList { $$ = $2; }
792 | { $$ = NULL; }
1dbba6cc
JF
793 ;
794
55fc1817
JF
795ArgumentList
796 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
797 ;
798
36cd3cb9 799ArgumentListOpt
cf7d4c69 800 : ArgumentList { $$ = $1; }
691e4717 801 | LexSetRegExp { $$ = NULL; }
1dbba6cc
JF
802 ;
803
36cd3cb9 804LeftHandSideExpression
cf7d4c69
JF
805 : NewExpression { $$ = $1; }
806 | CallExpression { $$ = $1; }
693d501b 807 ;
63cd45c9
JF
808/* }}} */
809/* 11.3 Postfix Expressions {{{ */
36cd3cb9 810PostfixExpression
3ea7eed0 811 : %prec "" LeftHandSideExpression { $$ = $1; }
2eb8215d
JF
812 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
813 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
1dbba6cc 814 ;
63cd45c9
JF
815/* }}} */
816/* 11.4 Unary Operators {{{ */
693d501b 817UnaryExpression_
2eb8215d
JF
818 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
819 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
820 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
821 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
822 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
823 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
824 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
825 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
826 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
827 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
828 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
693d501b
JF
829 ;
830
831UnaryExpression
832 : PostfixExpression { $$ = $1; }
691e4717 833 | LexSetRegExp UnaryExpression_ { $$ = $2; }
693d501b 834 ;
63cd45c9
JF
835/* }}} */
836/* 11.5 Multiplicative Operators {{{ */
36cd3cb9 837MultiplicativeExpression
cf7d4c69 838 : UnaryExpression { $$ = $1; }
2eb8215d
JF
839 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
840 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
841 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1dbba6cc 842 ;
63cd45c9
JF
843/* }}} */
844/* 11.6 Additive Operators {{{ */
36cd3cb9 845AdditiveExpression
cf7d4c69 846 : MultiplicativeExpression { $$ = $1; }
2eb8215d
JF
847 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
848 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1dbba6cc 849 ;
63cd45c9
JF
850/* }}} */
851/* 11.7 Bitwise Shift Operators {{{ */
36cd3cb9 852ShiftExpression
cf7d4c69 853 : AdditiveExpression { $$ = $1; }
2eb8215d
JF
854 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
855 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
856 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1dbba6cc 857 ;
63cd45c9
JF
858/* }}} */
859/* 11.8 Relational Operators {{{ */
3ea7eed0 860RelationalExpression
05089169
JF
861 : ShiftExpression { $$ = $1; }
862 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
863 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
864 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
865 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
866 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
867 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
693d501b 868 ;
63cd45c9
JF
869/* }}} */
870/* 11.9 Equality Operators {{{ */
36cd3cb9 871EqualityExpression
cf7d4c69 872 : RelationalExpression { $$ = $1; }
2eb8215d
JF
873 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
874 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
875 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
876 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1dbba6cc 877 ;
63cd45c9
JF
878/* }}} */
879/* 11.10 Binary Bitwise Operators {{{ */
36cd3cb9 880BitwiseANDExpression
cf7d4c69 881 : EqualityExpression { $$ = $1; }
2eb8215d 882 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1dbba6cc
JF
883 ;
884
36cd3cb9 885BitwiseXORExpression
cf7d4c69 886 : BitwiseANDExpression { $$ = $1; }
2eb8215d 887 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1dbba6cc
JF
888 ;
889
36cd3cb9 890BitwiseORExpression
cf7d4c69 891 : BitwiseXORExpression { $$ = $1; }
2eb8215d 892 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1dbba6cc 893 ;
63cd45c9
JF
894/* }}} */
895/* 11.11 Binary Logical Operators {{{ */
36cd3cb9 896LogicalANDExpression
cf7d4c69 897 : BitwiseORExpression { $$ = $1; }
2eb8215d 898 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1dbba6cc
JF
899 ;
900
36cd3cb9 901LogicalORExpression
cf7d4c69 902 : LogicalANDExpression { $$ = $1; }
2eb8215d 903 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1dbba6cc 904 ;
63cd45c9
JF
905/* }}} */
906/* 11.12 Conditional Operator ( ? : ) {{{ */
36cd3cb9 907ConditionalExpression
cf7d4c69 908 : LogicalORExpression { $$ = $1; }
3ea7eed0 909 | LogicalORExpression "?" LexPushInOff AssignmentExpression LexPopIn ":" AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
693d501b 910 ;
63cd45c9
JF
911/* }}} */
912/* 11.13 Assignment Operators {{{ */
36cd3cb9 913AssignmentExpression
cf7d4c69 914 : ConditionalExpression { $$ = $1; }
005a0939
JF
915 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
916 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
917 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
918 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
919 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
920 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
921 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
922 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
923 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
924 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
925 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
926 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
693d501b 927 ;
63cd45c9
JF
928/* }}} */
929/* 11.14 Comma Operator {{{ */
36cd3cb9 930Expression_
2eb8215d 931 : "," Expression { $$ = CYNew CYCompound($2); }
cf7d4c69 932 | { $$ = NULL; }
1dbba6cc
JF
933 ;
934
55fc1817
JF
935Expression
936 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
693d501b
JF
937 ;
938
36cd3cb9 939ExpressionOpt
cf7d4c69 940 : Expression { $$ = $1; }
691e4717 941 | LexSetRegExp { $$ = NULL; }
1dbba6cc 942 ;
63cd45c9 943/* }}} */
693d501b 944
63cd45c9 945/* 12 Statements {{{ */
3ea7eed0 946Statement__
36cd3cb9
JF
947 : Block { $$ = $1; }
948 | VariableStatement { $$ = $1; }
949 | EmptyStatement { $$ = $1; }
cf7d4c69 950 | IfStatement { $$ = $1; }
c8a0500b 951 | BreakableStatement { $$ = $1; }
36cd3cb9
JF
952 | ContinueStatement { $$ = $1; }
953 | BreakStatement { $$ = $1; }
954 | ReturnStatement { $$ = $1; }
cf7d4c69
JF
955 | WithStatement { $$ = $1; }
956 | LabelledStatement { $$ = $1; }
36cd3cb9
JF
957 | ThrowStatement { $$ = $1; }
958 | TryStatement { $$ = $1; }
c8a0500b 959 | DebuggerStatement { $$ = $1; }
1dbba6cc 960 ;
b10bd496 961
3ea7eed0
JF
962Statement_
963 : LexSetRegExp Statement__ { $$ = $2; }
964 | ExpressionStatement { $$ = $1; }
965 ;
966
b10bd496 967Statement
3ea7eed0 968 : LexSetStatement Statement_ { $$ = $2; }
b10bd496 969 ;
c8a0500b 970
3ea7eed0 971Declaration__
c8a0500b
JF
972 : FunctionDeclaration { $$ = $1; }
973 | LexicalDeclaration { $$ = $1; }
974 ;
975
3ea7eed0
JF
976Declaration_
977 : LexSetRegExp Declaration__ { $$ = $2; }
978 ;
979
980Declaration
981 : LexSetStatement Declaration_ { $$ = $2; }
982 ;
983
c8a0500b
JF
984BreakableStatement
985 : IterationStatement { $$ = $1; }
986 | SwitchStatement { $$ = $1; }
987 ;
63cd45c9
JF
988/* }}} */
989/* 12.1 Block {{{ */
cac61857 990Block_
3ea7eed0 991 : BRACE StatementListOpt "}" { $$ = $2; }
cac61857
JF
992 ;
993
36cd3cb9 994Block
3ea7eed0 995 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1dbba6cc
JF
996 ;
997
693d501b 998StatementList
c8a0500b 999 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
693d501b
JF
1000 ;
1001
1002StatementListOpt
1003 : StatementList { $$ = $1; }
691e4717 1004 | LexSetRegExp { $$ = NULL; }
1dbba6cc 1005 ;
c8a0500b
JF
1006
1007StatementListItem
1008 : Statement { $$ = $1; }
3ea7eed0 1009 | Declaration { $$ = $1; }
c8a0500b
JF
1010 ;
1011/* }}} */
1012/* 12.2 Declarations {{{ */
1013BindingIdentifier
1014 : Identifier { $$ = $1; }
1015 ;
1016
1017// XXX: BindingPattern
1018/* }}} */
1019/* 12.2.1 Let and Const Declarations {{{ */
1020LexicalDeclaration
1021 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1022 ;
1023
1024LetOrConst
1025 : "let"
1026 | "const"
1027 ;
63cd45c9 1028/* }}} */
c8a0500b 1029/* 12.2.2 Variable Statement {{{ */
36cd3cb9 1030VariableStatement
2eb8215d 1031 : "var" VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1dbba6cc
JF
1032 ;
1033
36cd3cb9 1034VariableDeclarationList_
cf7d4c69
JF
1035 : "," VariableDeclarationList { $$ = $2; }
1036 | { $$ = NULL; }
1dbba6cc
JF
1037 ;
1038
55fc1817
JF
1039VariableDeclarationList
1040 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1041 ;
1042
36cd3cb9 1043VariableDeclaration
c8a0500b
JF
1044 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1045 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1dbba6cc
JF
1046 ;
1047
55fc1817
JF
1048Initialiser
1049 : "=" AssignmentExpression { $$ = $2; }
1050 ;
1051
36cd3cb9 1052InitialiserOpt
cf7d4c69 1053 : Initialiser { $$ = $1; }
36cd3cb9 1054 | { $$ = NULL; }
1dbba6cc 1055 ;
63cd45c9 1056/* }}} */
c8a0500b
JF
1057/* 12.2.4 Destructuring Binding Patterns {{{ */
1058// XXX: *
1059
1060BindingElement
1061 : SingleNameBinding { $$ = $1; }
1062 ;
1063
1064SingleNameBinding
1065 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1066 ;
1067/* }}} */
63cd45c9 1068/* 12.3 Empty Statement {{{ */
36cd3cb9 1069EmptyStatement
2eb8215d 1070 : ";" { $$ = CYNew CYEmpty(); }
1dbba6cc 1071 ;
63cd45c9
JF
1072/* }}} */
1073/* 12.4 Expression Statement {{{ */
36cd3cb9 1074ExpressionStatement
3ea7eed0 1075 : Expression Terminator { $$ = CYNew CYExpress($1); }
1dbba6cc 1076 ;
63cd45c9
JF
1077/* }}} */
1078/* 12.5 The if Statement {{{ */
36cd3cb9
JF
1079ElseStatementOpt
1080 : "else" Statement { $$ = $2; }
c3c20102 1081 | %prec "if" { $$ = NULL; }
1dbba6cc
JF
1082 ;
1083
36cd3cb9 1084IfStatement
2eb8215d 1085 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1dbba6cc 1086 ;
63cd45c9 1087/* }}} */
1dbba6cc 1088
63cd45c9 1089/* 12.6 Iteration Statements {{{ */
36cd3cb9
JF
1090IterationStatement
1091 : DoWhileStatement { $$ = $1; }
cf7d4c69
JF
1092 | WhileStatement { $$ = $1; }
1093 | ForStatement { $$ = $1; }
1094 | ForInStatement { $$ = $1; }
1dbba6cc 1095 ;
63cd45c9
JF
1096/* }}} */
1097/* 12.6.1 The do-while Statement {{{ */
36cd3cb9 1098DoWhileStatement
2eb8215d 1099 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1dbba6cc 1100 ;
63cd45c9
JF
1101/* }}} */
1102/* 12.6.2 The while Statement {{{ */
36cd3cb9 1103WhileStatement
2eb8215d 1104 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1dbba6cc 1105 ;
63cd45c9
JF
1106/* }}} */
1107/* 12.6.3 The for Statement {{{ */
36cd3cb9 1108ForStatement
3ea7eed0 1109 : "for" "(" LexPushInOn ForStatementInitialiser LexPopIn ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1dbba6cc
JF
1110 ;
1111
36cd3cb9 1112ForStatementInitialiser
3ea7eed0
JF
1113 : ExpressionOpt { $$ = $1; }
1114 | LexSetRegExp "var" VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1dbba6cc 1115 ;
63cd45c9
JF
1116/* }}} */
1117/* 12.6.4 The for-in Statement {{{ */
36cd3cb9 1118ForInStatement
3ea7eed0 1119 : "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1dbba6cc
JF
1120 ;
1121
36cd3cb9
JF
1122ForInStatementInitialiser
1123 : LeftHandSideExpression { $$ = $1; }
3ea7eed0 1124 | LexSetRegExp "var" VariableDeclaration { $$ = $3; }
1dbba6cc 1125 ;
63cd45c9 1126/* }}} */
1dbba6cc 1127
63cd45c9 1128/* 12.7 The continue Statement {{{ */
36cd3cb9 1129ContinueStatement
2eb8215d 1130 : "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1dbba6cc 1131 ;
63cd45c9
JF
1132/* }}} */
1133/* 12.8 The break Statement {{{ */
36cd3cb9 1134BreakStatement
2eb8215d 1135 : "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1dbba6cc 1136 ;
63cd45c9
JF
1137/* }}} */
1138/* 12.9 The return Statement {{{ */
36cd3cb9 1139ReturnStatement
2eb8215d 1140 : "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1dbba6cc 1141 ;
63cd45c9
JF
1142/* }}} */
1143/* 12.10 The with Statement {{{ */
36cd3cb9 1144WithStatement
2eb8215d 1145 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1dbba6cc 1146 ;
63cd45c9 1147/* }}} */
1dbba6cc 1148
63cd45c9 1149/* 12.11 The switch Statement {{{ */
36cd3cb9 1150SwitchStatement
2eb8215d 1151 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1dbba6cc
JF
1152 ;
1153
1154CaseBlock
3ea7eed0 1155 : BRACE CaseClausesOpt "}" { $$ = $2; }
1dbba6cc
JF
1156 ;
1157
55fc1817
JF
1158CaseClause
1159 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1160 ;
1161
36cd3cb9 1162CaseClausesOpt
cf7d4c69
JF
1163 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1164 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1165 | { $$ = NULL; }
1dbba6cc
JF
1166 ;
1167
36cd3cb9 1168DefaultClause
2eb8215d 1169 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1dbba6cc 1170 ;
63cd45c9
JF
1171/* }}} */
1172/* 12.12 Labelled Statements {{{ */
36cd3cb9 1173LabelledStatement
2eb8215d 1174 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1dbba6cc 1175 ;
63cd45c9
JF
1176/* }}} */
1177/* 12.13 The throw Statement {{{ */
36cd3cb9 1178ThrowStatement
2eb8215d 1179 : "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1dbba6cc 1180 ;
63cd45c9
JF
1181/* }}} */
1182/* 12.14 The try Statement {{{ */
36cd3cb9 1183TryStatement
2eb8215d 1184 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1dbba6cc
JF
1185 ;
1186
1187CatchOpt
2eb8215d 1188 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
cf7d4c69 1189 | { $$ = NULL; }
1dbba6cc
JF
1190 ;
1191
1192FinallyOpt
2eb8215d 1193 : "finally" Block_ { $$ = CYNew CYFinally($2); }
cf7d4c69 1194 | { $$ = NULL; }
1dbba6cc 1195 ;
63cd45c9 1196/* }}} */
c8a0500b
JF
1197/* 12.14 The debugger Statement {{{ */
1198DebuggerStatement
1199 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1200 ;
1201/* }}} */
1dbba6cc 1202
63cd45c9 1203/* 13 Function Definition {{{ */
36cd3cb9 1204FunctionDeclaration
3ea7eed0 1205 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1dbba6cc
JF
1206 ;
1207
36cd3cb9 1208FunctionExpression
3ea7eed0 1209 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt LexPopIn ")" BRACE LexPushInOff FunctionBody LexPopIn "}" { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1dbba6cc
JF
1210 ;
1211
1212FormalParameterList_
36cd3cb9 1213 : "," FormalParameterList { $$ = $2; }
cf7d4c69 1214 | { $$ = NULL; }
1dbba6cc
JF
1215 ;
1216
c8a0500b
JF
1217FormalParameterList
1218 // XXX: : FunctionRestParameter { $$ = $1; }
1219 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1220 ;
1221
55fc1817
JF
1222FormalParameterListOpt
1223 : FormalParameterList
1224 | { $$ = NULL; }
1225 ;
1226
c8a0500b
JF
1227/* XXX: FunctionRestParameter
1228 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1229 ;*/
1230
1231FormalParameter
1232 : BindingElement { $$ = $1; }
1233 ;
1234
36cd3cb9 1235FunctionBody
c8a0500b 1236 : StatementListOpt { $$ = $1; }
1dbba6cc 1237 ;
63cd45c9
JF
1238/* }}} */
1239/* 14 Program {{{ */
1dbba6cc 1240Program
c8a0500b 1241 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1dbba6cc
JF
1242 ;
1243
55fc1817
JF
1244ProgramBody
1245 : StatementList { $$ = $1; }
1246 ;
1247
c8a0500b
JF
1248ProgramBodyOpt
1249 : ProgramBody { $$ = $1; }
1250 | { $$ = NULL; }
1dbba6cc 1251 ;
63cd45c9 1252/* }}} */
e5332278 1253
cbaa5f0f 1254@begin ObjectiveC
4de0686f 1255/* Cycript (Objective-C): @class Declaration {{{ */
b09da87b 1256ClassSuperOpt
3ea7eed0
JF
1257 /* XXX: why the hell did I choose MemberExpression? */
1258 : ":" LexSetRegExp MemberExpression { $$ = $3; }
b09da87b
JF
1259 | { $$ = NULL; }
1260 ;
1261
1ba6903e
JF
1262ClassField
1263 : Expression Identifier ";"
1264 ;
1265
55fc1817 1266ClassFieldList
3ea7eed0 1267 : BRACE ClassFieldListOpt "}" { $$ = NULL; }
55fc1817
JF
1268 ;
1269
1ba6903e
JF
1270ClassFieldListOpt
1271 : ClassFieldListOpt ClassField
1272 |
1273 ;
1274
b09da87b
JF
1275MessageScope
1276 : "+" { $$ = false; }
1277 | "-" { $$ = true; }
1278 ;
1279
1280TypeOpt
1281 : "(" Expression ")" { $$ = $2; }
1ba6903e 1282 | "(" LexSetRegExp "void" ")" { $$ = NULL; }
b09da87b
JF
1283 | { $$ = NULL; }
1284 ;
1285
1286MessageParameter
2eb8215d 1287 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
b09da87b
JF
1288 ;
1289
55fc1817
JF
1290MessageParameterList
1291 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1292 ;
1293
b09da87b
JF
1294MessageParameterListOpt
1295 : MessageParameterList { $$ = $1; }
1296 | { $$ = NULL; }
1297 ;
1298
b09da87b
JF
1299MessageParameters
1300 : MessageParameterList { $$ = $1; }
2eb8215d 1301 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
b09da87b
JF
1302 ;
1303
1304ClassMessageDeclaration
3ea7eed0 1305 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
b09da87b
JF
1306 ;
1307
1308ClassMessageDeclarationListOpt
4e8c99fb 1309 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1ba6903e 1310 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
b09da87b
JF
1311 | { $$ = NULL; }
1312 ;
1313
e5bc40db
JF
1314ClassName
1315 : Identifier { $$ = $1; }
1316 | "(" AssignmentExpression ")" { $$ = $2; }
1317 ;
1318
367eebb1
JF
1319ClassNameOpt
1320 : ClassName { $$ = $1; }
1321 | { $$ = NULL; }
b09da87b
JF
1322 ;
1323
64b8d29f
JF
1324// XXX: this should be AssignmentExpressionNoRight
1325ClassProtocols
2eb8215d 1326 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
64b8d29f
JF
1327 ;
1328
1329ClassProtocolsOpt
1330 : "," ClassProtocols { $$ = $2; }
1331 | { $$ = NULL; }
1332 ;
1333
1334ClassProtocolListOpt
1335 : "<" ClassProtocols ">" { $$ = $2; }
1336 | { $$ = NULL; }
1337 ;
1338
fb98ac0c 1339ClassExpression
3ea7eed0 1340 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt LexPopIn "@end" { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
fb98ac0c
JF
1341 ;
1342
1343ClassStatement
3ea7eed0 1344 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1ba6903e
JF
1345 ;
1346
1347CategoryName
a630a9eb 1348 : "(" WordOpt ")"
367eebb1
JF
1349 ;
1350
1351CategoryStatement
3ea7eed0 1352 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
367eebb1
JF
1353 ;
1354
3ea7eed0 1355PrimaryExpression
fb98ac0c 1356 : ClassExpression { $$ = $1; }
367eebb1
JF
1357 ;
1358
3ea7eed0 1359Statement__
fb98ac0c 1360 : ClassStatement { $$ = $1; }
365abb0a 1361 | CategoryStatement { $$ = $1; }
b09da87b 1362 ;
cac61857 1363/* }}} */
4de0686f 1364/* Cycript (Objective-C): Send Message {{{ */
693d501b 1365VariadicCall
2eb8215d 1366 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
693d501b
JF
1367 | { $$ = NULL; }
1368 ;
1369
7e5391fd
JF
1370SelectorWordOpt
1371 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1372 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1373 ;
1374
55fc1817
JF
1375SelectorCall_
1376 : SelectorCall { $$ = $1; }
1377 | VariadicCall { $$ = $1; }
1378 ;
1379
693d501b 1380SelectorCall
2eb8215d 1381 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
693d501b
JF
1382 ;
1383
1384SelectorList
1385 : SelectorCall { $$ = $1; }
2eb8215d 1386 | Word { $$ = CYNew CYArgument($1, NULL); }
693d501b
JF
1387 ;
1388
1389MessageExpression
3ea7eed0
JF
1390 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList LexPopIn "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1391 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList LexPopIn "]" { $$ = CYNew CYSendSuper($6); }
693d501b
JF
1392 ;
1393
e7ed5354 1394SelectorExpression_
2eb8215d 1395 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
e7ed5354
JF
1396 ;
1397
1398SelectorExpression
1399 : SelectorExpression_ { $$ = $1; }
2eb8215d 1400 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
e7ed5354
JF
1401 ;
1402
55fc1817
JF
1403SelectorExpressionOpt
1404 : SelectorExpression_ { $$ = $1; }
1405 | { $$ = NULL; }
1406 ;
1407
3ea7eed0 1408PrimaryExpression
693d501b 1409 : MessageExpression { $$ = $1; }
3ea7eed0 1410 | "@selector" "(" LexPushInOff SelectorExpression LexPopIn ")" { $$ = CYNew CYSelector($4); }
693d501b
JF
1411 ;
1412/* }}} */
1ba6903e
JF
1413/* Cycript (Objective-C): @import Directive {{{ */
1414PathName
1415 : "/" PathName
1416 | "." PathName
1417 | Word PathName
1418 |
1419 ;
1420
1421ImportPath
1422 : "<" PathName ">"
1423 | StringLiteral
1424 ;
1425
c8a0500b 1426StatementListItem
2eb8215d 1427 : "@import" ImportPath { $$ = CYNew CYImport(); }
1ba6903e
JF
1428 ;
1429/* }}} */
4de0686f
JF
1430@end
1431
1432@begin C
1433/* Cycript (C): Pointer Indirection/Addressing {{{ */
9465b86d
JF
1434LeftHandSideExpression
1435 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
693d501b
JF
1436 ;
1437
1438UnaryExpression_
2eb8215d 1439 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
693d501b
JF
1440 ;
1441
9b5527f0 1442MemberAccess
2eb8215d
JF
1443 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1444 | "->" Identifier { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
7e5391fd 1445 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
9b5527f0 1446 ;
cac61857 1447/* }}} */
4de0686f
JF
1448@end
1449
320ce753 1450/* YUI: Documentation Comments {{{ */
3ea7eed0 1451Statement__
320ce753
JF
1452 : Comment { $$ = $1; }
1453 ;
1454/* }}} */
1455
cb02f8ae 1456@begin E4X
691e4717
JF
1457/* Lexer State {{{ */
1458LexPushRegExp
1459 : { driver.PushCondition(CYDriver::RegExpCondition); }
1460 ;
1461
1462LexPushXMLContent
1463 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1464 ;
1465
1466LexPushXMLTag
1467 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1468 ;
1469
1470LexPop
1471 : { driver.PopCondition(); }
1472 ;
1473
1474LexSetXMLContent
1475 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1476 ;
1477
1478LexSetXMLTag
1479 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1480 ;
1481/* }}} */
1482
1483XMLWhitespaceOpt
1484 : XMLWhitespace
1485 |
1486 ;
1487
1488/* 8.1 Context Keywords {{{ */
1489Identifier
1490 : "namespace" { $$ = $1; }
1491 | "xml" { $$ = $1; }
1492 ;
1493/* }}} */
cb02f8ae
JF
1494/* 8.3 XML Initialiser Input Elements {{{ */
1495XMLMarkup
691e4717
JF
1496 : XMLComment { $$ = $1; }
1497 | XMLCDATA { $$ = $1; }
1498 | XMLPI { $$ = $1; }
cb02f8ae
JF
1499 ;
1500/* }}} */
1501/* 11.1 Primary Expressions {{{ */
3ea7eed0 1502PrimaryExpression
2eb8215d 1503 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
691e4717
JF
1504 | XMLInitialiser { $$ = $1; }
1505 | XMLListInitialiser { $$ = $1; }
cb02f8ae
JF
1506 ;
1507
1508PropertyIdentifier
691e4717
JF
1509 : AttributeIdentifier { $$ = $1; }
1510 | QualifiedIdentifier { $$ = $1; }
1511 | WildcardIdentifier { $$ = $1; }
cb02f8ae
JF
1512 ;
1513/* }}} */
1514/* 11.1.1 Attribute Identifiers {{{ */
1515AttributeIdentifier
2eb8215d 1516 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
691e4717
JF
1517 ;
1518
1519PropertySelector_
b92ceddb 1520 : PropertySelector { $$ = $1; }
3ea7eed0 1521 | "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYSelector($3); }
cb02f8ae
JF
1522 ;
1523
1524PropertySelector
2eb8215d 1525 : Identifier { $$ = CYNew CYSelector($1); }
691e4717 1526 | WildcardIdentifier { $$ = $1; }
cb02f8ae
JF
1527 ;
1528/* }}} */
1529/* 11.1.2 Qualified Identifiers {{{ */
691e4717 1530QualifiedIdentifier_
2eb8215d 1531 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
691e4717
JF
1532 | QualifiedIdentifier { $$ = $1; }
1533 ;
1534
cb02f8ae 1535QualifiedIdentifier
2eb8215d 1536 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
cb02f8ae
JF
1537 ;
1538/* }}} */
1539/* 11.1.3 Wildcard Identifiers {{{ */
1540WildcardIdentifier
2eb8215d 1541 : "*" { $$ = CYNew CYWildcard(); }
cb02f8ae
JF
1542 ;
1543/* }}} */
1544/* 11.1.4 XML Initialiser {{{ */
1545XMLInitialiser
691e4717
JF
1546 : XMLMarkup { $$ = $1; }
1547 | XMLElement { $$ = $1; }
cb02f8ae
JF
1548 ;
1549
1550XMLElement
3ea7eed0
JF
1551 : "<" LexPushInOff XMLTagContent LexPop LexPopIn "/>"
1552 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop LexPopIn ">"
cb02f8ae
JF
1553 ;
1554
1555XMLTagContent
0347fadf 1556 : LexPushXMLTag XMLTagName XMLAttributes
cb02f8ae
JF
1557 ;
1558
691e4717 1559XMLExpression
3ea7eed0 1560 : BRACE LexPushRegExp Expression LexPop "}"
691e4717
JF
1561 ;
1562
cb02f8ae 1563XMLTagName
691e4717 1564 : XMLExpression
cb02f8ae
JF
1565 | XMLName
1566 ;
1567
0347fadf
JF
1568XMLAttributes_
1569 : XMLAttributes_ XMLAttribute
1570 |
cb02f8ae
JF
1571 ;
1572
0347fadf
JF
1573XMLAttributes
1574 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1575 | XMLAttributes_ XMLWhitespaceOpt
cb02f8ae
JF
1576 ;
1577
691e4717
JF
1578XMLAttributeValue_
1579 : XMLExpression
1580 | XMLAttributeValue
1581 ;
1582
cb02f8ae 1583XMLAttribute
691e4717 1584 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
cb02f8ae
JF
1585 ;
1586
cb02f8ae 1587XMLElementContent
691e4717 1588 : XMLExpression XMLElementContentOpt
cb02f8ae
JF
1589 | XMLMarkup XMLElementContentOpt
1590 | XMLText XMLElementContentOpt
1591 | XMLElement XMLElementContentOpt
1592 ;
1593
1594XMLElementContentOpt
1595 : XMLElementContent
1596 |
1597 ;
1598/* }}} */
1599/* 11.1.5 XMLList Initialiser {{{ */
1600XMLListInitialiser
3ea7eed0 1601 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop LexPopIn "</>" { $$ = CYNew CYXMLList($4); }
691e4717
JF
1602 ;
1603/* }}} */
1604/* 11.2 Left-Hand-Side Expressions {{{ */
1605PropertyIdentifier_
0347fadf 1606 : Identifier { $$ = $1; }
691e4717
JF
1607 | PropertyIdentifier { $$ = $1; }
1608 ;
1609
1610MemberAccess
2eb8215d
JF
1611 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1612 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1613 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
691e4717
JF
1614 ;
1615/* }}} */
1616/* 12.1 The default xml namespace Statement {{{ */
b92ceddb 1617/* XXX: DefaultXMLNamespaceStatement
2eb8215d 1618 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
691e4717
JF
1619 ;
1620
3ea7eed0 1621Statement__
691e4717 1622 : DefaultXMLNamespaceStatement { $$ = $1; }
b92ceddb 1623 ; */
cb02f8ae
JF
1624/* }}} */
1625@end
1626
cac61857
JF
1627/* ECMAScript5: Object Literal Trailing Comma {{{ */
1628PropertyNameAndValueList_
1629 : "," { $$ = NULL; }
1630 ;
1631/* }}} */
4e11a430 1632
cac61857 1633/* JavaScript 1.7: Array Comprehensions {{{ */
367eebb1 1634IfComprehension
2eb8215d 1635 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
367eebb1
JF
1636 ;
1637
1638ForComprehension
3ea7eed0
JF
1639 : "for" "(" LexPushInOn Identifier LexPopIn "!in" Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
1640 | "for" "each" "(" LexPushInOn Identifier LexPopIn "!in" Expression ")" { $$ = CYNew CYForEachInComprehension($5, $8); }
367eebb1
JF
1641 ;
1642
55fc1817
JF
1643ComprehensionList
1644 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1645 ;
1646
367eebb1 1647ComprehensionListOpt
75b0a457
JF
1648 : ComprehensionList { $$ = $1; }
1649 | IfComprehension { $$ = $1; }
1650 | { $$ = NULL; }
367eebb1
JF
1651 ;
1652
3ea7eed0
JF
1653PrimaryExpression
1654 : "[" LexPushInOff AssignmentExpression ComprehensionList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
367eebb1 1655 ;
cac61857
JF
1656/* }}} */
1657/* JavaScript 1.7: for each {{{ */
1658ForInStatement
3ea7eed0 1659 : "for" "each" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForEachIn($5, $8, $10); }
cac61857
JF
1660 ;
1661/* }}} */
15b88a33 1662/* JavaScript 1.7: let Statements {{{ */
cac61857 1663LetStatement
c8a0500b 1664 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
cac61857
JF
1665 ;
1666
3ea7eed0 1667Statement__
cac61857
JF
1668 : LetStatement
1669 ;
15b88a33 1670/* }}} */
4e11a430 1671
6c093cce
JF
1672/* JavaScript FTW: Ruby Blocks {{{ */
1673RubyProcParameterList_
1674 : "," RubyProcParameterList { $$ = $2; }
1675 | { $$ = NULL; }
1676 ;
1677
1678RubyProcParameterList
c8a0500b 1679 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
6c093cce
JF
1680 | { $$ = NULL; }
1681 ;
1682
d7205a63 1683RubyProcParameters
6c093cce 1684 : "|" RubyProcParameterList "|" { $$ = $2; }
d7205a63
JF
1685 | "||" { $$ = NULL; }
1686 ;
1687
1688RubyProcParametersOpt
1689 : RubyProcParameters
6c093cce
JF
1690 | { $$ = NULL; }
1691 ;
1692
1693RubyProcExpression
2eb8215d 1694 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
6c093cce
JF
1695 ;
1696
3ea7eed0
JF
1697PrimaryExpression
1698 : "{" LexPushInOff RubyProcParameters StatementListOpt LexPopIn "}" { $$ = CYNew CYRubyProc($3, $4); }
6c093cce
JF
1699 ;
1700
3ea7eed0
JF
1701CallExpression
1702 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
6c093cce 1703 ;
6c093cce 1704/* }}} */
367eebb1 1705
e5332278 1706%%