%type <argument_> Arguments
%type <literal_> ArrayLiteral
%type <expression_> AssigneeExpression
-%type <expression_> AssigneeExpression_
%type <expression_> AssigneeExpressionNoBF
%type <expression_> AssignmentExpression
%type <assignment_> AssignmentExpression_
%type <expression_> PrimaryExpression
%type <expression_> PrimaryExpression_
%type <expression_> PrimaryExpressionNoBF
+%type <expression_> PrimaryExpressionNoBF_
%type <statement_> Program
%type <propertyName_> PropertyName
%type <property_> PropertyNameAndValueList
%type <property_> PropertyNameAndValueList_
%type <property_> PropertyNameAndValueListOpt
-%type <literal_> RegularExpressionLiteral_
-%type <condition_> RegularExpressionToken
%type <expression_> RelationalExpression
%type <infix_> RelationalExpression_
%type <expression_> RelationalExpressionNoBF
%type <expression_> ShiftExpression
%type <expression_> ShiftExpressionNoBF
%type <statement_> SourceElement
+%type <statement_> SourceElement_
%type <statement_> SourceElements
%type <statement_> Statement
%type <statement_> Statement_
%type <statement_> SwitchStatement
%type <statement_> ThrowStatement
%type <statement_> TryStatement
+%type <expression_> UnaryAssigneeExpression
%type <expression_> UnaryExpression
%type <expression_> UnaryExpression_
%type <expression_> UnaryExpressionNoBF
| { $$ = NULL; }
;
-RegularExpressionToken
- : "/" { $$ = CYDriver::RegExpSlash; }
- | "/=" { $$ = CYDriver::RegExpSlashEqual; }
-@begin E4X
- | "/>" { $$ = CYDriver::RegExpSlashRight; }
-@end
- ;
-
-RegularExpressionLiteral_
- : RegularExpressionToken { driver.SetCondition($1); } RegularExpressionLiteral { $$ = $3; }
- ;
-
Literal
: NullLiteral { $$ = $1; }
| BooleanLiteral { $$ = $1; }
| NumericLiteral { $$ = $1; }
| StringLiteral { $$ = $1; }
- | RegularExpressionLiteral_ { $$ = $1; }
+ | RegularExpressionLiteral { $$ = $1; }
;
NullLiteral
/* 11.1 Primary Expressions {{{ */
PrimaryExpression_
+ : ObjectLiteral { $$ = $1; }
+ | PrimaryExpressionNoBF_ { $$ = $1; }
+ ;
+
+PrimaryExpressionNoBF_
: "this" { $$ = $1; }
| Identifier { $$ = new(driver.pool_) CYVariable($1); }
| Literal { $$ = $1; }
| "(" Expression ")" { $$ = $2; }
;
+LexBeginRegExp
+ : { driver.BeginCondition(CYDriver::RegExpCondition); }
+ ;
+
PrimaryExpression
- : ObjectLiteral { $$ = $1; }
- | PrimaryExpression_ { $$ = $1; }
+ : LexBeginRegExp PrimaryExpression_ { $$ = $2; }
;
PrimaryExpressionNoBF
- : PrimaryExpression_ { $$ = $1; }
+ : PrimaryExpressionNoBF_ { $$ = $1; }
;
/* }}} */
/* 11.1.4 Array Initialiser {{{ */
ElementOpt
: Element { $$ = $1; }
- | { $$ = NULL; }
+ | LexBeginRegExp { $$ = NULL; }
;
ElementListOpt
: ElementList { $$ = $1; }
- | { $$ = NULL; }
+ | LexBeginRegExp { $$ = NULL; }
;
ElementList
: PrimaryExpression { $$ = $1; }
| FunctionExpression { $$ = $1; }
| MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
- | MemberExpression_ { $$ = $1; }
+ | LexBeginRegExp MemberExpression_ { $$ = $2; }
;
MemberExpressionNoBF
NewExpression
: MemberExpression { $$ = $1; }
- | NewExpression_ { $$ = $1; }
+ | LexBeginRegExp NewExpression_ { $$ = $2; }
;
NewExpressionNoBF
ArgumentListOpt
: ArgumentList { $$ = $1; }
- | { $$ = NULL; }
+ | LexBeginRegExp { $$ = NULL; }
;
ArgumentList
UnaryExpression
: PostfixExpression { $$ = $1; }
- | UnaryExpression_ { $$ = $1; }
+ | LexBeginRegExp UnaryExpression_ { $$ = $2; }
;
UnaryExpressionNoBF
AssigneeExpression
: LeftHandSideExpression { $$ = $1; }
- | AssigneeExpression_ { $$ = $1; }
+ | LexBeginRegExp UnaryAssigneeExpression { $$ = $2; }
;
AssigneeExpressionNoBF
: LeftHandSideExpressionNoBF { $$ = $1; }
- | AssigneeExpression_ { $$ = $1; }
+ | UnaryAssigneeExpression { $$ = $1; }
;
AssignmentExpression
ExpressionOpt
: Expression { $$ = $1; }
- | { $$ = NULL; }
+ | LexBeginRegExp { $$ = NULL; }
;
ExpressionNoInOpt
: ExpressionNoIn { $$ = $1; }
- | { $$ = NULL; }
+ | LexBeginRegExp { $$ = NULL; }
;
Expression
;
Statement
- : Statement_ { $$ = $1; }
+ : LexBeginRegExp Statement_ { $$ = $2; }
;
/* }}} */
/* 12.1 Block {{{ */
StatementListOpt
: StatementList { $$ = $1; }
- | { $$ = NULL; }
+ | LexBeginRegExp { $$ = NULL; }
;
/* }}} */
/* 12.2 Variable Statement {{{ */
ForStatementInitialiser
: ExpressionNoInOpt { $$ = $1; }
- | "var" VariableDeclarationListNoIn { $$ = $2; }
+ | LexBeginRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
;
/* }}} */
/* 12.6.4 The for-in Statement {{{ */
ForInStatementInitialiser
: LeftHandSideExpression { $$ = $1; }
- | "var" VariableDeclarationNoIn { $$ = $2; }
+ | LexBeginRegExp "var" VariableDeclarationNoIn { $$ = $3; }
;
/* }}} */
;
FunctionExpression
- : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
+ : LexBeginRegExp "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($3, $5, $8); }
;
FormalParameterList_
SourceElements
: SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
- | { $$ = NULL; }
+ | LexBeginRegExp { $$ = NULL; }
;
-SourceElement
+SourceElement_
: Statement_ { $$ = $1; }
| FunctionDeclaration { $$ = $1; }
;
+
+SourceElement
+ : LexBeginRegExp SourceElement_ { $$ = $2; }
+ ;
/* }}} */
@begin ObjectiveC
/* Cycript (Objective-C): @class Declaration {{{ */
ClassSuperOpt
- : ":" MemberExpressionNoBF { $$ = $2; }
+ /* XXX: why the hell did I choose MemberExpressionNoBF? */
+ : ":" LexBeginRegExp MemberExpressionNoBF { $$ = $3; }
| { $$ = NULL; }
;
: "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
;
-PrimaryExpression
+PrimaryExpression_
: ClassExpression { $$ = $1; }
;
MessageExpression
: "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
- | "[" "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($3); }
+ | "[" LexBeginRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
;
SelectorExpressionOpt
| Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
;
-PrimaryExpression_
+PrimaryExpressionNoBF_
: MessageExpression { $$ = $1; }
| "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
;
@begin C
/* Cycript (C): Pointer Indirection/Addressing {{{ */
-AssigneeExpression_
+UnaryAssigneeExpression
: "*" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); }
;
;
/* }}} */
/* 11.1 Primary Expressions {{{ */
-PrimaryExpression_
+PrimaryExpressionNoBF_
: PropertyIdentifier
| XMLInitialiser
| XMLListInitialiser
: ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
;
-PrimaryExpression_
+PrimaryExpressionNoBF_
: "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
;
/* }}} */
: "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
;
-Statement
+Statement_
: LetStatement
;
*//* }}} */
/* JavaScript FTW: Function Statements {{{ */
Statement
- : FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $1; }
+ : LexBeginRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }
;
/* }}} */