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