X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/b92ceddb344ea82a067100ab116ff59d7f7c96f3..0226d428e0b3b0913a0c067f86cbf90339cd4c92:/Cycript.y.in?ds=inline diff --git a/Cycript.y.in b/Cycript.y.in index 1789d47..79d277d 100644 --- a/Cycript.y.in +++ b/Cycript.y.in @@ -153,11 +153,14 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %token SlashRight "/>" %token LeftSlash " AdditiveExpression %type AdditiveExpressionNoBF -%type AdditiveExpressionNoWC %type ArgumentList %type ArgumentList_ %type ArgumentListOpt @@ -319,30 +321,27 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type ArrayLiteral %type AssigneeExpression %type AssigneeExpressionNoBF -%type AssigneeExpressionNoWC +%type AssigneeExpressionNoRE %type AssignmentExpression %type AssignmentExpression_ %type AssignmentExpressionNoBF %type AssignmentExpressionNoIn -%type AssignmentExpressionNoWC %type BitwiseANDExpression %type BitwiseANDExpressionNoBF %type BitwiseANDExpressionNoIn -%type BitwiseANDExpressionNoWC %type Block %type Block_ %type BooleanLiteral %type BitwiseORExpression %type BitwiseORExpressionNoBF %type BitwiseORExpressionNoIn -%type BitwiseORExpressionNoWC %type BitwiseXORExpression %type BitwiseXORExpressionNoBF %type BitwiseXORExpressionNoIn -%type BitwiseXORExpressionNoWC %type BreakStatement %type CallExpression %type CallExpressionNoBF +%type CallExpressionNoRE %type CaseBlock %type CaseClause %type CaseClausesOpt @@ -352,7 +351,6 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type ConditionalExpression %type ConditionalExpressionNoBF %type ConditionalExpressionNoIn -%type ConditionalExpressionNoWC %type ContinueStatement %type DefaultClause %type DoWhileStatement @@ -365,7 +363,6 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type EqualityExpression %type EqualityExpressionNoBF %type EqualityExpressionNoIn -%type EqualityExpressionNoWC %type Expression %type ExpressionOpt %type Expression_ @@ -385,7 +382,6 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type FunctionBody %type FunctionDeclaration %type FunctionExpression -%type FunctionExpression_ %type Identifier %type IdentifierOpt %type IfComprehension @@ -398,7 +394,7 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type LabelledStatement %type LeftHandSideExpression %type LeftHandSideExpressionNoBF -%type LeftHandSideExpressionNoWC +%type LeftHandSideExpressionNoRE //%type LetStatement %type Literal %type LiteralNoRE @@ -406,36 +402,29 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type LogicalANDExpression %type LogicalANDExpressionNoBF %type LogicalANDExpressionNoIn -%type LogicalANDExpressionNoWC %type LogicalORExpression %type LogicalORExpressionNoBF %type LogicalORExpressionNoIn -%type LogicalORExpressionNoWC %type MemberAccess %type MemberExpression %type MemberExpression_ %type MemberExpressionNoBF -%type MemberExpressionNoWC +%type MemberExpressionNoRE %type MultiplicativeExpression %type MultiplicativeExpressionNoBF -%type MultiplicativeExpressionNoWC %type NewExpression %type NewExpression_ %type NewExpressionNoBF -%type NewExpressionNoWC +%type NewExpressionNoRE %type NullLiteral %type ObjectLiteral %type PostfixExpression %type PostfixExpressionNoBF -%type PostfixExpressionNoWC +%type PostfixExpressionNoRE %type PrimaryExpression %type PrimaryExpressionNo %type PrimaryExpressionNoBF -%type PrimaryExpressionNoWC -%type PrimaryExpressionNoWC_ -@begin E4X -%type PrimaryExpressionWC -@end +%type PrimaryExpressionNoRE %type PrimaryExpressionBF %type Program %type PropertyName @@ -447,12 +436,10 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type RelationalExpression_ %type RelationalExpressionNoBF %type RelationalExpressionNoIn -%type RelationalExpressionNoWC %type RelationalExpressionNoIn_ %type ReturnStatement %type ShiftExpression %type ShiftExpressionNoBF -%type ShiftExpressionNoWC %type SourceElement %type SourceElement_ %type SourceElements @@ -467,7 +454,7 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type UnaryExpression %type UnaryExpression_ %type UnaryExpressionNoBF -%type UnaryExpressionNoWC +%type UnaryExpressionNoRE %type VariableDeclaration %type VariableDeclarationNoIn %type VariableDeclarationList @@ -527,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" @@ -703,28 +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 ; -PrimaryExpressionNoWC_ +PrimaryExpressionNoRE : PrimaryExpressionBF { $$ = $1; } | PrimaryExpressionNo { $$ = $1; } ; -PrimaryExpressionNoWC - : LexSetRegExp PrimaryExpressionNoWC_ { $$ = $2; } - ; - PrimaryExpressionNo : "this" { $$ = $1; } | Identifier { $$ = new(driver.pool_) CYVariable($1); } @@ -803,7 +778,7 @@ MemberAccess MemberExpression : PrimaryExpression { $$ = $1; } - | FunctionExpression { $$ = $1; } + | LexSetRegExp FunctionExpression { $$ = $2; } | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; } | LexSetRegExp MemberExpression_ { $$ = $2; } ; @@ -814,11 +789,11 @@ MemberExpressionNoBF | MemberExpression_ { $$ = $1; } ; -MemberExpressionNoWC - : PrimaryExpression { $$ = $1; } +MemberExpressionNoRE + : PrimaryExpressionNoRE { $$ = $1; } | FunctionExpression { $$ = $1; } - | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; } - | LexSetRegExp MemberExpression_ { $$ = $2; } + | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; } + | MemberExpression_ { $$ = $1; } ; NewExpression_ @@ -835,13 +810,13 @@ NewExpressionNoBF | NewExpression_ { $$ = $1; } ; -NewExpressionNoWC - : MemberExpressionNoWC { $$ = $1; } - | LexSetRegExp NewExpression_ { $$ = $2; } +NewExpressionNoRE + : MemberExpressionNoRE { $$ = $1; } + | NewExpression_ { $$ = $1; } ; 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; } ; @@ -852,6 +827,12 @@ CallExpressionNoBF | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; } ; +CallExpressionNoRE + : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); } + | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); } + | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; } + ; + ArgumentList_ : "," ArgumentList { $$ = $2; } | { $$ = NULL; } @@ -880,9 +861,9 @@ LeftHandSideExpressionNoBF | CallExpressionNoBF { $$ = $1; } ; -LeftHandSideExpressionNoWC - : NewExpressionNoWC { $$ = $1; } - | CallExpression { $$ = $1; } +LeftHandSideExpressionNoRE + : NewExpressionNoRE { $$ = $1; } + | CallExpressionNoRE { $$ = $1; } ; /* }}} */ /* 11.3 Postfix Expressions {{{ */ @@ -898,10 +879,10 @@ PostfixExpressionNoBF | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); } ; -PostfixExpressionNoWC - : AssigneeExpressionNoWC { $$ = $1; } - | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); } - | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); } +PostfixExpressionNoRE + : AssigneeExpressionNoRE { $$ = $1; } + | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); } + | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); } ; /* }}} */ /* 11.4 Unary Operators {{{ */ @@ -929,9 +910,9 @@ UnaryExpressionNoBF | UnaryExpression_ { $$ = $1; } ; -UnaryExpressionNoWC - : PostfixExpressionNoWC { $$ = $1; } - | LexSetRegExp UnaryExpression_ { $$ = $2; } +UnaryExpressionNoRE + : PostfixExpressionNoRE { $$ = $1; } + | UnaryExpression_ { $$ = $1; } ; /* }}} */ /* 11.5 Multiplicative Operators {{{ */ @@ -948,13 +929,6 @@ MultiplicativeExpressionNoBF | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } ; - -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); } - ; /* }}} */ /* 11.6 Additive Operators {{{ */ AdditiveExpression @@ -968,12 +942,6 @@ AdditiveExpressionNoBF | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } ; - -AdditiveExpressionNoWC - : MultiplicativeExpressionNoWC { $$ = $1; } - | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } - | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } - ; /* }}} */ /* 11.7 Bitwise Shift Operators {{{ */ ShiftExpression @@ -989,13 +957,6 @@ ShiftExpressionNoBF | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } ; - -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); } - ; /* }}} */ /* 11.8 Relational Operators {{{ */ RelationalExpressionNoIn_ @@ -1025,11 +986,6 @@ RelationalExpressionNoBF : ShiftExpressionNoBF { $$ = $1; } | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; } ; - -RelationalExpressionNoWC - : ShiftExpressionNoWC { $$ = $1; } - | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; } - ; /* }}} */ /* 11.9 Equality Operators {{{ */ EqualityExpression @@ -1055,14 +1011,6 @@ EqualityExpressionNoBF | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } ; - -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); } - ; /* }}} */ /* 11.10 Binary Bitwise Operators {{{ */ BitwiseANDExpression @@ -1080,11 +1028,6 @@ BitwiseANDExpressionNoBF | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } ; -BitwiseANDExpressionNoWC - : EqualityExpressionNoWC { $$ = $1; } - | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } - ; - BitwiseXORExpression : BitwiseANDExpression { $$ = $1; } | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } @@ -1100,11 +1043,6 @@ BitwiseXORExpressionNoBF | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } ; -BitwiseXORExpressionNoWC - : BitwiseANDExpressionNoWC { $$ = $1; } - | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } - ; - BitwiseORExpression : BitwiseXORExpression { $$ = $1; } | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } @@ -1119,11 +1057,6 @@ BitwiseORExpressionNoBF : BitwiseXORExpressionNoBF { $$ = $1; } | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } ; - -BitwiseORExpressionNoWC - : BitwiseXORExpressionNoWC { $$ = $1; } - | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } - ; /* }}} */ /* 11.11 Binary Logical Operators {{{ */ LogicalANDExpression @@ -1141,11 +1074,6 @@ LogicalANDExpressionNoBF | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } ; -LogicalANDExpressionNoWC - : BitwiseORExpressionNoWC { $$ = $1; } - | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } - ; - LogicalORExpression : LogicalANDExpression { $$ = $1; } | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } @@ -1160,11 +1088,6 @@ LogicalORExpressionNoBF : LogicalANDExpressionNoBF { $$ = $1; } | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } ; - -LogicalORExpressionNoWC - : LogicalANDExpressionNoWC { $$ = $1; } - | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } - ; /* }}} */ /* 11.12 Conditional Operator ( ? : ) {{{ */ ConditionalExpression @@ -1181,11 +1104,6 @@ ConditionalExpressionNoBF : LogicalORExpressionNoBF { $$ = $1; } | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } ; - -ConditionalExpressionNoWC - : LogicalORExpressionNoWC { $$ = $1; } - | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } - ; /* }}} */ /* 11.13 Assignment Operators {{{ */ AssignmentExpression_ @@ -1213,9 +1131,9 @@ AssigneeExpressionNoBF | UnaryAssigneeExpression { $$ = $1; } ; -AssigneeExpressionNoWC - : LeftHandSideExpressionNoWC { $$ = $1; } - | LexSetRegExp UnaryAssigneeExpression { $$ = $2; } +AssigneeExpressionNoRE + : LeftHandSideExpressionNoRE { $$ = $1; } + | UnaryAssigneeExpression { $$ = $1; } ; AssignmentExpression @@ -1243,11 +1161,6 @@ AssignmentExpressionNoBF : ConditionalExpressionNoBF { $$ = $1; } | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } ; - -AssignmentExpressionNoWC - : ConditionalExpressionNoWC { $$ = $1; } - | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } - ; /* }}} */ /* 11.14 Comma Operator {{{ */ Expression_ @@ -1507,12 +1420,8 @@ FunctionDeclaration : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); } ; -FunctionExpression_ - : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); } - ; - FunctionExpression - : LexSetRegExp FunctionExpression_ { $$ = $2; } + : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); } ; FormalParameterList_ @@ -1650,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); } ; @@ -1678,7 +1587,7 @@ PrimaryExpressionNo @begin C /* Cycript (C): Pointer Indirection/Addressing {{{ */ UnaryAssigneeExpression - : "*" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); } + : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); } ; UnaryExpression_ @@ -1738,7 +1647,7 @@ XMLMarkup ; /* }}} */ /* 11.1 Primary Expressions {{{ */ -PrimaryExpressionWC +PrimaryExpressionNo : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); } | XMLInitialiser { $$ = $1; } | XMLListInitialiser { $$ = $1; }