X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/697d6fd2b2bf66a1f0bf1f28de0ced96fc14cbfc..cee5e1fd5183c06f351c849d6c245b9a8a57e1d7:/Cycript.y.in diff --git a/Cycript.y.in b/Cycript.y.in index e770815..3b7d21f 100644 --- a/Cycript.y.in +++ b/Cycript.y.in @@ -1,4 +1,4 @@ -/* Cycript - Remote Execution Server and Disassembler +/* Cycript - Inlining/Optimizing JavaScript Compiler * Copyright (C) 2009 Jay Freeman (saurik) */ @@ -47,7 +47,11 @@ #include "Parser.hpp" @begin ObjectiveC -#include "ObjectiveC.hpp" +#include "ObjectiveC/Syntax.hpp" +@end + +@begin E4X +#include "E4X/Syntax.hpp" @end typedef struct { @@ -62,7 +66,8 @@ typedef struct { CYAssignment *assignment_; CYBoolean *boolean_; CYClause *clause_; - CYCatch *catch_; + cy::Syntax::Catch *catch_; + CYComment *comment_; CYComprehension *comprehension_; CYCompound *compound_; CYDeclaration *declaration_; @@ -94,8 +99,15 @@ typedef struct { CYField *field_; CYMessage *message_; CYMessageParameter *messageParameter_; + CYProtocol *protocol_; CYSelectorPart *selector_; @end + +@begin E4X + CYAttribute *attribute_; + CYPropertyIdentifier *propertyIdentifier_; + CYSelector *selector_; +@end }; } YYSTYPE; @@ -125,15 +137,30 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %lex-param { void *scanner } @begin E4X -%token At "@" -%token ColonColon "::" +%token XMLCDATA +%token XMLComment +%token XMLPI + +%token XMLAttributeValue +%token XMLName +%token XMLTagCharacters +%token XMLText +%token XMLWhitespace +@end + +@begin E4X %token LeftRight "<>" %token LeftSlashRight "" + +%token SlashRight "/>" +%token LeftSlash " Comment + %token OpenParen "(" %token CloseParen ")" @@ -276,6 +305,12 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); // Woah?! %token Each "each" +@begin E4X +// E4X Conditional +%token Namespace "namespace" +%token XML "xml" +@end + %token Identifier_ %token NumericLiteral %token StringLiteral @@ -363,6 +398,8 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type LeftHandSideExpressionNoBF //%type LetStatement %type Literal +%type LiteralNoRE +%type LiteralRE %type LogicalANDExpression %type LogicalANDExpressionNoBF %type LogicalANDExpressionNoIn @@ -383,11 +420,13 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type PostfixExpression %type PostfixExpressionNoBF %type PrimaryExpression -%type PrimaryExpression_ +%type PrimaryExpressionNo %type PrimaryExpressionNoBF -%type PrimaryExpressionNoBF_ +%type PrimaryExpressionNoRE +%type PrimaryExpressionBF %type Program %type PropertyName +%type PropertyName_ %type PropertyNameAndValueList %type PropertyNameAndValueList_ %type PropertyNameAndValueListOpt @@ -409,7 +448,6 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type SwitchStatement %type ThrowStatement %type TryStatement -%type UnaryAssigneeExpression %type UnaryExpression %type UnaryExpression_ %type UnaryExpressionNoBF @@ -423,6 +461,17 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type WhileStatement %type WithStatement +@begin C +%type AssigneeExpressionNoRE +%type CallExpressionNoRE +%type LeftHandSideExpressionNoRE +%type MemberExpressionNoRE +%type NewExpressionNoRE +%type PostfixExpressionNoRE +%type UnaryAssigneeExpression +%type UnaryExpressionNoRE +@end + @begin ObjectiveC %type CategoryStatement %type ClassExpression @@ -433,6 +482,9 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type ClassMessageDeclarationListOpt %type ClassName %type ClassNameOpt +%type ClassProtocolListOpt +%type ClassProtocols +%type ClassProtocolsOpt %type MessageExpression %type MessageParameter %type MessageParameters @@ -451,6 +503,35 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %type WordOpt @end +@begin E4X +%type PropertyIdentifier_ +%type PropertySelector +%type PropertySelector_ +%type QualifiedIdentifier +%type QualifiedIdentifier_ +%type WildcardIdentifier +%type XMLComment +%type XMLCDATA +%type XMLElement +%type XMLElementContent +%type XMLMarkup +%type XMLPI + +%type AttributeIdentifier +/* XXX: %type DefaultXMLNamespaceStatement */ +%type PropertyIdentifier +%type XMLListInitialiser +%type XMLInitialiser +@end + +%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" +%nonassoc "else" + +%nonassoc "++" "--" +%nonassoc "(" "[" + %left "*" "/" "%" %left "+" "-" %left "<<" ">>" ">>>" @@ -464,13 +545,16 @@ int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|=" -%nonassoc "if" -%nonassoc "else" - %start Program %% +/* Lexer State {{{ */ +LexSetRegExp + : { driver.SetCondition(CYDriver::RegExpCondition); } + ; +/* }}} */ + StrictSemi : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); } ; @@ -524,7 +608,7 @@ Word | "extends" { $$ = $1; } | "false" { $$ = $1; } | "finally" { $$ = $1; } - | "for" { $$ = $1; } + /* XXX: | "for" { $$ = $1; } */ | "function" { $$ = $1; } | "if" { $$ = $1; } | "import" { $$ = $1; } @@ -586,12 +670,21 @@ IdentifierOpt | { $$ = NULL; } ; -Literal +LiteralNoRE : NullLiteral { $$ = $1; } | BooleanLiteral { $$ = $1; } | NumericLiteral { $$ = $1; } | StringLiteral { $$ = $1; } - | RegularExpressionLiteral { $$ = $1; } + | "@" StringLiteral { $$ = $2; } + ; + +LiteralRE + : RegularExpressionLiteral { $$ = $1; } + ; + +Literal + : LiteralNoRE { $$ = $1; } + | LiteralRE { $$ = $1; } ; NullLiteral @@ -604,12 +697,20 @@ BooleanLiteral ; /* 11.1 Primary Expressions {{{ */ -PrimaryExpression_ - : ObjectLiteral { $$ = $1; } - | PrimaryExpressionNoBF_ { $$ = $1; } +PrimaryExpression + : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; } + ; + +PrimaryExpressionNoBF + : PrimaryExpressionNo { $$ = $1; } ; -PrimaryExpressionNoBF_ +PrimaryExpressionNoRE + : PrimaryExpressionBF { $$ = $1; } + | PrimaryExpressionNo { $$ = $1; } + ; + +PrimaryExpressionNo : "this" { $$ = $1; } | Identifier { $$ = new(driver.pool_) CYVariable($1); } | Literal { $$ = $1; } @@ -617,16 +718,8 @@ PrimaryExpressionNoBF_ | "(" Expression ")" { $$ = $2; } ; -LexBeginRegExp - : { driver.BeginCondition(CYDriver::RegExpCondition); } - ; - -PrimaryExpression - : LexBeginRegExp PrimaryExpression_ { $$ = $2; } - ; - -PrimaryExpressionNoBF - : PrimaryExpressionNoBF_ { $$ = $1; } +PrimaryExpressionBF + : ObjectLiteral { $$ = $1; } ; /* }}} */ /* 11.1.4 Array Initialiser {{{ */ @@ -640,12 +733,12 @@ Element ElementOpt : Element { $$ = $1; } - | LexBeginRegExp { $$ = NULL; } + | LexSetRegExp { $$ = NULL; } ; ElementListOpt : ElementList { $$ = $1; } - | LexBeginRegExp { $$ = NULL; } + | LexSetRegExp { $$ = NULL; } ; ElementList @@ -672,11 +765,15 @@ PropertyNameAndValueList : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); } ; -PropertyName +PropertyName_ : Identifier { $$ = $1; } | StringLiteral { $$ = $1; } | NumericLiteral { $$ = $1; } ; + +PropertyName + : LexSetRegExp PropertyName_ { $$ = $2; } + ; /* }}} */ /* 11.2 Left-Hand-Side Expressions {{{ */ @@ -691,9 +788,9 @@ MemberAccess MemberExpression : PrimaryExpression { $$ = $1; } - | FunctionExpression { $$ = $1; } + | LexSetRegExp FunctionExpression { $$ = $2; } | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; } - | LexBeginRegExp MemberExpression_ { $$ = $2; } + | LexSetRegExp MemberExpression_ { $$ = $2; } ; MemberExpressionNoBF @@ -702,13 +799,22 @@ MemberExpressionNoBF | MemberExpression_ { $$ = $1; } ; +@begin C +MemberExpressionNoRE + : PrimaryExpressionNoRE { $$ = $1; } + | FunctionExpression { $$ = $1; } + | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; } + | MemberExpression_ { $$ = $1; } + ; +@end + NewExpression_ : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); } ; NewExpression : MemberExpression { $$ = $1; } - | LexBeginRegExp NewExpression_ { $$ = $2; } + | LexSetRegExp NewExpression_ { $$ = $2; } ; NewExpressionNoBF @@ -716,6 +822,13 @@ NewExpressionNoBF | NewExpression_ { $$ = $1; } ; +@begin C +NewExpressionNoRE + : MemberExpressionNoRE { $$ = $1; } + | NewExpression_ { $$ = $1; } + ; +@end + CallExpression : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); } @@ -728,6 +841,14 @@ CallExpressionNoBF | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; } ; +@begin C +CallExpressionNoRE + : 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; } | { $$ = NULL; } @@ -735,7 +856,7 @@ ArgumentList_ ArgumentListOpt : ArgumentList { $$ = $1; } - | LexBeginRegExp { $$ = NULL; } + | LexSetRegExp { $$ = NULL; } ; ArgumentList @@ -755,6 +876,13 @@ LeftHandSideExpressionNoBF : NewExpressionNoBF { $$ = $1; } | CallExpressionNoBF { $$ = $1; } ; + +@begin C +LeftHandSideExpressionNoRE + : NewExpressionNoRE { $$ = $1; } + | CallExpressionNoRE { $$ = $1; } + ; +@end /* }}} */ /* 11.3 Postfix Expressions {{{ */ PostfixExpression @@ -768,6 +896,14 @@ PostfixExpressionNoBF | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); } ; + +@begin C +PostfixExpressionNoRE + : AssigneeExpressionNoRE { $$ = $1; } + | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); } + | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); } + ; +@end /* }}} */ /* 11.4 Unary Operators {{{ */ UnaryExpression_ @@ -786,13 +922,20 @@ UnaryExpression_ UnaryExpression : PostfixExpression { $$ = $1; } - | LexBeginRegExp UnaryExpression_ { $$ = $2; } + | LexSetRegExp UnaryExpression_ { $$ = $2; } ; UnaryExpressionNoBF : PostfixExpressionNoBF { $$ = $1; } | UnaryExpression_ { $$ = $1; } ; + +@begin C +UnaryExpressionNoRE + : PostfixExpressionNoRE { $$ = $1; } + | UnaryExpression_ { $$ = $1; } + ; +@end /* }}} */ /* 11.5 Multiplicative Operators {{{ */ MultiplicativeExpression @@ -1002,14 +1145,25 @@ AssignmentExpression_ AssigneeExpression : LeftHandSideExpression { $$ = $1; } - | LexBeginRegExp UnaryAssigneeExpression { $$ = $2; } +@begin C + | LexSetRegExp UnaryAssigneeExpression { $$ = $2; } +@end ; AssigneeExpressionNoBF : LeftHandSideExpressionNoBF { $$ = $1; } +@begin C | UnaryAssigneeExpression { $$ = $1; } +@end ; +@begin C +AssigneeExpressionNoRE + : LeftHandSideExpressionNoRE { $$ = $1; } + | UnaryAssigneeExpression { $$ = $1; } + ; +@end + AssignmentExpression : ConditionalExpression { $$ = $1; } | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } @@ -1049,12 +1203,12 @@ ExpressionNoIn_ ExpressionOpt : Expression { $$ = $1; } - | LexBeginRegExp { $$ = NULL; } + | LexSetRegExp { $$ = NULL; } ; ExpressionNoInOpt : ExpressionNoIn { $$ = $1; } - | LexBeginRegExp { $$ = NULL; } + | LexSetRegExp { $$ = NULL; } ; Expression @@ -1089,7 +1243,7 @@ Statement_ ; Statement - : LexBeginRegExp Statement_ { $$ = $2; } + : LexSetRegExp Statement_ { $$ = $2; } ; /* }}} */ /* 12.1 Block {{{ */ @@ -1107,7 +1261,7 @@ StatementList StatementListOpt : StatementList { $$ = $1; } - | LexBeginRegExp { $$ = NULL; } + | LexSetRegExp { $$ = NULL; } ; /* }}} */ /* 12.2 Variable Statement {{{ */ @@ -1205,7 +1359,7 @@ ForStatement ForStatementInitialiser : ExpressionNoInOpt { $$ = $1; } - | LexBeginRegExp "var" VariableDeclarationListNoIn { $$ = $3; } + | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; } ; /* }}} */ /* 12.6.4 The for-in Statement {{{ */ @@ -1215,7 +1369,7 @@ ForInStatement ForInStatementInitialiser : LeftHandSideExpression { $$ = $1; } - | LexBeginRegExp "var" VariableDeclarationNoIn { $$ = $3; } + | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; } ; /* }}} */ @@ -1270,16 +1424,16 @@ LabelledStatement /* }}} */ /* 12.13 The throw Statement {{{ */ ThrowStatement - : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); } + : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); } ; /* }}} */ /* 12.14 The try Statement {{{ */ TryStatement - : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); } + : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); } ; CatchOpt - : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) CYCatch($3, $5); } + : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); } | { $$ = NULL; } ; @@ -1295,7 +1449,7 @@ FunctionDeclaration ; FunctionExpression - : LexBeginRegExp "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($3, $5, $8); } + : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); } ; FormalParameterList_ @@ -1319,7 +1473,7 @@ Program SourceElements : SourceElement SourceElements { $1->SetNext($2); $$ = $1; } - | LexBeginRegExp { $$ = NULL; } + | LexSetRegExp { $$ = NULL; } ; SourceElement_ @@ -1328,7 +1482,7 @@ SourceElement_ ; SourceElement - : LexBeginRegExp SourceElement_ { $$ = $2; } + : LexSetRegExp SourceElement_ { $$ = $2; } ; /* }}} */ @@ -1336,7 +1490,7 @@ SourceElement /* Cycript (Objective-C): @class Declaration {{{ */ ClassSuperOpt /* XXX: why the hell did I choose MemberExpressionNoBF? */ - : ":" LexBeginRegExp MemberExpressionNoBF { $$ = $3; } + : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; } | { $$ = NULL; } ; @@ -1391,19 +1545,34 @@ ClassNameOpt | { $$ = 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 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); } ; -PrimaryExpression_ +PrimaryExpressionBF : ClassExpression { $$ = $1; } ; @@ -1434,7 +1603,7 @@ SelectorList MessageExpression : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); } - | "[" LexBeginRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); } + | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); } ; SelectorExpressionOpt @@ -1451,7 +1620,7 @@ SelectorExpression | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); } ; -PrimaryExpressionNoBF_ +PrimaryExpressionNo : MessageExpression { $$ = $1; } | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); } ; @@ -1461,7 +1630,7 @@ PrimaryExpressionNoBF_ @begin C /* Cycript (C): Pointer Indirection/Addressing {{{ */ UnaryAssigneeExpression - : "*" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); } + : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); } ; UnaryExpression_ @@ -1475,92 +1644,145 @@ MemberAccess /* }}} */ @end +/* YUI: Documentation Comments {{{ */ +Statement_ + : Comment { $$ = $1; } + ; +/* }}} */ + @begin E4X +/* Lexer State {{{ */ +LexPushRegExp + : { driver.PushCondition(CYDriver::RegExpCondition); } + ; + +LexPushXMLContent + : { driver.PushCondition(CYDriver::XMLContentCondition); } + ; + +LexPushXMLTag + : { driver.PushCondition(CYDriver::XMLTagCondition); } + ; + +LexPop + : { driver.PopCondition(); } + ; + +LexSetXMLContent + : { driver.SetCondition(CYDriver::XMLContentCondition); } + ; + +LexSetXMLTag + : { driver.SetCondition(CYDriver::XMLTagCondition); } + ; +/* }}} */ + +XMLWhitespaceOpt + : XMLWhitespace + | + ; + +/* 8.1 Context Keywords {{{ */ +Identifier + : "namespace" { $$ = $1; } + | "xml" { $$ = $1; } + ; +/* }}} */ /* 8.3 XML Initialiser Input Elements {{{ */ XMLMarkup - : XMLComment - | XMLCDATA - | XMLPI + : XMLComment { $$ = $1; } + | XMLCDATA { $$ = $1; } + | XMLPI { $$ = $1; } ; /* }}} */ /* 11.1 Primary Expressions {{{ */ -PrimaryExpressionNoBF_ - : PropertyIdentifier - | XMLInitialiser - | XMLListInitialiser +PrimaryExpressionNo + : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); } + | XMLInitialiser { $$ = $1; } + | XMLListInitialiser { $$ = $1; } ; PropertyIdentifier - : AttributeIdentifier - | QualifiedIdentifier - | WildcardIdentifier + : AttributeIdentifier { $$ = $1; } + | QualifiedIdentifier { $$ = $1; } + | WildcardIdentifier { $$ = $1; } ; /* }}} */ /* 11.1.1 Attribute Identifiers {{{ */ AttributeIdentifier - : "@" PropertySelector - | "@" QualifiedIdentifier - | "@" "[" Expression "]" + : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); } + ; + +PropertySelector_ + : PropertySelector { $$ = $1; } + | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); } ; PropertySelector - : Identifier - | WildcardIdentifier + : Identifier { $$ = new(driver.pool_) CYSelector($1); } + | WildcardIdentifier { $$ = $1; } ; /* }}} */ /* 11.1.2 Qualified Identifiers {{{ */ +QualifiedIdentifier_ + : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); } + | QualifiedIdentifier { $$ = $1; } + ; + QualifiedIdentifier - : PropertySelector "::" PropertySelector - | PropertySelector "::" "[" Expression "]" + : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); } ; /* }}} */ /* 11.1.3 Wildcard Identifiers {{{ */ WildcardIdentifier - : "*" + : "*" { $$ = new(driver.pool_) CYWildcard(); } ; /* }}} */ /* 11.1.4 XML Initialiser {{{ */ XMLInitialiser - : XMLMarkup - | XMLElement + : XMLMarkup { $$ = $1; } + | XMLElement { $$ = $1; } ; XMLElement - : "<" XMLTagContent XMLWhitespaceOpt "/>" - | "<" XMLTagContent XMLWhitespace ">" XMLElementContentOpt "" + : "<" XMLTagContent "/>" LexPop + | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "" LexPop ; XMLTagContent - : XMLTagName XMLAttributesOpt + : LexPushXMLTag XMLTagName XMLAttributes + ; + +XMLExpression + : "{" LexPushRegExp Expression "}" LexPop ; XMLTagName - : "{" Expression "}" + : XMLExpression | XMLName ; -XMLAttributes - : XMLWhitespace "{" Expression "}" - | XMLAttributeOpt XMLAttributes +XMLAttributes_ + : XMLAttributes_ XMLAttribute + | ; -XMLAttributesOpt - : XMLAttributes - | +XMLAttributes + : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt + | XMLAttributes_ XMLWhitespaceOpt ; -XMLAttribute - : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt "{" Expression "}" - | XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue +XMLAttributeValue_ + : XMLExpression + | XMLAttributeValue ; -XMLAttributeOpt - : XMLAttribute - | +XMLAttribute + : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_ ; XMLElementContent - : "{" Expression "}" XMLElementContentOpt + : XMLExpression XMLElementContentOpt | XMLMarkup XMLElementContentOpt | XMLText XMLElementContentOpt | XMLElement XMLElementContentOpt @@ -1573,8 +1795,29 @@ XMLElementContentOpt /* }}} */ /* 11.1.5 XMLList Initialiser {{{ */ XMLListInitialiser - : "<>" XMLElementContent "" + : "<>" LexPushXMLContent XMLElementContent "" LexPop { $$ = new(driver.pool_) CYXMLList($3); } + ; +/* }}} */ +/* 11.2 Left-Hand-Side Expressions {{{ */ +PropertyIdentifier_ + : Identifier { $$ = $1; } + | PropertyIdentifier { $$ = $1; } + ; + +MemberAccess + : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); } + | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); } + | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); } + ; +/* }}} */ +/* 12.1 The default xml namespace Statement {{{ */ +/* XXX: DefaultXMLNamespaceStatement + : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); } ; + +Statement_ + : DefaultXMLNamespaceStatement { $$ = $1; } + ; */ /* }}} */ @end @@ -1603,7 +1846,7 @@ ComprehensionList : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; } ; -PrimaryExpressionNoBF_ +PrimaryExpressionNo : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); } ; /* }}} */ @@ -1623,7 +1866,7 @@ Statement_ *//* }}} */ /* JavaScript FTW: Function Statements {{{ */ Statement - : LexBeginRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; } + : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; } ; /* }}} */