From fdb013ca56e05d5576738154e72d83e720eccf33 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 1 Nov 2009 08:13:58 +0000 Subject: [PATCH] Removed the WC explosion from the grammar, this problem has been solved by operator precedence. --- Cycript.y.in | 192 ++------------------------------------------------- 1 file changed, 5 insertions(+), 187 deletions(-) diff --git a/Cycript.y.in b/Cycript.y.in index dde7908..79d277d 100644 --- a/Cycript.y.in +++ b/Cycript.y.in @@ -307,27 +307,6 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %token XML "xml" @end -@begin ObjectiveC -%type AdditiveExpressionNoWC -%type AssigneeExpressionNoWC -%type AssignmentExpressionNoWC -%type BitwiseANDExpressionNoWC -%type BitwiseXORExpressionNoWC -%type BitwiseORExpressionNoWC -%type ConditionalExpressionNoWC -%type EqualityExpressionNoWC -%type LeftHandSideExpressionNoWC -%type LogicalANDExpressionNoWC -%type LogicalORExpressionNoWC -%type MemberExpressionNoWC -%type MultiplicativeExpressionNoWC -%type NewExpressionNoWC -%type PostfixExpressionNoWC -%type RelationalExpressionNoWC -%type ShiftExpressionNoWC -%type UnaryExpressionNoWC -@end - %token Identifier_ %token NumericLiteral %token StringLiteral @@ -446,11 +425,6 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type PrimaryExpressionNo %type PrimaryExpressionNoBF %type PrimaryExpressionNoRE -%type PrimaryExpressionNoWC -%type PrimaryExpressionNoWC_ -@begin E4X -%type PrimaryExpressionWC -@end %type PrimaryExpressionBF %type Program %type PropertyName @@ -540,8 +514,6 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type 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" @@ -716,35 +688,18 @@ BooleanLiteral /* 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); } @@ -841,15 +796,6 @@ MemberExpressionNoRE | MemberExpression_ { $$ = $1; } ; -@begin ObjectiveC -MemberExpressionNoWC - : PrimaryExpression { $$ = $1; } - | LexSetRegExp FunctionExpression { $$ = $2; } - | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; } - | LexSetRegExp MemberExpression_ { $$ = $2; } - ; -@end - NewExpression_ : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); } ; @@ -869,15 +815,8 @@ NewExpressionNoRE | 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; } ; @@ -889,7 +828,7 @@ CallExpressionNoBF ; 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; } ; @@ -926,13 +865,6 @@ LeftHandSideExpressionNoRE : NewExpressionNoRE { $$ = $1; } | CallExpressionNoRE { $$ = $1; } ; - -@begin ObjectiveC -LeftHandSideExpressionNoWC - : NewExpressionNoWC { $$ = $1; } - | CallExpression { $$ = $1; } - ; -@end /* }}} */ /* 11.3 Postfix Expressions {{{ */ PostfixExpression @@ -952,14 +884,6 @@ PostfixExpressionNoRE | 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_ @@ -990,13 +914,6 @@ UnaryExpressionNoRE : PostfixExpressionNoRE { $$ = $1; } | UnaryExpression_ { $$ = $1; } ; - -@begin ObjectiveC -UnaryExpressionNoWC - : PostfixExpressionNoWC { $$ = $1; } - | LexSetRegExp UnaryExpression_ { $$ = $2; } - ; -@end /* }}} */ /* 11.5 Multiplicative Operators {{{ */ MultiplicativeExpression @@ -1012,15 +929,6 @@ MultiplicativeExpressionNoBF | 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 @@ -1034,14 +942,6 @@ AdditiveExpressionNoBF | 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 @@ -1057,15 +957,6 @@ ShiftExpressionNoBF | 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_ @@ -1095,13 +986,6 @@ RelationalExpressionNoBF : 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 @@ -1127,16 +1011,6 @@ EqualityExpressionNoBF | 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 @@ -1154,13 +1028,6 @@ BitwiseANDExpressionNoBF | 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); } @@ -1176,13 +1043,6 @@ BitwiseXORExpressionNoBF | 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); } @@ -1197,13 +1057,6 @@ BitwiseORExpressionNoBF : 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 @@ -1221,13 +1074,6 @@ LogicalANDExpressionNoBF | 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); } @@ -1242,13 +1088,6 @@ LogicalORExpressionNoBF : 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 @@ -1265,13 +1104,6 @@ ConditionalExpressionNoBF : 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_ @@ -1304,13 +1136,6 @@ AssigneeExpressionNoRE | UnaryAssigneeExpression { $$ = $1; } ; -@begin ObjectiveC -AssigneeExpressionNoWC - : LeftHandSideExpressionNoWC { $$ = $1; } - | LexSetRegExp UnaryAssigneeExpression { $$ = $2; } - ; -@end - AssignmentExpression : ConditionalExpression { $$ = $1; } | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } @@ -1336,13 +1161,6 @@ AssignmentExpressionNoBF : 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_ @@ -1741,7 +1559,7 @@ SelectorList ; 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); } ; @@ -1829,7 +1647,7 @@ XMLMarkup ; /* }}} */ /* 11.1 Primary Expressions {{{ */ -PrimaryExpressionWC +PrimaryExpressionNo : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); } | XMLInitialiser { $$ = $1; } | XMLListInitialiser { $$ = $1; } -- 2.45.2