CYNumber *number_;
CYParameter *parameter_;
CYProperty *property_;
+ CYSelectorPart *selector_;
CYSource *source_;
CYStatement *statement_;
CYString *string_;
%token OpenBracket "["
%token CloseBracket "]"
+%token AtSelector "@selector"
+
%token <word_> Break "break"
%token <word_> Case "case"
%token <word_> Catch "catch"
%type <clause_> DefaultClause
%type <statement_> DoWhileStatement
%type <expression_> Element
+%type <expression_> ElementOpt
%type <element_> ElementList
-%type <element_> ElementList_
+%type <element_> ElementListOpt
%type <statement_> ElseStatementOpt
%type <statement_> EmptyStatement
%type <expression_> EqualityExpression
%type <expression_> RelationalExpressionNoBF
%type <expression_> RelationalExpressionNoIn
%type <statement_> ReturnStatement
+%type <selector_> SelectorExpression
+%type <selector_> SelectorExpression_
+%type <selector_> SelectorExpressionOpt
%type <expression_> ShiftExpression
%type <expression_> ShiftExpressionNoBF
%type <source_> SourceElement
TerminatorOpt
: ";"
| "\n"
- | error { yyerrok; }
+ | error { yyerrok; driver.errors_.pop_back(); }
;
Terminator
: ";"
| "\n"
- | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else yyerrok; }
+ | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } }
;
CommaOpt
/* }}} */
/* 11.1.4 Array Initialiser {{{ */
ArrayLiteral
- : "[" ElementList "]" { $$ = $2; }
+ : "[" ElementList "]" { $$ = new(driver.pool_) CYArray($2); }
;
Element
: AssignmentExpression { $$ = $1; }
+ ;
+
+ElementOpt
+ : Element { $$ = $1; }
| { $$ = NULL; }
;
-ElementList_
- : "," ElementList { $$ = $2; }
+ElementListOpt
+ : ElementList { $$ = $1; }
| { $$ = NULL; }
;
ElementList
- : Element ElementList_ { $$ = new(driver.pool_) CYElement($1, $2); }
+ : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
+ | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
;
/* }}} */
/* 11.1.5 Object Initialiser {{{ */
ObjectLiteral
- : "{" PropertyNameAndValueListOpt "}" { $$ = new CYObject($2); }
+ : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
;
PropertyNameAndValueList_
;
Block
- : "{" "}" { $$ = new(driver.pool_) CYEmpty(); }
- | "{" StatementList "}" { $$ = $2; }
+ : "{" StatementListOpt "}" { $$ = $2 ?: new(driver.pool_) CYEmpty(); }
;
StatementList
;
Program
- : SourceElements { driver.source_.push_back($1); $$ = $1; }
+ : SourceElements { driver.source_ = $1; }
;
SourceElements
| { $$ = NULL; }
;
-/*Command
- : SourceElement { driver.source_.push_back($2); if (driver.filename_.empty() && false) YYACCEPT; $2->Show(std::cout); }
- ;*/
-
SourceElement
: Statement { $$ = $1; }
| FunctionDeclaration { $$ = $1; }
: "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYMessage($2, $3); }
;
+SelectorExpressionOpt
+ : SelectorExpression_ { $$ = $1; }
+ | { $$ = NULL; }
+ ;
+
+SelectorExpression_
+ : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
+ ;
+
+SelectorExpression
+ : SelectorExpression_ { $$ = $1; }
+ | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
+ ;
+
PrimaryExpression_
: MessageExpression { $$ = $1; }
+ | "@selector" "(" SelectorExpression ")" { $$ = new CYSelector($3); }
;
/* }}} */