%union { CYBinding *binding_; }
%union { CYBindings *bindings_; }
%union { CYBoolean *boolean_; }
+%union { CYBraced *braced_; }
%union { CYClause *clause_; }
%union { cy::Syntax::Catch *catch_; }
%union { CYClassTail *classTail_; }
%union { CYParenthetical *parenthetical_; }
%union { CYProperty *property_; }
%union { CYPropertyName *propertyName_; }
-%union { CYRubyProc *rubyProc_; }
%union { CYSpan *span_; }
%union { CYStatement *statement_; }
%union { CYString *string_; }
%type <binding_> BindingElement
%type <expression_> BitwiseORExpression
%type <expression_> BitwiseXORExpression
+%type <target_> BracedExpression_
+%type <target_> BracedExpression
%type <statement_> BreakStatement
%type <statement_> BreakableStatement
%type <expression_> CallExpression_
%type <bool_> RegularExpressionSlash
%type <expression_> RelationalExpression
%type <statement_> ReturnStatement
-%type <target_> RubyBlockExpression_
-%type <target_> RubyBlockExpression
-%type <rubyProc_> RubyProcExpression
+%type <braced_> BracedParameter
%type <functionParameter_> RubyProcParameterList_
%type <functionParameter_> RubyProcParameterList
%type <functionParameter_> RubyProcParameters
;
LeftHandSideExpression
- : RubyBlockExpression[pass] { $$ = $pass; }
+ : BracedExpression[pass] { $$ = $pass; }
| IndirectExpression[pass] { $$ = $pass; }
;
/* }}} */
/* 12.4 Postfix Expressions {{{ */
PostfixExpression
- : RubyBlockExpression[pass] { $$ = $pass; }
+ : BracedExpression[pass] { $$ = $pass; }
| AccessExpression[lhs] LexNewLineOrOpt "++" { $$ = CYNew CYPostIncrement($lhs); }
| AccessExpression[lhs] LexNewLineOrOpt "--" { $$ = CYNew CYPostDecrement($lhs); }
;
;
ForInStatementInitializer
- : LexLet LexOf RubyBlockExpression[pass] { $$ = $pass; }
+ : LexLet LexOf BracedExpression[pass] { $$ = $pass; }
| LexLet LexOf IndirectExpression[pass] { $$ = $pass; }
| LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
| ForDeclaration[pass] { $$ = $pass; }
: LexOf WordNoUnary[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); }
;
/* }}} */
+/* JavaScript FTW: Subscript Access {{{ */
+MemberAccess
+ : "." "[" AssignmentExpression[property] "]" { $$ = CYNew CYSubscriptMember(NULL, $property); }
+ ;
+/* }}} */
+
+/* JavaScript FTW: Java "Anonymous Inner Classes" {{{ */
+BracedParameter
+ : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYExtend(NULL, $properties); }
+ ;
+/* }}} */
/* JavaScript FTW: Ruby Blocks {{{ */
RubyProcParameterList_
| { $$ = NULL; }
;
-RubyProcExpression
- : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
+BracedParameter
+ : ";{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyBlock(NULL, CYNew CYRubyProc($parameters, $code)); }
;
PrimaryExpression
: "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
;
-RubyBlockExpression_
+BracedExpression_
: AccessExpression[pass] LexNewLineOrOpt { $$ = $pass; }
- | RubyBlockExpression_[lhs] RubyProcExpression[rhs] LexNewLineOrOpt { $$ = CYNew CYRubyBlock($lhs, $rhs); }
+ | BracedExpression_[lhs] { if (!$lhs->IsNew()) CYMAP(OpenBrace_, OpenBrace); } BracedParameter[rhs] LexNewLineOrOpt { $rhs->SetLeft($lhs); $$ = $rhs; }
;
-RubyBlockExpression
- : RubyBlockExpression_[pass] "\n" { $$ = $pass; }
- | RubyBlockExpression_[pass] { $$ = $pass; }
+BracedExpression
+ : BracedExpression_[pass] "\n" { $$ = $pass; }
+ | BracedExpression_[pass] { $$ = $pass; }
;
/* }}} */
/* JavaScript FTW: Ruby Scopes {{{ */