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