CYBoolean *boolean_;
CYClause *clause_;
cy::Syntax::Catch *catch_;
+ CYComment *comment_;
CYComprehension *comprehension_;
CYCompound *compound_;
CYDeclaration *declaration_;
CYField *field_;
CYMessage *message_;
CYMessageParameter *messageParameter_;
+ CYProtocol *protocol_;
CYSelectorPart *selector_;
@end
%token SemiColon ";"
%token NewLine "\n"
+%token <comment_> Comment
+
%token OpenParen "("
%token CloseParen ")"
%token <identifier_> XML "xml"
@end
-@begin ObjectiveC
-%type <expression_> AdditiveExpressionNoWC
-%type <expression_> AssigneeExpressionNoWC
-%type <expression_> AssignmentExpressionNoWC
-%type <expression_> BitwiseANDExpressionNoWC
-%type <expression_> BitwiseXORExpressionNoWC
-%type <expression_> BitwiseORExpressionNoWC
-%type <expression_> ConditionalExpressionNoWC
-%type <expression_> EqualityExpressionNoWC
-%type <expression_> LeftHandSideExpressionNoWC
-%type <expression_> LogicalANDExpressionNoWC
-%type <expression_> LogicalORExpressionNoWC
-%type <expression_> MemberExpressionNoWC
-%type <expression_> MultiplicativeExpressionNoWC
-%type <expression_> NewExpressionNoWC
-%type <expression_> PostfixExpressionNoWC
-%type <expression_> RelationalExpressionNoWC
-%type <expression_> ShiftExpressionNoWC
-%type <expression_> UnaryExpressionNoWC
-@end
-
%token <identifier_> Identifier_
%token <number_> NumericLiteral
%token <string_> StringLiteral
%type <literal_> ArrayLiteral
%type <expression_> AssigneeExpression
%type <expression_> AssigneeExpressionNoBF
-%type <expression_> AssigneeExpressionNoRE
%type <expression_> AssignmentExpression
%type <assignment_> AssignmentExpression_
%type <expression_> AssignmentExpressionNoBF
%type <statement_> BreakStatement
%type <expression_> CallExpression
%type <expression_> CallExpressionNoBF
-%type <expression_> CallExpressionNoRE
%type <clause_> CaseBlock
%type <clause_> CaseClause
%type <clause_> CaseClausesOpt
%type <statement_> LabelledStatement
%type <expression_> LeftHandSideExpression
%type <expression_> LeftHandSideExpressionNoBF
-%type <expression_> LeftHandSideExpressionNoRE
//%type <statement_> LetStatement
%type <literal_> Literal
%type <literal_> LiteralNoRE
%type <expression_> MemberExpression
%type <expression_> MemberExpression_
%type <expression_> MemberExpressionNoBF
-%type <expression_> MemberExpressionNoRE
%type <expression_> MultiplicativeExpression
%type <expression_> MultiplicativeExpressionNoBF
%type <expression_> NewExpression
%type <expression_> NewExpression_
%type <expression_> NewExpressionNoBF
-%type <expression_> NewExpressionNoRE
%type <null_> NullLiteral
%type <literal_> ObjectLiteral
%type <expression_> PostfixExpression
%type <expression_> PostfixExpressionNoBF
-%type <expression_> PostfixExpressionNoRE
%type <expression_> PrimaryExpression
%type <expression_> PrimaryExpressionNo
%type <expression_> PrimaryExpressionNoBF
%type <expression_> PrimaryExpressionNoRE
-%type <expression_> PrimaryExpressionNoWC
-%type <expression_> PrimaryExpressionNoWC_
-@begin E4X
-%type <expression_> PrimaryExpressionWC
-@end
%type <expression_> PrimaryExpressionBF
%type <statement_> Program
%type <propertyName_> PropertyName
%type <statement_> SwitchStatement
%type <statement_> ThrowStatement
%type <statement_> TryStatement
-%type <expression_> UnaryAssigneeExpression
%type <expression_> UnaryExpression
%type <expression_> UnaryExpression_
%type <expression_> UnaryExpressionNoBF
-%type <expression_> UnaryExpressionNoRE
%type <declaration_> VariableDeclaration
%type <declaration_> VariableDeclarationNoIn
%type <declarations_> VariableDeclarationList
%type <statement_> WhileStatement
%type <statement_> WithStatement
+@begin C
+%type <expression_> AssigneeExpressionNoRE
+%type <expression_> CallExpressionNoRE
+%type <expression_> LeftHandSideExpressionNoRE
+%type <expression_> MemberExpressionNoRE
+%type <expression_> NewExpressionNoRE
+%type <expression_> PostfixExpressionNoRE
+%type <expression_> UnaryAssigneeExpression
+%type <expression_> UnaryExpressionNoRE
+@end
+
@begin ObjectiveC
%type <statement_> CategoryStatement
%type <expression_> ClassExpression
%type <message_> ClassMessageDeclarationListOpt
%type <className_> ClassName
%type <className_> ClassNameOpt
+%type <protocol_> ClassProtocolListOpt
+%type <protocol_> ClassProtocols
+%type <protocol_> ClassProtocolsOpt
%type <expression_> MessageExpression
%type <messageParameter_> MessageParameter
%type <messageParameter_> MessageParameters
%type <expression_> XMLInitialiser
@end
-%token WC
-
%nonassoc Identifier_ "abstract" "boolean" "break" "byte" "case" "catch" "char" "class" "const" "continue" "debugger" "default" "delete" "do" "double" "each" "enum" "export" "extends" "false" "final" "finally" "float" /*"for"*/ "function" "goto" "implements" "import" /*"in"*/ /*"instanceof"*/ "int" "interface" "let" "long" "namespace" "native" "new" "null" "package" "private" "protected" "public" "return" "short" "super" "static" "switch" "synchronized" "this" "throw" "throws" "transient" "true" "try" "typeof" "var" "void" "volatile" "while" "with" "xml" "yield"
%nonassoc "if"
/* 11.1 Primary Expressions {{{ */
PrimaryExpression
- : PrimaryExpressionNoWC { $$ = $1; }
-@begin E4X
- | LexSetRegExp PrimaryExpressionWC { $$ = $2; }
-@end
+ : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
;
PrimaryExpressionNoBF
: PrimaryExpressionNo { $$ = $1; }
-@begin E4X
- | PrimaryExpressionWC { $$ = $1; }
-@end
;
PrimaryExpressionNoRE
- : PrimaryExpressionNoWC_ { $$ = $1; }
-@begin E4X
- | PrimaryExpressionWC { $$ = $1; }
-@end
- ;
-
-PrimaryExpressionNoWC_
: PrimaryExpressionBF { $$ = $1; }
| PrimaryExpressionNo { $$ = $1; }
;
-PrimaryExpressionNoWC
- : LexSetRegExp PrimaryExpressionNoWC_ { $$ = $2; }
- ;
-
PrimaryExpressionNo
: "this" { $$ = $1; }
| Identifier { $$ = new(driver.pool_) CYVariable($1); }
| MemberExpression_ { $$ = $1; }
;
+@begin C
MemberExpressionNoRE
: PrimaryExpressionNoRE { $$ = $1; }
| FunctionExpression { $$ = $1; }
| MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
| MemberExpression_ { $$ = $1; }
;
-
-@begin ObjectiveC
-MemberExpressionNoWC
- : PrimaryExpression { $$ = $1; }
- | LexSetRegExp FunctionExpression { $$ = $2; }
- | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
- | LexSetRegExp MemberExpression_ { $$ = $2; }
- ;
@end
NewExpression_
| NewExpression_ { $$ = $1; }
;
+@begin C
NewExpressionNoRE
: MemberExpressionNoRE { $$ = $1; }
| NewExpression_ { $$ = $1; }
;
-
-@begin ObjectiveC
-NewExpressionNoWC
- : MemberExpressionNoWC { $$ = $1; }
- | LexSetRegExp NewExpression_ { $$ = $2; }
- ;
@end
CallExpression
- : PrimaryExpressionNoWC Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
+ : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
| CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
| CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
;
| CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
;
+@begin C
CallExpressionNoRE
- : PrimaryExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
+ : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
| CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
| CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
;
+@end
ArgumentList_
: "," ArgumentList { $$ = $2; }
| CallExpressionNoBF { $$ = $1; }
;
+@begin C
LeftHandSideExpressionNoRE
: NewExpressionNoRE { $$ = $1; }
| CallExpressionNoRE { $$ = $1; }
;
-
-@begin ObjectiveC
-LeftHandSideExpressionNoWC
- : NewExpressionNoWC { $$ = $1; }
- | CallExpression { $$ = $1; }
- ;
@end
/* }}} */
/* 11.3 Postfix Expressions {{{ */
| LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
;
+@begin C
PostfixExpressionNoRE
: AssigneeExpressionNoRE { $$ = $1; }
| LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
| LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
;
-
-@begin ObjectiveC
-PostfixExpressionNoWC
- : AssigneeExpressionNoWC { $$ = $1; }
- | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
- | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
- ;
@end
/* }}} */
/* 11.4 Unary Operators {{{ */
| UnaryExpression_ { $$ = $1; }
;
+@begin C
UnaryExpressionNoRE
: PostfixExpressionNoRE { $$ = $1; }
| UnaryExpression_ { $$ = $1; }
;
-
-@begin ObjectiveC
-UnaryExpressionNoWC
- : PostfixExpressionNoWC { $$ = $1; }
- | LexSetRegExp UnaryExpression_ { $$ = $2; }
- ;
@end
/* }}} */
/* 11.5 Multiplicative Operators {{{ */
| MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
| MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
;
-
-@begin ObjectiveC
-MultiplicativeExpressionNoWC
- : UnaryExpressionNoWC { $$ = $1; }
- | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
- | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
- | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
- ;
-@end
/* }}} */
/* 11.6 Additive Operators {{{ */
AdditiveExpression
| AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
| AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
;
-
-@begin ObjectiveC
-AdditiveExpressionNoWC
- : MultiplicativeExpressionNoWC { $$ = $1; }
- | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
- | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
- ;
-@end
/* }}} */
/* 11.7 Bitwise Shift Operators {{{ */
ShiftExpression
| ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
| ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
;
-
-@begin ObjectiveC
-ShiftExpressionNoWC
- : AdditiveExpressionNoWC { $$ = $1; }
- | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
- | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
- | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
- ;
-@end
/* }}} */
/* 11.8 Relational Operators {{{ */
RelationalExpressionNoIn_
: ShiftExpressionNoBF { $$ = $1; }
| RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
;
-
-@begin ObjectiveC
-RelationalExpressionNoWC
- : ShiftExpressionNoWC { $$ = $1; }
- | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
- ;
-@end
/* }}} */
/* 11.9 Equality Operators {{{ */
EqualityExpression
| EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
| EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
;
-
-@begin ObjectiveC
-EqualityExpressionNoWC
- : RelationalExpressionNoWC { $$ = $1; }
- | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
- | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
- | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
- | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
- ;
-@end
/* }}} */
/* 11.10 Binary Bitwise Operators {{{ */
BitwiseANDExpression
| BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
;
-@begin ObjectiveC
-BitwiseANDExpressionNoWC
- : EqualityExpressionNoWC { $$ = $1; }
- | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
- ;
-@end
-
BitwiseXORExpression
: BitwiseANDExpression { $$ = $1; }
| BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
| BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
;
-@begin ObjectiveC
-BitwiseXORExpressionNoWC
- : BitwiseANDExpressionNoWC { $$ = $1; }
- | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
- ;
-@end
-
BitwiseORExpression
: BitwiseXORExpression { $$ = $1; }
| BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
: BitwiseXORExpressionNoBF { $$ = $1; }
| BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
;
-
-@begin ObjectiveC
-BitwiseORExpressionNoWC
- : BitwiseXORExpressionNoWC { $$ = $1; }
- | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
- ;
-@end
/* }}} */
/* 11.11 Binary Logical Operators {{{ */
LogicalANDExpression
| LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
;
-@begin ObjectiveC
-LogicalANDExpressionNoWC
- : BitwiseORExpressionNoWC { $$ = $1; }
- | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
- ;
-@end
-
LogicalORExpression
: LogicalANDExpression { $$ = $1; }
| LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
: LogicalANDExpressionNoBF { $$ = $1; }
| LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
;
-
-@begin ObjectiveC
-LogicalORExpressionNoWC
- : LogicalANDExpressionNoWC { $$ = $1; }
- | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
- ;
-@end
/* }}} */
/* 11.12 Conditional Operator ( ? : ) {{{ */
ConditionalExpression
: LogicalORExpressionNoBF { $$ = $1; }
| LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
;
-
-@begin ObjectiveC
-ConditionalExpressionNoWC
- : LogicalORExpressionNoWC { $$ = $1; }
- | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
- ;
-@end
/* }}} */
/* 11.13 Assignment Operators {{{ */
AssignmentExpression_
AssigneeExpression
: LeftHandSideExpression { $$ = $1; }
+@begin C
| LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
+@end
;
AssigneeExpressionNoBF
: LeftHandSideExpressionNoBF { $$ = $1; }
+@begin C
| UnaryAssigneeExpression { $$ = $1; }
+@end
;
+@begin C
AssigneeExpressionNoRE
: LeftHandSideExpressionNoRE { $$ = $1; }
| UnaryAssigneeExpression { $$ = $1; }
;
-
-@begin ObjectiveC
-AssigneeExpressionNoWC
- : LeftHandSideExpressionNoWC { $$ = $1; }
- | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
- ;
@end
AssignmentExpression
: ConditionalExpressionNoBF { $$ = $1; }
| AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
;
-
-@begin ObjectiveC
-AssignmentExpressionNoWC
- : ConditionalExpressionNoWC { $$ = $1; }
- | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
- ;
-@end
/* }}} */
/* 11.14 Comma Operator {{{ */
Expression_
| { $$ = NULL; }
;
+// XXX: this should be AssignmentExpressionNoRight
+ClassProtocols
+ : ShiftExpression ClassProtocolsOpt { $$ = new(driver.pool_) CYProtocol($1, $2); }
+ ;
+
+ClassProtocolsOpt
+ : "," ClassProtocols { $$ = $2; }
+ | { $$ = NULL; }
+ ;
+
+ClassProtocolListOpt
+ : "<" ClassProtocols ">" { $$ = $2; }
+ | { $$ = NULL; }
+ ;
+
ClassExpression
- : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); }
+ : "@class" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5, $6); }
;
ClassStatement
- : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); }
+ : "@class" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5, $6); }
;
CategoryStatement
;
MessageExpression
- : "[" AssignmentExpressionNoWC SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
+ : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
| "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
;
/* }}} */
@end
+/* YUI: Documentation Comments {{{ */
+Statement_
+ : Comment { $$ = $1; }
+ ;
+/* }}} */
+
@begin E4X
/* Lexer State {{{ */
LexPushRegExp
;
/* }}} */
/* 11.1 Primary Expressions {{{ */
-PrimaryExpressionWC
+PrimaryExpressionNo
: PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
| XMLInitialiser { $$ = $1; }
| XMLListInitialiser { $$ = $1; }