]> git.saurik.com Git - cycript.git/blame - Cycript.yy.in
Parse (but ignore) ECMAScript 6 "spread elements".
[cycript.git] / Cycript.yy.in
CommitLineData
b3378a02 1/* Cycript - Optimizing JavaScript Compiler/Runtime
c1d3e52e 2 * Copyright (C) 2009-2015 Jay Freeman (saurik)
b4aa79af
JF
3*/
4
f95d2598 5/* GNU Affero General Public License, Version 3 {{{ */
b4aa79af 6/*
f95d2598
JF
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c15969fd 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f95d2598
JF
15 * GNU Affero General Public License for more details.
16
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b3378a02 19**/
b4aa79af
JF
20/* }}} */
21
6ce9ac92 22%code top {
4e869640 23#define cyscanner driver.scanner_
693d501b 24#define YYSTACKEXPANDABLE 1
6ce9ac92 25}
1dbba6cc 26
6ce9ac92 27%code requires {
b12a9965 28#include "Driver.hpp"
63b4c5a8 29#include "Parser.hpp"
ddeb1876 30#include "Stack.hpp"
2c1d569a 31#define CYNew new(driver.pool_)
63b4c5a8 32
cbaa5f0f 33@begin ObjectiveC
3c1c3635 34#include "ObjectiveC/Syntax.hpp"
4de0686f
JF
35@end
36
691e4717 37@begin E4X
b92ceddb 38#include "E4X/Syntax.hpp"
691e4717
JF
39@end
40
82a02ede 41#include "Highlight.hpp"
a5662a53 42}
82a02ede 43
a5662a53
JF
44%union { bool bool_; }
45
46%union { CYArgument *argument_; }
47%union { CYAssignment *assignment_; }
48%union { CYBoolean *boolean_; }
49%union { CYClause *clause_; }
50%union { cy::Syntax::Catch *catch_; }
a5662a53
JF
51%union { CYComprehension *comprehension_; }
52%union { CYDeclaration *declaration_; }
53%union { CYDeclarations *declarations_; }
54%union { CYElement *element_; }
55%union { CYExpression *expression_; }
56%union { CYFalse *false_; }
57%union { CYFinally *finally_; }
a7d8b413
JF
58%union { CYForInitializer *for_; }
59%union { CYForInInitializer *forin_; }
a5662a53
JF
60%union { CYFunctionParameter *functionParameter_; }
61%union { CYIdentifier *identifier_; }
62%union { CYInfix *infix_; }
63%union { CYLiteral *literal_; }
64%union { CYMember *member_; }
65%union { CYModule *module_; }
66%union { CYNull *null_; }
67%union { CYNumber *number_; }
68%union { CYParenthetical *parenthetical_; }
a5662a53
JF
69%union { CYProperty *property_; }
70%union { CYPropertyName *propertyName_; }
71%union { CYRubyProc *rubyProc_; }
b900e1a4 72%union { CYSpan *span_; }
a5662a53
JF
73%union { CYStatement *statement_; }
74%union { CYString *string_; }
75%union { CYThis *this_; }
76%union { CYTrue *true_; }
77%union { CYWord *word_; }
4de0686f 78
7b750785 79@begin C
a5662a53
JF
80%union { CYTypeModifier *modifier_; }
81%union { CYTypeSpecifier *specifier_; }
82%union { CYTypedIdentifier *typedIdentifier_; }
83%union { CYTypedParameter *typedParameter_; }
7b750785
JF
84@end
85
cbaa5f0f 86@begin ObjectiveC
a5662a53
JF
87%union { CYClassName *className_; }
88%union { CYClassField *classField_; }
89%union { CYMessage *message_; }
90%union { CYMessageParameter *messageParameter_; }
91%union { CYProtocol *protocol_; }
92%union { CYSelectorPart *selector_; }
4de0686f 93@end
691e4717
JF
94
95@begin E4X
a5662a53
JF
96%union { CYAttribute *attribute_; }
97%union { CYPropertyIdentifier *propertyIdentifier_; }
98%union { CYSelector *selector_; }
691e4717 99@end
63b4c5a8 100
6ce9ac92 101%code provides {
a5662a53
JF
102
103struct YYSTYPE {
104 cy::parser::semantic_type semantic_;
105 hi::Value highlight_;
106};
107
58afc6aa 108int cylex(YYSTYPE *, CYLocation *, void *);
a5662a53
JF
109
110}
111
112%code {
113
114#undef yylex
115_finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, void *scanner) {
116 YYSTYPE data;
117 int token(cylex(&data, location, scanner));
118 *semantic = data.semantic_;
119 return token;
120}
121
6ce9ac92 122}
c5aeb567 123
6ce9ac92 124%name-prefix "cy"
e5332278 125
6ce9ac92 126%language "C++"
1dbba6cc 127
5999c315
JF
128%initial-action {
129 @$.begin.filename = @$.end.filename = &driver.filename_;
130};
131
be36c292 132%locations
e5332278 133%defines
1dbba6cc 134
58afc6aa
JF
135%define api.location.type { CYLocation }
136
534fb6da
JF
137//%glr-parser
138//%expect 1
cac61857 139
e5332278
JF
140%error-verbose
141
5999c315 142%parse-param { CYDriver &driver }
4e869640 143%lex-param { void *cyscanner }
e5332278 144
c3b144b8 145/* Token Declarations {{{ */
cb02f8ae 146@begin E4X
cb02f8ae
JF
147%token XMLCDATA
148%token XMLComment
149%token XMLPI
691e4717
JF
150
151%token XMLAttributeValue
152%token XMLName
153%token XMLTagCharacters
154%token XMLText
155%token XMLWhitespace
156@end
157
158@begin E4X
159%token LeftRight "<>"
160%token LeftSlashRight "</>"
161
162%token SlashRight "/>"
163%token LeftSlash "</"
164
691e4717
JF
165%token ColonColon "::"
166%token PeriodPeriod ".."
cb02f8ae 167@end
ac9a5ce1 168
b1589845
JF
169@begin E4X ObjectiveC
170%token At "@"
ac9d4181 171%token Pound "#"
b1589845
JF
172@end
173
63b4c5a8
JF
174%token Ampersand "&"
175%token AmpersandAmpersand "&&"
176%token AmpersandEqual "&="
177%token Carrot "^"
178%token CarrotEqual "^="
179%token Equal "="
180%token EqualEqual "=="
181%token EqualEqualEqual "==="
4b2fd91c 182%token EqualRight "=>"
6265f0de 183%token EqualRight_ "\n=>"
63b4c5a8
JF
184%token Exclamation "!"
185%token ExclamationEqual "!="
186%token ExclamationEqualEqual "!=="
187%token Hyphen "-"
188%token HyphenEqual "-="
189%token HyphenHyphen "--"
c3c20102 190%token HyphenHyphen_ "\n--"
63b4c5a8
JF
191%token HyphenRight "->"
192%token Left "<"
193%token LeftEqual "<="
194%token LeftLeft "<<"
195%token LeftLeftEqual "<<="
196%token Percent "%"
197%token PercentEqual "%="
198%token Period "."
c8a0500b 199%token PeriodPeriodPeriod "..."
63b4c5a8
JF
200%token Pipe "|"
201%token PipeEqual "|="
202%token PipePipe "||"
203%token Plus "+"
204%token PlusEqual "+="
205%token PlusPlus "++"
c3c20102 206%token PlusPlus_ "\n++"
63b4c5a8
JF
207%token Right ">"
208%token RightEqual ">="
209%token RightRight ">>"
210%token RightRightEqual ">>="
211%token RightRightRight ">>>"
212%token RightRightRightEqual ">>>="
213%token Slash "/"
214%token SlashEqual "/="
215%token Star "*"
216%token StarEqual "*="
217%token Tilde "~"
218
219%token Colon ":"
220%token Comma ","
221%token Question "?"
222%token SemiColon ";"
c3c20102 223%token NewLine "\n"
63b4c5a8 224
b900e1a4 225%token Comment
320ce753 226
63b4c5a8
JF
227%token OpenParen "("
228%token CloseParen ")"
924f67b2 229
63b4c5a8 230%token OpenBrace "{"
6c093cce 231%token OpenBrace_ "\n{"
3ea7eed0 232%token OpenBrace__ ";{"
63b4c5a8 233%token CloseBrace "}"
924f67b2 234
63b4c5a8
JF
235%token OpenBracket "["
236%token CloseBracket "]"
237
09e4db67 238%token At_error_ "@error"
dc5d7cf4 239
1ba6903e 240@begin Java
09e4db67 241%token At_class_ "@class"
1ba6903e
JF
242@end
243
60097023 244@begin C
09e4db67
JF
245%token _typedef_ "typedef"
246%token _unsigned_ "unsigned"
247%token _signed_ "signed"
248%token _extern_ "extern"
60097023
JF
249@end
250
8a2eb1be 251@begin C
09e4db67 252%token At_encode_ "@encode"
8a2eb1be
JF
253@end
254
1ba6903e 255@begin ObjectiveC
09e4db67
JF
256%token At_implementation_ "@implementation"
257%token At_implementation__ ";@implementation"
258%token At_import_ "@import"
259%token At_end_ "@end"
260%token At_selector_ "@selector"
261%token At_null_ "@null"
262%token At_YES_ "@YES"
263%token At_NO_ "@NO"
264%token At_true_ "@true"
265%token At_false_ "@false"
266%token _YES_ "YES"
267%token _NO_ "NO"
1ba6903e 268@end
e7ed5354 269
09e4db67
JF
270%token _false_ "false"
271%token _null_ "null"
272%token _true_ "true"
273
274%token _break_ "break"
275%token _case_ "case"
276%token _catch_ "catch"
277%token _class_ "class"
a7d8b413 278%token _class__ "!class"
09e4db67
JF
279%token _const_ "const"
280%token _continue_ "continue"
281%token _debugger_ "debugger"
282%token _default_ "default"
283%token _delete_ "delete"
284%token _do_ "do"
285%token _else_ "else"
286%token _enum_ "enum"
287%token _export_ "export"
288%token _extends_ "extends"
289%token _finally_ "finally"
290%token _for_ "for"
291%token _function_ "function"
292%token _function__ ";function"
293%token _if_ "if"
294%token _import_ "import"
295%token _in_ "in"
296%token _in__ "!in"
297%token _instanceof_ "instanceof"
298%token _new_ "new"
299%token _return_ "return"
300%token _super_ "super"
301%token _switch_ "switch"
302%token _this_ "this"
303%token _throw_ "throw"
304%token _try_ "try"
305%token _typeof_ "typeof"
306%token _var_ "var"
307%token _void_ "void"
308%token _while_ "while"
309%token _with_ "with"
310
311%token _abstract_ "abstract"
312%token _await_ "await"
313%token _boolean_ "boolean"
314%token _byte_ "byte"
315%token _char_ "char"
316%token _double_ "double"
317%token _final_ "final"
318%token _float_ "float"
319%token _goto_ "goto"
320%token _implements_ "implements"
321%token _int_ "int"
322%token _interface_ "interface"
323%token _let_ "let"
324%token _long_ "long"
325%token _native_ "native"
326%token _package_ "package"
327%token _private_ "private"
328%token _protected_ "protected"
329%token _public_ "public"
330%token _short_ "short"
331%token _static_ "static"
332%token _synchronized_ "synchronized"
333%token _throws_ "throws"
334%token _transient_ "transient"
335%token _volatile_ "volatile"
336%token _yield_ "yield"
337
338%token _undefined_ "undefined"
339
340@begin ObjectiveC
341%token _bool_ "bool"
342%token _BOOL_ "BOOL"
343%token _id_ "id"
344%token _nil_ "nil"
345%token _NULL_ "NULL"
346%token _SEL_ "SEL"
347@end
348
349%token _auto_ "auto"
350%token _each_ "each"
351%token _of_ "of"
75b0a457 352
691e4717 353@begin E4X
09e4db67
JF
354%token _namespace_ "namespace"
355%token _xml_ "xml"
691e4717
JF
356@end
357
7e5391fd
JF
358%token AutoComplete
359
75b0a457 360%token <identifier_> Identifier_
63b4c5a8
JF
361%token <number_> NumericLiteral
362%token <string_> StringLiteral
63cd45c9 363%token <literal_> RegularExpressionLiteral
1dbba6cc 364
b900e1a4
JF
365%token <string_> NoSubstitutionTemplate
366%token <string_> TemplateHead
367%token <string_> TemplateMiddle
368%token <string_> TemplateTail
369
cf7d4c69 370%type <expression_> AdditiveExpression
cf7d4c69 371%type <argument_> ArgumentList_
55fc1817 372%type <argument_> ArgumentList
cf7d4c69
JF
373%type <argument_> ArgumentListOpt
374%type <argument_> Arguments
b3aa25d8 375%type <expression_> ArrayComprehension
cf7d4c69 376%type <literal_> ArrayLiteral
4b2fd91c
JF
377%type <expression_> ArrowFunction
378%type <functionParameter_> ArrowParameters
55fc1817 379%type <expression_> AssignmentExpression
fc8fc33d 380%type <expression_> AssignmentExpressionOpt
c2529502 381%type <identifier_> Binding
c8a0500b 382%type <identifier_> BindingIdentifier
cf7d4c69 383%type <expression_> BitwiseANDExpression
55fc1817 384%type <statement_> Block
a7d8b413 385%type <statement_> BlockStatement
cf7d4c69 386%type <boolean_> BooleanLiteral
c8a0500b 387%type <declaration_> BindingElement
cf7d4c69
JF
388%type <expression_> BitwiseORExpression
389%type <expression_> BitwiseXORExpression
390%type <statement_> BreakStatement
c8a0500b 391%type <statement_> BreakableStatement
3ea7eed0 392%type <expression_> CallExpression_
cf7d4c69
JF
393%type <expression_> CallExpression
394%type <clause_> CaseBlock
395%type <clause_> CaseClause
396%type <clause_> CaseClausesOpt
a7d8b413
JF
397%type <catch_> Catch
398%type <identifier_> CatchParameter
b3aa25d8
JF
399%type <expression_> Comprehension
400%type <comprehension_> ComprehensionFor
401%type <comprehension_> ComprehensionIf
402%type <comprehension_> ComprehensionTail
cf7d4c69
JF
403%type <expression_> ConditionalExpression
404%type <statement_> ContinueStatement
4b2fd91c 405%type <statement_> ConciseBody
a7d8b413 406%type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
c8a0500b 407%type <statement_> DebuggerStatement
3ea7eed0
JF
408%type <statement_> Declaration__
409%type <statement_> Declaration_
c8a0500b 410%type <statement_> Declaration
cf7d4c69 411%type <clause_> DefaultClause
cf7d4c69 412%type <element_> ElementList
5befe15e 413%type <element_> ElementListOpt
cf7d4c69
JF
414%type <statement_> ElseStatementOpt
415%type <statement_> EmptyStatement
416%type <expression_> EqualityExpression
b0385401 417%type <expression_> Expression
cf7d4c69
JF
418%type <expression_> ExpressionOpt
419%type <statement_> ExpressionStatement
a7d8b413
JF
420%type <finally_> Finally
421%type <for_> ForStatementInitializer
422%type <forin_> ForInStatementInitializer
c8a0500b 423%type <declaration_> FormalParameter
b09da87b 424%type <functionParameter_> FormalParameterList_
55fc1817 425%type <functionParameter_> FormalParameterList
c8a0500b 426%type <functionParameter_> FormalParameterListOpt
b10bd496
JF
427%type <statement_> FunctionBody
428%type <statement_> FunctionDeclaration
cf7d4c69 429%type <expression_> FunctionExpression
a7d8b413 430%type <statement_> HoistableDeclaration
75b0a457 431%type <identifier_> Identifier
cf7d4c69 432%type <identifier_> IdentifierOpt
3fe283c5 433%type <identifier_> IdentifierType
4492c19c 434%type <word_> IdentifierName
a7d8b413 435%type <expression_> IdentifierReference
cf7d4c69 436%type <statement_> IfStatement
a7d8b413
JF
437%type <expression_> Initializer
438%type <expression_> InitializerOpt
cf7d4c69 439%type <statement_> IterationStatement
a7d8b413
JF
440%type <identifier_> LabelIdentifier
441%type <statement_> LabelledItem
cf7d4c69
JF
442%type <statement_> LabelledStatement
443%type <expression_> LeftHandSideExpression
15b88a33 444%type <statement_> LetStatement
c8a0500b 445%type <statement_> LexicalDeclaration
cf7d4c69
JF
446%type <literal_> Literal
447%type <expression_> LogicalANDExpression
448%type <expression_> LogicalORExpression
9b5527f0 449%type <member_> MemberAccess
693d501b 450%type <expression_> MemberExpression_
55fc1817 451%type <expression_> MemberExpression
7b750785 452%type <module_> Module
cf7d4c69 453%type <expression_> MultiplicativeExpression
55fc1817 454%type <expression_> NewExpression
cf7d4c69
JF
455%type <null_> NullLiteral
456%type <literal_> ObjectLiteral
cf7d4c69
JF
457%type <expression_> PostfixExpression
458%type <expression_> PrimaryExpression
b92ceddb 459%type <propertyName_> PropertyName_
55fc1817 460%type <propertyName_> PropertyName
aea76473
JF
461%type <property_> PropertyDefinition
462%type <property_> PropertyDefinitionList_
463%type <property_> PropertyDefinitionList
464%type <property_> PropertyDefinitionListOpt
55fc1817 465%type <expression_> RelationalExpression
cf7d4c69 466%type <statement_> ReturnStatement
6c093cce 467%type <rubyProc_> RubyProcExpression
6c093cce 468%type <functionParameter_> RubyProcParameterList_
55fc1817 469%type <functionParameter_> RubyProcParameterList
d7205a63 470%type <functionParameter_> RubyProcParameters
6c093cce 471%type <functionParameter_> RubyProcParametersOpt
a7d8b413
JF
472%type <statement_> Script
473%type <statement_> ScriptBody
474%type <statement_> ScriptBodyOpt
cf7d4c69 475%type <expression_> ShiftExpression
c8a0500b 476%type <declaration_> SingleNameBinding
3ea7eed0 477%type <statement_> Statement__
b10bd496 478%type <statement_> Statement_
55fc1817 479%type <statement_> Statement
693d501b 480%type <statement_> StatementList
cf7d4c69 481%type <statement_> StatementListOpt
c8a0500b 482%type <statement_> StatementListItem
cf7d4c69 483%type <statement_> SwitchStatement
b900e1a4
JF
484%type <expression_> TemplateLiteral
485%type <span_> TemplateSpans
cf7d4c69
JF
486%type <statement_> ThrowStatement
487%type <statement_> TryStatement
693d501b 488%type <expression_> UnaryExpression_
55fc1817 489%type <expression_> UnaryExpression
cf7d4c69 490%type <declaration_> VariableDeclaration
cf7d4c69 491%type <declarations_> VariableDeclarationList_
55fc1817 492%type <declarations_> VariableDeclarationList
cf7d4c69 493%type <statement_> VariableStatement
cf7d4c69 494%type <statement_> WithStatement
4492c19c 495%type <word_> Word
73f04979 496@begin ObjectiveC
4492c19c 497%type <word_> WordOpt
73f04979 498@end
cf7d4c69 499
7b750785 500@begin C
7b750785
JF
501%type <specifier_> IntegerType
502%type <specifier_> IntegerTypeOpt
503%type <typedIdentifier_> PrefixedType
504%type <specifier_> PrimitiveType
7b750785 505%type <typedIdentifier_> SuffixedType
00b4cb83 506%type <typedIdentifier_> TypeSignifier
7b750785
JF
507%type <modifier_> TypeQualifierLeft
508%type <typedIdentifier_> TypeQualifierRight
509%type <typedIdentifier_> TypedIdentifier
510%type <typedParameter_> TypedParameterList_
511%type <typedParameter_> TypedParameterList
512%type <typedParameter_> TypedParameterListOpt
513@end
514
515@begin ObjectiveC
c3b144b8 516%type <expression_> BoxableExpression
328ad766
JF
517%type <statement_> CategoryStatement
518%type <expression_> ClassExpression
b6a67580
JF
519%type <classField_> ClassFieldListOpt
520%type <classField_> ClassFields
328ad766
JF
521%type <statement_> ClassStatement
522%type <expression_> ClassSuperOpt
328ad766
JF
523%type <message_> ClassMessageDeclaration
524%type <message_> ClassMessageDeclarationListOpt
525%type <className_> ClassName
526%type <className_> ClassNameOpt
64b8d29f
JF
527%type <protocol_> ClassProtocolListOpt
528%type <protocol_> ClassProtocols
529%type <protocol_> ClassProtocolsOpt
693d501b 530%type <expression_> MessageExpression
328ad766
JF
531%type <messageParameter_> MessageParameter
532%type <messageParameter_> MessageParameters
533%type <messageParameter_> MessageParameterList
534%type <messageParameter_> MessageParameterListOpt
535%type <bool_> MessageScope
693d501b 536%type <argument_> SelectorCall_
55fc1817 537%type <argument_> SelectorCall
328ad766 538%type <selector_> SelectorExpression_
55fc1817 539%type <selector_> SelectorExpression
328ad766 540%type <selector_> SelectorExpressionOpt
693d501b 541%type <argument_> SelectorList
7e5391fd 542%type <word_> SelectorWordOpt
57d55714 543%type <typedIdentifier_> TypeOpt
693d501b 544%type <argument_> VariadicCall
328ad766 545@end
693d501b 546
691e4717 547@begin E4X
b92ceddb 548%type <propertyIdentifier_> PropertyIdentifier_
b92ceddb 549%type <selector_> PropertySelector_
55fc1817 550%type <selector_> PropertySelector
691e4717 551%type <identifier_> QualifiedIdentifier_
55fc1817 552%type <identifier_> QualifiedIdentifier
691e4717
JF
553%type <identifier_> WildcardIdentifier
554%type <identifier_> XMLComment
555%type <identifier_> XMLCDATA
556%type <identifier_> XMLElement
557%type <identifier_> XMLElementContent
558%type <identifier_> XMLMarkup
559%type <identifier_> XMLPI
560
561%type <attribute_> AttributeIdentifier
b92ceddb 562/* XXX: %type <statement_> DefaultXMLNamespaceStatement */
691e4717
JF
563%type <expression_> PropertyIdentifier
564%type <expression_> XMLListInitialiser
565%type <expression_> XMLInitialiser
566@end
c3b144b8
JF
567/* }}} */
568/* Token Priorities {{{ */
3ea7eed0
JF
569%nonassoc ""
570%left "++" "--"
b92ceddb
JF
571
572%nonassoc "if"
573%nonassoc "else"
c3b144b8 574/* }}} */
b92ceddb 575
a7d8b413 576%start Script
e5332278 577
693d501b 578%%
c3c20102 579
691e4717 580/* Lexer State {{{ */
3ea7eed0
JF
581LexPushInOn
582 : { driver.in_.push(true); }
583 ;
584
585LexPushInOff
586 : { driver.in_.push(false); }
587 ;
588
589LexPopIn
590 : { driver.in_.pop(); }
591 ;
592
691e4717
JF
593LexSetRegExp
594 : { driver.SetCondition(CYDriver::RegExpCondition); }
595 ;
3ea7eed0 596
a5662a53
JF
597LexNoNewLine
598 : { if (!yyla.empty() && yyla.type_get() != yyeof_) error(@$, "unexpected lookahead"); driver.no_.NewLine = true; }
599 ;
600
4b2fd91c 601LexNoBrace
6ce9ac92 602 : { if (yyla.empty()) driver.no_.OpenBrace = true; else if (yyla.type == yytranslate_(token::OpenBrace) || yyla.type == yytranslate_(token::OpenBrace_)) yyla.type = yytranslate_(token::OpenBrace__); }
4b2fd91c 603 ;
066da9f6 604
a7d8b413
JF
605LexNoClass
606 : { if (yyla.empty()) driver.no_.Class = true; else if (yyla.type == yytranslate_(token::_class_)) yyla.type = yytranslate_(token::_class__); }
607 ;
608
4b2fd91c 609LexNoFunction
09e4db67 610 : { if (yyla.empty()) driver.no_.Function = true; else if (yyla.type == yytranslate_(token::_function_)) yyla.type = yytranslate_(token::_function__); }
4b2fd91c
JF
611 ;
612
39ed6a51
JF
613LexNoAtImplementation :
614@begin ObjectiveC
09e4db67 615 { if (yyla.empty()) driver.no_.AtImplementation = true; else if (yyla.type == yytranslate_(token::At_implementation_)) yyla.type = yytranslate_(token::At_implementation__); }
39ed6a51 616@end
507848cd
JF
617 ;
618
4b2fd91c 619LexSetStatement
a7d8b413 620 : LexNoBrace LexNoClass LexNoFunction LexNoAtImplementation
3ea7eed0 621 ;
691e4717 622/* }}} */
c3b144b8 623/* Virtual Tokens {{{ */
3ea7eed0 624BRACE
6c093cce
JF
625 : "{"
626 | "\n{"
627 ;
a87d7060
JF
628
629Var_
630 : "var"
631 ;
c3b144b8 632/* }}} */
6c093cce 633
a7d8b413 634/* 11.6 Names and Keywords {{{ */
c3b144b8
JF
635IdentifierName
636 : Word { $$ = $1; }
49392246
JF
637 | "for" { $$ = CYNew CYWord("for"); }
638 | "in" { $$ = CYNew CYWord("in"); }
639 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
c3c20102
JF
640 ;
641
36cd3cb9 642Word
cf7d4c69 643 : Identifier { $$ = $1; }
8f56307d 644 | "auto" { $$ = CYNew CYWord("auto"); }
a5662a53 645 | "break" { $$ = CYNew CYWord("break"); }
8f56307d
JF
646 | "case" { $$ = CYNew CYWord("case"); }
647 | "catch" { $$ = CYNew CYWord("catch"); }
648 | "class" { $$ = CYNew CYWord("class"); }
a7d8b413 649 | "!class" { $$ = CYNew CYWord("class"); }
8f56307d 650 | "const" { $$ = CYNew CYWord("const"); }
a5662a53 651 | "continue" { $$ = CYNew CYWord("continue"); }
8f56307d
JF
652 | "debugger" { $$ = CYNew CYWord("debugger"); }
653 | "default" { $$ = CYNew CYWord("default"); }
654 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
655 | "do" { $$ = CYNew CYWord("do"); }
656 | "else" { $$ = CYNew CYWord("else"); }
657 | "enum" { $$ = CYNew CYWord("enum"); }
658 | "export" { $$ = CYNew CYWord("export"); }
659 | "extends" { $$ = CYNew CYWord("extends"); }
660 | "false" { $$ = CYNew CYWord("false"); }
661 | "finally" { $$ = CYNew CYWord("finally"); }
8f56307d
JF
662 | "function" { $$ = CYNew CYWord("function"); }
663 | "if" { $$ = CYNew CYWord("if"); }
664 | "import" { $$ = CYNew CYWord("import"); }
8f56307d 665 | "!in" { $$ = CYNew CYWord("in"); }
8f56307d
JF
666 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
667 | "null" { $$ = CYNew CYWord("null"); }
a5662a53 668 | "return" { $$ = CYNew CYWord("return"); }
8f56307d
JF
669 | "super" { $$ = CYNew CYWord("super"); }
670 | "switch" { $$ = CYNew CYWord("switch"); }
671 | "this" { $$ = CYNew CYWord("this"); }
a5662a53 672 | "throw" { $$ = CYNew CYWord("throw"); }
8f56307d
JF
673 | "true" { $$ = CYNew CYWord("true"); }
674 | "try" { $$ = CYNew CYWord("try"); }
675 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
676 | "var" { $$ = CYNew CYWord("var"); }
677 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
678 | "while" { $$ = CYNew CYWord("while"); }
679 | "with" { $$ = CYNew CYWord("with"); }
49392246
JF
680
681 // XXX: should be Identifier
682 | "let" { $$ = CYNew CYIdentifier("let"); }
2bf24581 683 ;
f2f0d1d1 684
73f04979 685@begin ObjectiveC
55fc1817
JF
686WordOpt
687 : Word { $$ = $1; }
688 | { $$ = NULL; }
689 ;
73f04979 690@end
a7d8b413
JF
691/* }}} */
692/* 11.8.1 Null Literals {{{ */
693NullLiteral
694 : "null" { $$ = CYNew CYNull(); }
695 ;
696/* }}} */
697/* 11.8.2 Boolean Literals {{{ */
698BooleanLiteral
699 : "true" { $$ = CYNew CYTrue(); }
700 | "false" { $$ = CYNew CYFalse(); }
701 ;
702/* }}} */
703
704/* 11.9 Automatic Semicolon Insertion {{{ */
705StrictSemi
706 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
707 ;
708
709TerminatorSoft
710 : ";"
711 | "\n" StrictSemi
712 ;
713
714Terminator
715 : ";"
716 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) { error(@1, "required semi-colon"); } else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
717 ;
718
719TerminatorOpt
720 : ";"
721 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
722 ;
723/* }}} */
724
725/* 12.1 Identifiers {{{ */
726IdentifierReference
727 : Identifier { $$ = CYNew CYVariable($1); }
728 // XXX: | "yield"
729 ;
730
731BindingIdentifier
732 : Identifier { $$ = $1; }
733 // XXX: | "yield"
734 ;
735
736LabelIdentifier
737 : Identifier { $$ = $1; }
738 // XXX: | yield
739 ;
55fc1817 740
3fe283c5 741IdentifierType
75b0a457 742 : Identifier_ { $$ = $1; }
d6e7cafb
JF
743 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
744 | "await" { $$ = CYNew CYIdentifier("await"); }
745 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
746 | "byte" { $$ = CYNew CYIdentifier("byte"); }
747 | "double" { $$ = CYNew CYIdentifier("double"); }
49392246 748 | "each" { $$ = CYNew CYIdentifier("each"); }
d6e7cafb
JF
749 | "final" { $$ = CYNew CYIdentifier("final"); }
750 | "float" { $$ = CYNew CYIdentifier("float"); }
751 | "goto" { $$ = CYNew CYIdentifier("goto"); }
752 | "implements" { $$ = CYNew CYIdentifier("implements"); }
753 | "interface" { $$ = CYNew CYIdentifier("interface"); }
754 | "native" { $$ = CYNew CYIdentifier("native"); }
49392246 755 | "of" { $$ = CYNew CYIdentifier("of"); }
d6e7cafb
JF
756 | "package" { $$ = CYNew CYIdentifier("package"); }
757 | "private" { $$ = CYNew CYIdentifier("private"); }
758 | "protected" { $$ = CYNew CYIdentifier("protected"); }
759 | "public" { $$ = CYNew CYIdentifier("public"); }
760 | "static" { $$ = CYNew CYIdentifier("static"); }
761 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
762 | "throws" { $$ = CYNew CYIdentifier("throws"); }
763 | "transient" { $$ = CYNew CYIdentifier("transient"); }
a5662a53 764 | "yield" { $$ = CYNew CYIdentifier("yield"); }
09e4db67
JF
765@begin ObjectiveC
766 | "bool" { $$ = CYNew CYIdentifier("bool"); }
767 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
768 | "id" { $$ = CYNew CYIdentifier("id"); }
769 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
770@end
75b0a457
JF
771 ;
772
3fe283c5
JF
773Identifier
774 : IdentifierType
d6e7cafb
JF
775 | "char" { $$ = CYNew CYIdentifier("char"); }
776 | "int" { $$ = CYNew CYIdentifier("int"); }
777 | "long" { $$ = CYNew CYIdentifier("long"); }
778 | "short" { $$ = CYNew CYIdentifier("short"); }
09e4db67 779 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
d6e7cafb 780 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
3fe283c5 781@begin C
d6e7cafb
JF
782 | "extern" { $$ = CYNew CYIdentifier("extern"); }
783 | "signed" { $$ = CYNew CYIdentifier("signed"); }
784 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
785 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
7b750785
JF
786@end
787@begin ObjectiveC
09e4db67 788 | "nil" { $$ = CYNew CYIdentifier("nil"); }
d6e7cafb 789 | "NO" { $$ = CYNew CYIdentifier("NO"); }
09e4db67 790 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
d6e7cafb 791 | "YES" { $$ = CYNew CYIdentifier("YES"); }
3fe283c5
JF
792@end
793 ;
794
36cd3cb9 795IdentifierOpt
cf7d4c69
JF
796 : Identifier { $$ = $1; }
797 | { $$ = NULL; }
1dbba6cc 798 ;
c3b144b8 799/* }}} */
a7d8b413 800/* 12.2 Primary Expression {{{ */
3ea7eed0 801PrimaryExpression
8f56307d 802 : "this" { $$ = CYNew CYThis(); }
a7d8b413 803 | IdentifierReference { $$ = $1; }
cf7d4c69 804 | Literal { $$ = $1; }
a7d8b413 805 | ArrayLiteral { $$ = $1; }
3ea7eed0 806 | ObjectLiteral { $$ = $1; }
a7d8b413 807 | RegularExpressionLiteral { $$ = $1; }
b900e1a4 808 | TemplateLiteral { $$ = $1; }
a7d8b413 809 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) error(@1, "invalid parenthetical"); $$ = $1; }
3ea7eed0 810 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
1dbba6cc 811 ;
a7d8b413
JF
812
813CoverParenthesizedExpressionAndArrowParameterList
814 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
815 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
816 ;
1dbba6cc 817/* }}} */
a7d8b413
JF
818/* 12.2.4 Literals {{{ */
819Literal
820 : NullLiteral { $$ = $1; }
821 | BooleanLiteral { $$ = $1; }
822 | NumericLiteral { $$ = $1; }
823 | StringLiteral { $$ = $1; }
b3aa25d8
JF
824 ;
825/* }}} */
a7d8b413 826/* 12.2.5 Array Initializer {{{ */
36cd3cb9 827ArrayLiteral
440424e2 828 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
1dbba6cc
JF
829 ;
830
36cd3cb9 831ElementList
fc8fc33d
JF
832 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
833 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
834 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
1dbba6cc 835 ;
55fc1817
JF
836
837ElementListOpt
838 : ElementList { $$ = $1; }
839 | LexSetRegExp { $$ = NULL; }
840 ;
1dbba6cc 841/* }}} */
a7d8b413 842/* 12.2.6 Object Initializer {{{ */
36cd3cb9 843ObjectLiteral
440424e2 844 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
1dbba6cc
JF
845 ;
846
aea76473
JF
847PropertyDefinitionList_
848 : "," PropertyDefinitionList { $$ = $2; }
70234143 849 | "," LexSetRegExp { $$ = NULL; }
cac61857 850 | { $$ = NULL; }
1dbba6cc
JF
851 ;
852
aea76473
JF
853PropertyDefinitionList
854 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
55fc1817
JF
855 ;
856
aea76473
JF
857PropertyDefinitionListOpt
858 : PropertyDefinitionList { $$ = $1; }
70234143 859 | LexSetRegExp { $$ = NULL; }
1dbba6cc
JF
860 ;
861
aea76473 862PropertyDefinition
797cb0e5
JF
863 // XXX: this should be IdentifierName
864 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
865 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
aea76473
JF
866 //| MethodDefinition
867 ;
868
b92ceddb 869PropertyName_
4492c19c 870 : IdentifierName { $$ = $1; }
36cd3cb9
JF
871 | StringLiteral { $$ = $1; }
872 | NumericLiteral { $$ = $1; }
1dbba6cc 873 ;
b92ceddb
JF
874
875PropertyName
876 : LexSetRegExp PropertyName_ { $$ = $2; }
877 ;
a7d8b413
JF
878
879
880Initializer
881 : "=" AssignmentExpression { $$ = $2; }
882 ;
883
884InitializerOpt
885 : Initializer { $$ = $1; }
886 | { $$ = NULL; }
887 ;
888/* }}} */
889/* 12.2.9 Template Literals {{{ */
b900e1a4
JF
890TemplateLiteral
891 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
892 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
893 ;
1dbba6cc 894
b900e1a4
JF
895TemplateSpans
896 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
897 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
898 ;
899/* }}} */
a7d8b413
JF
900
901/* 12.3+ Left-Hand-Side Expressions {{{ */
9b5527f0 902MemberAccess
440424e2 903 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
5ccfc586 904 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
7e5391fd 905 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
9b5527f0
JF
906 ;
907
55fc1817 908MemberExpression_
3ea7eed0
JF
909 : MemberExpression { $$ = $1; }
910 //| "super" { $$ = $1; }
55fc1817
JF
911 ;
912
36cd3cb9 913MemberExpression
3ea7eed0 914 : LexSetRegExp PrimaryExpression { $$ = $2; }
afbff131 915 | LexSetRegExp FunctionExpression { $$ = $2; }
3ea7eed0
JF
916 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
917 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1dbba6cc
JF
918 ;
919
36cd3cb9 920NewExpression
cf7d4c69 921 : MemberExpression { $$ = $1; }
3ea7eed0 922 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1dbba6cc
JF
923 ;
924
3ea7eed0
JF
925CallExpression_
926 : MemberExpression_
927 | CallExpression
b1589845
JF
928 ;
929
36cd3cb9 930CallExpression
3ea7eed0 931 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
7e5391fd 932 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1dbba6cc
JF
933 ;
934
3ea7eed0 935Arguments
440424e2 936 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
b1589845
JF
937 ;
938
36cd3cb9 939ArgumentList_
cf7d4c69
JF
940 : "," ArgumentList { $$ = $2; }
941 | { $$ = NULL; }
1dbba6cc
JF
942 ;
943
55fc1817
JF
944ArgumentList
945 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
ed493ddd 946 | LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
55fc1817
JF
947 ;
948
36cd3cb9 949ArgumentListOpt
cf7d4c69 950 : ArgumentList { $$ = $1; }
691e4717 951 | LexSetRegExp { $$ = NULL; }
1dbba6cc
JF
952 ;
953
36cd3cb9 954LeftHandSideExpression
cf7d4c69
JF
955 : NewExpression { $$ = $1; }
956 | CallExpression { $$ = $1; }
693d501b 957 ;
63cd45c9 958/* }}} */
a7d8b413 959/* 12.4 Postfix Expressions {{{ */
36cd3cb9 960PostfixExpression
3ea7eed0 961 : %prec "" LeftHandSideExpression { $$ = $1; }
2eb8215d
JF
962 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
963 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
1dbba6cc 964 ;
63cd45c9 965/* }}} */
a7d8b413 966/* 12.5 Unary Operators {{{ */
693d501b 967UnaryExpression_
2eb8215d
JF
968 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
969 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
970 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
971 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
972 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
973 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
974 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
975 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
976 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
977 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
978 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
693d501b
JF
979 ;
980
981UnaryExpression
982 : PostfixExpression { $$ = $1; }
691e4717 983 | LexSetRegExp UnaryExpression_ { $$ = $2; }
693d501b 984 ;
63cd45c9 985/* }}} */
a7d8b413 986/* 12.6 Multiplicative Operators {{{ */
36cd3cb9 987MultiplicativeExpression
cf7d4c69 988 : UnaryExpression { $$ = $1; }
2eb8215d
JF
989 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
990 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
991 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1dbba6cc 992 ;
63cd45c9 993/* }}} */
a7d8b413 994/* 12.7 Additive Operators {{{ */
36cd3cb9 995AdditiveExpression
cf7d4c69 996 : MultiplicativeExpression { $$ = $1; }
2eb8215d
JF
997 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
998 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1dbba6cc 999 ;
63cd45c9 1000/* }}} */
a7d8b413 1001/* 12.8 Bitwise Shift Operators {{{ */
36cd3cb9 1002ShiftExpression
cf7d4c69 1003 : AdditiveExpression { $$ = $1; }
2eb8215d
JF
1004 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1005 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1006 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1dbba6cc 1007 ;
63cd45c9 1008/* }}} */
a7d8b413 1009/* 12.9 Relational Operators {{{ */
3ea7eed0 1010RelationalExpression
05089169
JF
1011 : ShiftExpression { $$ = $1; }
1012 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1013 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1014 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1015 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1016 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1017 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
693d501b 1018 ;
63cd45c9 1019/* }}} */
a7d8b413 1020/* 12.10 Equality Operators {{{ */
36cd3cb9 1021EqualityExpression
cf7d4c69 1022 : RelationalExpression { $$ = $1; }
2eb8215d
JF
1023 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1024 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1025 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1026 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1dbba6cc 1027 ;
63cd45c9 1028/* }}} */
a7d8b413 1029/* 12.11 Binary Bitwise Operators {{{ */
36cd3cb9 1030BitwiseANDExpression
cf7d4c69 1031 : EqualityExpression { $$ = $1; }
2eb8215d 1032 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1dbba6cc
JF
1033 ;
1034
36cd3cb9 1035BitwiseXORExpression
cf7d4c69 1036 : BitwiseANDExpression { $$ = $1; }
2eb8215d 1037 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1dbba6cc
JF
1038 ;
1039
36cd3cb9 1040BitwiseORExpression
cf7d4c69 1041 : BitwiseXORExpression { $$ = $1; }
2eb8215d 1042 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1dbba6cc 1043 ;
63cd45c9 1044/* }}} */
a7d8b413 1045/* 12.12 Binary Logical Operators {{{ */
36cd3cb9 1046LogicalANDExpression
cf7d4c69 1047 : BitwiseORExpression { $$ = $1; }
2eb8215d 1048 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1dbba6cc
JF
1049 ;
1050
36cd3cb9 1051LogicalORExpression
cf7d4c69 1052 : LogicalANDExpression { $$ = $1; }
2eb8215d 1053 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1dbba6cc 1054 ;
63cd45c9 1055/* }}} */
a7d8b413 1056/* 12.13 Conditional Operator ( ? : ) {{{ */
36cd3cb9 1057ConditionalExpression
cf7d4c69 1058 : LogicalORExpression { $$ = $1; }
440424e2 1059 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
693d501b 1060 ;
63cd45c9 1061/* }}} */
a7d8b413 1062/* 12.14 Assignment Operators {{{ */
36cd3cb9 1063AssignmentExpression
cf7d4c69 1064 : ConditionalExpression { $$ = $1; }
a7d8b413 1065 // XXX: | YieldExpression { $$ = $1; }
4b2fd91c 1066 | ArrowFunction { $$ = $1; }
005a0939
JF
1067 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1068 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1069 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1070 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1071 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1072 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1073 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1074 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1075 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1076 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1077 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1078 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
693d501b 1079 ;
fc8fc33d
JF
1080
1081AssignmentExpressionOpt
1082 : AssignmentExpression { $$ = $1; }
1083 | LexSetRegExp { $$ = NULL; }
1084 ;
63cd45c9 1085/* }}} */
a7d8b413 1086/* 12.15 Comma Operator ( , ) {{{ */
55fc1817 1087Expression
b0385401 1088 : AssignmentExpression { $$ = $1; }
a7d8b413 1089 /* XXX: I have this backwards... */
b0385401 1090 | AssignmentExpression "," Expression { $$ = CYNew CYCompound($1, $3); }
693d501b
JF
1091 ;
1092
36cd3cb9 1093ExpressionOpt
cf7d4c69 1094 : Expression { $$ = $1; }
691e4717 1095 | LexSetRegExp { $$ = NULL; }
1dbba6cc 1096 ;
63cd45c9 1097/* }}} */
693d501b 1098
a7d8b413 1099/* 13 Statements and Declarations {{{ */
3ea7eed0 1100Statement__
a7d8b413 1101 : BlockStatement { $$ = $1; }
36cd3cb9
JF
1102 | VariableStatement { $$ = $1; }
1103 | EmptyStatement { $$ = $1; }
cf7d4c69 1104 | IfStatement { $$ = $1; }
c8a0500b 1105 | BreakableStatement { $$ = $1; }
36cd3cb9
JF
1106 | ContinueStatement { $$ = $1; }
1107 | BreakStatement { $$ = $1; }
1108 | ReturnStatement { $$ = $1; }
cf7d4c69
JF
1109 | WithStatement { $$ = $1; }
1110 | LabelledStatement { $$ = $1; }
36cd3cb9
JF
1111 | ThrowStatement { $$ = $1; }
1112 | TryStatement { $$ = $1; }
c8a0500b 1113 | DebuggerStatement { $$ = $1; }
1dbba6cc 1114 ;
b10bd496 1115
3ea7eed0
JF
1116Statement_
1117 : LexSetRegExp Statement__ { $$ = $2; }
1118 | ExpressionStatement { $$ = $1; }
1119 ;
1120
b10bd496 1121Statement
3ea7eed0 1122 : LexSetStatement Statement_ { $$ = $2; }
b10bd496 1123 ;
c8a0500b 1124
3ea7eed0 1125Declaration__
a7d8b413
JF
1126 : HoistableDeclaration { $$ = $1; }
1127 // XXX: | ClassDeclaration { $$ = $1; }
c8a0500b
JF
1128 | LexicalDeclaration { $$ = $1; }
1129 ;
1130
3ea7eed0
JF
1131Declaration_
1132 : LexSetRegExp Declaration__ { $$ = $2; }
1133 ;
1134
1135Declaration
1136 : LexSetStatement Declaration_ { $$ = $2; }
1137 ;
1138
a7d8b413
JF
1139HoistableDeclaration
1140 : FunctionDeclaration
1141 // XXX: | GeneratorDeclaration
1142 ;
1143
c8a0500b
JF
1144BreakableStatement
1145 : IterationStatement { $$ = $1; }
1146 | SwitchStatement { $$ = $1; }
1147 ;
63cd45c9 1148/* }}} */
a7d8b413
JF
1149/* 13.2 Block {{{ */
1150BlockStatement
1151 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
cac61857
JF
1152 ;
1153
36cd3cb9 1154Block
a7d8b413 1155 : BRACE StatementListOpt "}" { $$ = $2; }
1dbba6cc
JF
1156 ;
1157
693d501b 1158StatementList
c8a0500b 1159 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
693d501b
JF
1160 ;
1161
1162StatementListOpt
1163 : StatementList { $$ = $1; }
5d660bed 1164 | LexSetStatement LexSetRegExp { $$ = NULL; }
1dbba6cc 1165 ;
c8a0500b
JF
1166
1167StatementListItem
1168 : Statement { $$ = $1; }
3ea7eed0 1169 | Declaration { $$ = $1; }
c8a0500b
JF
1170 ;
1171/* }}} */
a7d8b413 1172/* 13.3+ Let and Const Declarations {{{ */
c8a0500b
JF
1173LexicalDeclaration
1174 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1175 ;
1176
1177LetOrConst
1178 : "let"
1179 | "const"
1180 ;
a7d8b413
JF
1181
1182Binding
1183 : BindingIdentifier
1184 ;
1185
1186// XXX: lots of binding stuff
63cd45c9 1187/* }}} */
a7d8b413 1188/* 13.3.2+ Variable Statement {{{ */
36cd3cb9 1189VariableStatement
a87d7060 1190 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1dbba6cc
JF
1191 ;
1192
36cd3cb9 1193VariableDeclarationList_
cf7d4c69
JF
1194 : "," VariableDeclarationList { $$ = $2; }
1195 | { $$ = NULL; }
1dbba6cc
JF
1196 ;
1197
55fc1817
JF
1198VariableDeclarationList
1199 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1200 ;
1201
36cd3cb9 1202VariableDeclaration
a7d8b413
JF
1203 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1204 // XXX: | BindingPattern Initializer { $$ = CYNew CYDeclaration($1, $2); }
1dbba6cc 1205 ;
63cd45c9 1206/* }}} */
a7d8b413 1207/* 13.3.3+ Destructuring Binding Patterns {{{ */
c8a0500b
JF
1208// XXX: *
1209
1210BindingElement
1211 : SingleNameBinding { $$ = $1; }
1212 ;
1213
1214SingleNameBinding
a7d8b413 1215 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
c8a0500b
JF
1216 ;
1217/* }}} */
a7d8b413 1218/* 13.4 Empty Statement {{{ */
36cd3cb9 1219EmptyStatement
2eb8215d 1220 : ";" { $$ = CYNew CYEmpty(); }
1dbba6cc 1221 ;
63cd45c9 1222/* }}} */
a7d8b413 1223/* 13.5 Expression Statement {{{ */
36cd3cb9 1224ExpressionStatement
3ea7eed0 1225 : Expression Terminator { $$ = CYNew CYExpress($1); }
1dbba6cc 1226 ;
63cd45c9 1227/* }}} */
a7d8b413 1228/* 13.6 The if Statement {{{ */
36cd3cb9
JF
1229ElseStatementOpt
1230 : "else" Statement { $$ = $2; }
c3c20102 1231 | %prec "if" { $$ = NULL; }
1dbba6cc
JF
1232 ;
1233
36cd3cb9 1234IfStatement
2eb8215d 1235 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1dbba6cc 1236 ;
63cd45c9 1237/* }}} */
a7d8b413 1238/* 13.7+ Iteration Statements {{{ */
d5618df7 1239IterationStatement
2eb8215d 1240 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
a7d8b413
JF
1241 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1242 | "for" "(" LexPushInOn ForStatementInitializer ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1243 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1244 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1dbba6cc
JF
1245 ;
1246
a7d8b413 1247ForStatementInitializer
3ea7eed0 1248 : ExpressionOpt { $$ = $1; }
a87d7060 1249 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1dbba6cc 1250 ;
1dbba6cc 1251
a7d8b413 1252ForInStatementInitializer
36cd3cb9 1253 : LeftHandSideExpression { $$ = $1; }
a87d7060 1254 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1dbba6cc 1255 ;
63cd45c9 1256/* }}} */
a7d8b413 1257/* 13.8 The continue Statement {{{ */
a5662a53
JF
1258Continue
1259 : "continue" LexNoNewLine
1260 ;
1261
36cd3cb9 1262ContinueStatement
a5662a53
JF
1263 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1264 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1dbba6cc 1265 ;
63cd45c9 1266/* }}} */
a7d8b413 1267/* 13.9 The break Statement {{{ */
a5662a53
JF
1268Break
1269 : "break" LexNoNewLine
1270 ;
1271
36cd3cb9 1272BreakStatement
a5662a53
JF
1273 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1274 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1dbba6cc 1275 ;
63cd45c9 1276/* }}} */
a7d8b413 1277/* 13.10 The return Statement {{{ */
a5662a53
JF
1278Return
1279 : "return" LexNoNewLine
1280 ;
1281
36cd3cb9 1282ReturnStatement
a5662a53
JF
1283 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1284 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1dbba6cc 1285 ;
63cd45c9 1286/* }}} */
a7d8b413 1287/* 13.11 The with Statement {{{ */
36cd3cb9 1288WithStatement
2eb8215d 1289 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1dbba6cc 1290 ;
63cd45c9 1291/* }}} */
a7d8b413 1292/* 13.12 The switch Statement {{{ */
36cd3cb9 1293SwitchStatement
2eb8215d 1294 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1dbba6cc
JF
1295 ;
1296
1297CaseBlock
3ea7eed0 1298 : BRACE CaseClausesOpt "}" { $$ = $2; }
1dbba6cc
JF
1299 ;
1300
55fc1817
JF
1301CaseClause
1302 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1303 ;
1304
36cd3cb9 1305CaseClausesOpt
cf7d4c69
JF
1306 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1307 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1308 | { $$ = NULL; }
1dbba6cc
JF
1309 ;
1310
a7d8b413 1311// XXX: the standard makes certain you can only have one of these
36cd3cb9 1312DefaultClause
2eb8215d 1313 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1dbba6cc 1314 ;
63cd45c9 1315/* }}} */
a7d8b413 1316/* 13.13 Labelled Statements {{{ */
36cd3cb9 1317LabelledStatement
a7d8b413
JF
1318 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1319 ;
1320
1321LabelledItem
1322 : Statement { $$ = $1; }
1323 | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
1dbba6cc 1324 ;
63cd45c9 1325/* }}} */
a7d8b413
JF
1326/* 13.14 The throw Statement {{{ */
1327Throw
a5662a53
JF
1328 : "throw" LexNoNewLine
1329 ;
1330
36cd3cb9 1331ThrowStatement
a7d8b413
JF
1332 : Throw LexSetRegExp TerminatorSoft { error(@1, "throw without exception"); }
1333 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1dbba6cc 1334 ;
63cd45c9 1335/* }}} */
a7d8b413 1336/* 13.15 The try Statement {{{ */
36cd3cb9 1337TryStatement
a7d8b413
JF
1338 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1339 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1340 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1dbba6cc
JF
1341 ;
1342
a7d8b413
JF
1343Catch
1344 : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
1dbba6cc
JF
1345 ;
1346
a7d8b413
JF
1347Finally
1348 : "finally" Block { $$ = CYNew CYFinally($2); }
1349 ;
1350
1351CatchParameter
1352 : BindingIdentifier { $$ = $1; }
1353 // XXX: BindingPattern
1dbba6cc 1354 ;
63cd45c9 1355/* }}} */
a7d8b413 1356/* 13.16 The debugger Statement {{{ */
c8a0500b
JF
1357DebuggerStatement
1358 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1359 ;
1360/* }}} */
1dbba6cc 1361
a7d8b413 1362/* 14.1+ Function Definitions {{{ */
36cd3cb9 1363FunctionDeclaration
3ea7eed0 1364 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1dbba6cc
JF
1365 ;
1366
36cd3cb9 1367FunctionExpression
440424e2 1368 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1dbba6cc
JF
1369 ;
1370
1371FormalParameterList_
36cd3cb9 1372 : "," FormalParameterList { $$ = $2; }
cf7d4c69 1373 | { $$ = NULL; }
1dbba6cc
JF
1374 ;
1375
c8a0500b
JF
1376FormalParameterList
1377 // XXX: : FunctionRestParameter { $$ = $1; }
1378 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1379 ;
1380
55fc1817
JF
1381FormalParameterListOpt
1382 : FormalParameterList
1383 | { $$ = NULL; }
1384 ;
1385
c8a0500b
JF
1386/* XXX: FunctionRestParameter
1387 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1388 ;*/
1389
1390FormalParameter
1391 : BindingElement { $$ = $1; }
1392 ;
1393
36cd3cb9 1394FunctionBody
c8a0500b 1395 : StatementListOpt { $$ = $1; }
1dbba6cc 1396 ;
63cd45c9 1397/* }}} */
a7d8b413 1398/* 14.2 Arrow Function Definitions {{{ */
4b2fd91c 1399ArrowFunction
a0be43fc 1400 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
4b2fd91c
JF
1401 ;
1402
1403ArrowParameters
1404 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
a7d8b413 1405 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1->expression_->Parameter(); if ($$ == NULL) error(@1, "invalid parameter list"); }
4b2fd91c
JF
1406 ;
1407
1408ConciseBody
1409 : AssignmentExpression { $$ = CYNew CYReturn($1); }
440424e2 1410 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
4b2fd91c
JF
1411 ;
1412/* }}} */
a7d8b413
JF
1413/* 14.3+ Method Definitions {{{ */
1414/* }}} */
1415/* 14.4+ Generator Function Definitions {{{ */
1416/* }}} */
1417/* 14.5+ Class Definitions {{{ */
1418/* }}} */
1419
1420/* 15.1 Scripts {{{ */
1421Script
1422 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1dbba6cc
JF
1423 ;
1424
a7d8b413 1425ScriptBody
55fc1817
JF
1426 : StatementList { $$ = $1; }
1427 ;
1428
a7d8b413
JF
1429ScriptBodyOpt
1430 : ScriptBody { $$ = $1; }
5d660bed 1431 | LexSetStatement LexSetRegExp { $$ = NULL; }
1dbba6cc 1432 ;
63cd45c9 1433/* }}} */
a7d8b413
JF
1434/* 15.2+ Modules {{{ */
1435/* }}} */
1436/* 15.2.2+ Imports {{{ */
1437/* }}} */
1438/* 15.2.3+ Exports {{{ */
1439/* }}} */
e5332278 1440
7b750785
JF
1441@begin C
1442/* Cycript (C): Type Encoding {{{ */
663c538f 1443TypeSignifier
00b4cb83
JF
1444 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1445 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
663c538f
JF
1446 ;
1447
46f4f308 1448SuffixedType
00b4cb83 1449 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
3fe16be7 1450 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
00b4cb83
JF
1451 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1452 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1453 | TypeSignifier { $$ = $1; }
1454 | { $$ = CYNew CYTypedIdentifier(@$); }
46f4f308
JF
1455 ;
1456
1457PrefixedType
9a39f705 1458 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
46f4f308
JF
1459 ;
1460
663c538f 1461TypeQualifierLeft
3fe283c5
JF
1462 : { $$ = NULL; }
1463 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1464 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
663c538f
JF
1465 ;
1466
1467TypeQualifierRight
3fe283c5 1468 : PrefixedType { $$ = $1; }
9a39f705 1469 | SuffixedType { $$ = $1; }
3fe283c5
JF
1470 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1471 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1472 ;
1473
1474IntegerType
1475 : "int" { $$ = CYNew CYTypeVariable("int"); }
1476 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1477 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1478 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1479 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1480 ;
1481
1482IntegerTypeOpt
1483 : IntegerType { $$ = $1; }
22e0b32a 1484 | { $$ = CYNew CYTypeVariable("int"); }
56e02e5b
JF
1485 ;
1486
663c538f 1487PrimitiveType
3fe283c5
JF
1488 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1489 | IntegerType { $$ = $1; }
1490 | "void" { $$ = CYNew CYTypeVoid(); }
1491 | "char" { $$ = CYNew CYTypeVariable("char"); }
1492 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1493 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
46f4f308
JF
1494 ;
1495
1496TypedIdentifier
3fe283c5 1497 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
561e7f1c
JF
1498 ;
1499
46f4f308 1500PrimaryExpression
57d55714 1501 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
46f4f308
JF
1502 ;
1503/* }}} */
7b750785
JF
1504@end
1505
1506@begin ObjectiveC
4de0686f 1507/* Cycript (Objective-C): @class Declaration {{{ */
b09da87b 1508ClassSuperOpt
3ea7eed0
JF
1509 /* XXX: why the hell did I choose MemberExpression? */
1510 : ":" LexSetRegExp MemberExpression { $$ = $3; }
b09da87b
JF
1511 | { $$ = NULL; }
1512 ;
1513
cfd73c6d 1514ClassFieldListOpt
b6a67580 1515 : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYClassField($1, $3); }
70234143 1516 | LexSetRegExp { $$ = NULL; }
55fc1817
JF
1517 ;
1518
cfd73c6d
JF
1519ClassFields
1520 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1ba6903e
JF
1521 ;
1522
b09da87b
JF
1523MessageScope
1524 : "+" { $$ = false; }
1525 | "-" { $$ = true; }
1526 ;
1527
1528TypeOpt
104cc5f5
JF
1529 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) error($3->location_, "unexpected identifier"); $$ = $3; }
1530 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
b09da87b
JF
1531 ;
1532
1533MessageParameter
104cc5f5 1534 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
b09da87b
JF
1535 ;
1536
55fc1817
JF
1537MessageParameterList
1538 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1539 ;
1540
b09da87b
JF
1541MessageParameterListOpt
1542 : MessageParameterList { $$ = $1; }
1543 | { $$ = NULL; }
1544 ;
1545
b09da87b
JF
1546MessageParameters
1547 : MessageParameterList { $$ = $1; }
104cc5f5 1548 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
b09da87b
JF
1549 ;
1550
1551ClassMessageDeclaration
3ea7eed0 1552 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
b09da87b
JF
1553 ;
1554
1555ClassMessageDeclarationListOpt
4e8c99fb 1556 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
b09da87b
JF
1557 | { $$ = NULL; }
1558 ;
1559
e5bc40db
JF
1560ClassName
1561 : Identifier { $$ = $1; }
1562 | "(" AssignmentExpression ")" { $$ = $2; }
1563 ;
1564
367eebb1
JF
1565ClassNameOpt
1566 : ClassName { $$ = $1; }
1567 | { $$ = NULL; }
b09da87b
JF
1568 ;
1569
64b8d29f
JF
1570// XXX: this should be AssignmentExpressionNoRight
1571ClassProtocols
2eb8215d 1572 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
64b8d29f
JF
1573 ;
1574
1575ClassProtocolsOpt
1576 : "," ClassProtocols { $$ = $2; }
1577 | { $$ = NULL; }
1578 ;
1579
1580ClassProtocolListOpt
1581 : "<" ClassProtocols ">" { $$ = $2; }
1582 | { $$ = NULL; }
1583 ;
1584
fb98ac0c 1585ClassExpression
440424e2 1586 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
fb98ac0c
JF
1587 ;
1588
1589ClassStatement
cfd73c6d 1590 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1ba6903e
JF
1591 ;
1592
1593CategoryName
a630a9eb 1594 : "(" WordOpt ")"
367eebb1
JF
1595 ;
1596
1597CategoryStatement
3ea7eed0 1598 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
367eebb1
JF
1599 ;
1600
3ea7eed0 1601PrimaryExpression
fb98ac0c 1602 : ClassExpression { $$ = $1; }
367eebb1
JF
1603 ;
1604
3ea7eed0 1605Statement__
fb98ac0c 1606 : ClassStatement { $$ = $1; }
365abb0a 1607 | CategoryStatement { $$ = $1; }
b09da87b 1608 ;
cac61857 1609/* }}} */
4de0686f 1610/* Cycript (Objective-C): Send Message {{{ */
693d501b 1611VariadicCall
2eb8215d 1612 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
693d501b
JF
1613 | { $$ = NULL; }
1614 ;
1615
7e5391fd
JF
1616SelectorWordOpt
1617 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1618 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1619 ;
1620
55fc1817
JF
1621SelectorCall_
1622 : SelectorCall { $$ = $1; }
1623 | VariadicCall { $$ = $1; }
1624 ;
1625
693d501b 1626SelectorCall
02447eaf 1627 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
693d501b
JF
1628 ;
1629
1630SelectorList
1631 : SelectorCall { $$ = $1; }
2eb8215d 1632 | Word { $$ = CYNew CYArgument($1, NULL); }
693d501b
JF
1633 ;
1634
1635MessageExpression
440424e2
JF
1636 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1637 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
693d501b
JF
1638 ;
1639
e7ed5354 1640SelectorExpression_
2eb8215d 1641 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
e7ed5354
JF
1642 ;
1643
1644SelectorExpression
1645 : SelectorExpression_ { $$ = $1; }
2eb8215d 1646 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
e7ed5354
JF
1647 ;
1648
55fc1817
JF
1649SelectorExpressionOpt
1650 : SelectorExpression_ { $$ = $1; }
1651 | { $$ = NULL; }
1652 ;
1653
3ea7eed0 1654PrimaryExpression
693d501b 1655 : MessageExpression { $$ = $1; }
440424e2 1656 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
693d501b
JF
1657 ;
1658/* }}} */
7b750785
JF
1659@end
1660
1661/* Cycript: @import Directive {{{ */
417dcc12
JF
1662Module
1663 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1664 | Word { $$ = CYNew CYModule($1); }
1ba6903e
JF
1665 ;
1666
417dcc12
JF
1667Declaration__
1668 : "@import" Module { $$ = CYNew CYImport($2); }
1ba6903e
JF
1669 ;
1670/* }}} */
7b750785
JF
1671
1672@begin ObjectiveC
c3b144b8
JF
1673/* Cycript (Objective-C): Boxed Expressions {{{ */
1674BoxableExpression
1675 : NullLiteral { $$ = $1; }
1676 | BooleanLiteral { $$ = $1; }
1677 | NumericLiteral { $$ = $1; }
1678 | StringLiteral { $$ = $1; }
1679 | ArrayLiteral { $$ = $1; }
1680 | ObjectLiteral { $$ = $1; }
a7d8b413 1681 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
60496dd5
JF
1682 | "YES" { $$ = CYNew CYTrue(); }
1683 | "NO" { $$ = CYNew CYFalse(); }
c3b144b8
JF
1684 ;
1685
1686PrimaryExpression
1687 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
4ea461c0
JF
1688 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
1689 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
1690 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
1691 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
1692 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
c3b144b8
JF
1693 ;
1694/* }}} */
56e02e5b 1695/* Cycript (Objective-C): Block Expressions {{{ */
56e02e5b 1696PrimaryExpression
00b4cb83 1697 : "^" TypedIdentifier { if ($2->identifier_ != NULL) error($2->location_, "unexpected identifier"); } BRACE LexPushInOff FunctionBody "}" LexPopIn { if (CYTypeFunctionWith *function = $2->Function()) $$ = CYNew CYObjCBlock($2, function->parameters_, $6); else error($2->location_, "expected parameters"); }
56e02e5b
JF
1698 ;
1699/* }}} */
61769f4f
JF
1700/* Cycript (Objective-C): Instance Literals {{{ */
1701PrimaryExpression
ac9d4181 1702 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
61769f4f
JF
1703 ;
1704/* }}} */
4de0686f
JF
1705@end
1706
1707@begin C
1708/* Cycript (C): Pointer Indirection/Addressing {{{ */
9465b86d
JF
1709LeftHandSideExpression
1710 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
693d501b
JF
1711 ;
1712
1713UnaryExpression_
2eb8215d 1714 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
693d501b
JF
1715 ;
1716
9b5527f0 1717MemberAccess
2eb8215d 1718 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
5ccfc586 1719 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
7e5391fd 1720 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
9b5527f0 1721 ;
cac61857 1722/* }}} */
a87d7060
JF
1723/* Cycript (C): auto Compatibility {{{ */
1724Var_
1725 : "auto"
1726 ;
1727/* }}} */
690cf1a8
JF
1728/* Cycript (C): Lambda Expressions {{{ */
1729TypedParameterList_
1730 : "," TypedParameterList { $$ = $2; }
1731 | { $$ = NULL; }
1732 ;
1733
1734TypedParameterList
1735 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1736 ;
1737
1738TypedParameterListOpt
1739 : TypedParameterList { $$ = $1; }
1740 | { $$ = NULL; }
1741 ;
1742
1743PrimaryExpression
9a39f705 1744 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
690cf1a8
JF
1745 ;
1746/* }}} */
60097023
JF
1747/* Cycript (C): Type Definitions {{{ */
1748Statement__
00b4cb83 1749 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) error($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
60097023
JF
1750 ;
1751/* }}} */
c5587ed7
JF
1752/* Cycript (C): extern "C" {{{ */
1753Statement__
44fc505c 1754 : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) error(@2, "unknown extern binding"); } TypedIdentifier { if ($4->identifier_ == NULL) error($4->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($2, $4); }
c5587ed7
JF
1755 ;
1756/* }}} */
1757
4de0686f
JF
1758@end
1759
cb02f8ae 1760@begin E4X
691e4717
JF
1761/* Lexer State {{{ */
1762LexPushRegExp
1763 : { driver.PushCondition(CYDriver::RegExpCondition); }
1764 ;
1765
1766LexPushXMLContent
1767 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1768 ;
1769
1770LexPushXMLTag
1771 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1772 ;
1773
1774LexPop
1775 : { driver.PopCondition(); }
1776 ;
1777
1778LexSetXMLContent
1779 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1780 ;
1781
1782LexSetXMLTag
1783 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1784 ;
1785/* }}} */
c3b144b8 1786/* Virtual Tokens {{{ */
691e4717
JF
1787XMLWhitespaceOpt
1788 : XMLWhitespace
1789 |
1790 ;
c3b144b8 1791/* }}} */
691e4717
JF
1792
1793/* 8.1 Context Keywords {{{ */
1794Identifier
d6e7cafb
JF
1795 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
1796 | "xml" { $$ = CYNew CYIdentifier("xml"); }
691e4717
JF
1797 ;
1798/* }}} */
a7d8b413 1799/* 8.3 XML Initializer Input Elements {{{ */
cb02f8ae 1800XMLMarkup
691e4717
JF
1801 : XMLComment { $$ = $1; }
1802 | XMLCDATA { $$ = $1; }
1803 | XMLPI { $$ = $1; }
cb02f8ae
JF
1804 ;
1805/* }}} */
c3b144b8 1806
cb02f8ae 1807/* 11.1 Primary Expressions {{{ */
3ea7eed0 1808PrimaryExpression
2eb8215d 1809 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
691e4717
JF
1810 | XMLInitialiser { $$ = $1; }
1811 | XMLListInitialiser { $$ = $1; }
cb02f8ae
JF
1812 ;
1813
1814PropertyIdentifier
691e4717
JF
1815 : AttributeIdentifier { $$ = $1; }
1816 | QualifiedIdentifier { $$ = $1; }
1817 | WildcardIdentifier { $$ = $1; }
cb02f8ae
JF
1818 ;
1819/* }}} */
1820/* 11.1.1 Attribute Identifiers {{{ */
1821AttributeIdentifier
2eb8215d 1822 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
691e4717
JF
1823 ;
1824
1825PropertySelector_
b92ceddb 1826 : PropertySelector { $$ = $1; }
440424e2 1827 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
cb02f8ae
JF
1828 ;
1829
1830PropertySelector
2eb8215d 1831 : Identifier { $$ = CYNew CYSelector($1); }
691e4717 1832 | WildcardIdentifier { $$ = $1; }
cb02f8ae
JF
1833 ;
1834/* }}} */
1835/* 11.1.2 Qualified Identifiers {{{ */
691e4717 1836QualifiedIdentifier_
2eb8215d 1837 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
691e4717
JF
1838 | QualifiedIdentifier { $$ = $1; }
1839 ;
1840
cb02f8ae 1841QualifiedIdentifier
2eb8215d 1842 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
cb02f8ae
JF
1843 ;
1844/* }}} */
1845/* 11.1.3 Wildcard Identifiers {{{ */
1846WildcardIdentifier
2eb8215d 1847 : "*" { $$ = CYNew CYWildcard(); }
cb02f8ae
JF
1848 ;
1849/* }}} */
a7d8b413 1850/* 11.1.4 XML Initializer {{{ */
cb02f8ae 1851XMLInitialiser
691e4717
JF
1852 : XMLMarkup { $$ = $1; }
1853 | XMLElement { $$ = $1; }
cb02f8ae
JF
1854 ;
1855
1856XMLElement
440424e2
JF
1857 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1858 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
cb02f8ae
JF
1859 ;
1860
1861XMLTagContent
0347fadf 1862 : LexPushXMLTag XMLTagName XMLAttributes
cb02f8ae
JF
1863 ;
1864
691e4717 1865XMLExpression
3ea7eed0 1866 : BRACE LexPushRegExp Expression LexPop "}"
691e4717
JF
1867 ;
1868
cb02f8ae 1869XMLTagName
691e4717 1870 : XMLExpression
cb02f8ae
JF
1871 | XMLName
1872 ;
1873
0347fadf
JF
1874XMLAttributes_
1875 : XMLAttributes_ XMLAttribute
1876 |
cb02f8ae
JF
1877 ;
1878
0347fadf
JF
1879XMLAttributes
1880 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1881 | XMLAttributes_ XMLWhitespaceOpt
cb02f8ae
JF
1882 ;
1883
691e4717
JF
1884XMLAttributeValue_
1885 : XMLExpression
1886 | XMLAttributeValue
1887 ;
1888
cb02f8ae 1889XMLAttribute
691e4717 1890 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
cb02f8ae
JF
1891 ;
1892
cb02f8ae 1893XMLElementContent
691e4717 1894 : XMLExpression XMLElementContentOpt
cb02f8ae
JF
1895 | XMLMarkup XMLElementContentOpt
1896 | XMLText XMLElementContentOpt
1897 | XMLElement XMLElementContentOpt
1898 ;
1899
1900XMLElementContentOpt
1901 : XMLElementContent
1902 |
1903 ;
1904/* }}} */
a7d8b413 1905/* 11.1.5 XMLList Initializer {{{ */
cb02f8ae 1906XMLListInitialiser
440424e2 1907 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
691e4717
JF
1908 ;
1909/* }}} */
c3b144b8 1910
691e4717
JF
1911/* 11.2 Left-Hand-Side Expressions {{{ */
1912PropertyIdentifier_
0347fadf 1913 : Identifier { $$ = $1; }
691e4717
JF
1914 | PropertyIdentifier { $$ = $1; }
1915 ;
1916
1917MemberAccess
2eb8215d
JF
1918 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1919 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1920 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
691e4717
JF
1921 ;
1922/* }}} */
1923/* 12.1 The default xml namespace Statement {{{ */
b92ceddb 1924/* XXX: DefaultXMLNamespaceStatement
2eb8215d 1925 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
691e4717
JF
1926 ;
1927
3ea7eed0 1928Statement__
691e4717 1929 : DefaultXMLNamespaceStatement { $$ = $1; }
b92ceddb 1930 ; */
cb02f8ae
JF
1931/* }}} */
1932@end
1933
a7d8b413 1934/* JavaScript FTL: Array Comprehensions {{{ */
b3aa25d8
JF
1935Comprehension
1936 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
367eebb1
JF
1937 ;
1938
b3aa25d8
JF
1939ComprehensionFor
1940 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1941 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
367eebb1 1942 ;
cac61857 1943/* }}} */
a7d8b413 1944/* JavaScript FTL: for each {{{ */
d5618df7 1945IterationStatement
a7d8b413 1946 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
cac61857
JF
1947 ;
1948/* }}} */
a7d8b413 1949/* JavaScript FTL: let Statements {{{ */
cac61857 1950LetStatement
c8a0500b 1951 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
cac61857
JF
1952 ;
1953
3ea7eed0 1954Statement__
cac61857
JF
1955 : LetStatement
1956 ;
15b88a33 1957/* }}} */
4e11a430 1958
a7d8b413
JF
1959/* JavaScript FTW: Array Comprehensions {{{ */
1960PrimaryExpression
1961 : ArrayComprehension
1962 ;
1963
1964ArrayComprehension
1965 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
1966 ;
1967
1968Comprehension
1969 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
1970 ;
1971
1972ComprehensionTail
1973 : { $$ = NULL; }
1974 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
1975 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
1976 ;
1977
1978ComprehensionFor
1979 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
1980 ;
1981
1982ComprehensionIf
1983 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
1984 ;
1985/* }}} */
1986/* JavaScript FTW: Coalesce Operator {{{ */
1987ConditionalExpression
1988 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1989 ;
1990/* }}} */
6c093cce
JF
1991/* JavaScript FTW: Ruby Blocks {{{ */
1992RubyProcParameterList_
1993 : "," RubyProcParameterList { $$ = $2; }
1994 | { $$ = NULL; }
1995 ;
1996
1997RubyProcParameterList
c8a0500b 1998 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
6c093cce
JF
1999 | { $$ = NULL; }
2000 ;
2001
d7205a63 2002RubyProcParameters
6c093cce 2003 : "|" RubyProcParameterList "|" { $$ = $2; }
d7205a63
JF
2004 | "||" { $$ = NULL; }
2005 ;
2006
2007RubyProcParametersOpt
2008 : RubyProcParameters
6c093cce
JF
2009 | { $$ = NULL; }
2010 ;
2011
2012RubyProcExpression
2eb8215d 2013 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
6c093cce
JF
2014 ;
2015
3ea7eed0 2016PrimaryExpression
440424e2 2017 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
6c093cce
JF
2018 ;
2019
3ea7eed0
JF
2020CallExpression
2021 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
6c093cce 2022 ;
6c093cce 2023/* }}} */
367eebb1 2024
e5332278 2025%%