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