#define YY_EXTRA_TYPE CYDriver *
+#define F(value) do { \
+ int token(value); \
+ yyextra->statement_ = false; \
+ return token; \
+} while (false)
+
#define A new($pool)
#define Y apr_pstrmemdup($pool, yytext, yyleng)
-#define I(type, Type, Name) do { \
+#define I(type, Type, value) do { \
yylval->type ## _ = A CY ## Type; \
- return tk::Name; \
+ F(value); \
} while (false)
#define T yylval->newline_ = yyextra->state_ == CYNewLine; BEGIN(Div);
#define C T yyextra->state_ = CYClear;
#define R T yyextra->state_ = CYRestricted;
-#define E L C I(literal, RegEx(Y), RegularExpressionLiteral);
+#define E L C I(literal, RegEx(Y), tk::RegularExpressionLiteral);
#define N \
if (yyextra->state_ != CYNewLine) { \
yyextra->state_ = CYNewLine; \
else { \
yyextra->state_ = CYClear; \
- return tk::NewLine; \
+ F(tk::NewLine); \
} \
}
/* http://ostermiller.org/findcomment.html */
/* XXX: unify these two rules using !? */
-\/\*!([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/ V() C I(comment, Comment(Y), Comment);
+\/\*!([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/ V() C I(comment, Comment(Y), tk::Comment);
\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/ V(N)
@begin E4X
-<RegExp>"<>" L return tk::LeftRight;
-<XMLContent>"</>" L return tk::LeftSlashRight;
+<RegExp>"<>" L F(tk::LeftRight);
+<XMLContent>"</>" L F(tk::LeftSlashRight);
-<RegExp,XMLContent>\<!\[CDATA\[(\n|[^[]|\[[^[]|\[\[[^>])*]]> V() return tk::XMLCDATA;
-<RegExp,XMLContent>\<!--(\n|[^-]|-[^-])*--> V() return tk::XMLComment;
-<RegExp,XMLContent>\<?(\n|[^?]|\?[^>])*?> V() return tk::XMLPI;
+<RegExp,XMLContent>\<!\[CDATA\[(\n|[^[]|\[[^[]|\[\[[^>])*]]> V() F(tk::XMLCDATA);
+<RegExp,XMLContent>\<!--(\n|[^-]|-[^-])*--> V() F(tk::XMLComment);
+<RegExp,XMLContent>\<?(\n|[^?]|\?[^>])*?> V() F(tk::XMLPI);
-<XMLTag>"=" L return tk::Equal;
-<XMLTag>">" L return tk::Right;
-<XMLTag>"/>" L return tk::SlashRight;
-<XMLTag>"{" L return tk::OpenBrace;
+<XMLTag>"=" L F(tk::Equal);
+<XMLTag>">" L F(tk::Right);
+<XMLTag>"/>" L F(tk::SlashRight);
+<XMLTag>"{" L F(tk::OpenBrace);
-<XMLTag>\"(\n|[^"])*\"|'(\n|[^'])*' V() return tk::XMLAttributeValue;
-<XMLTag>{XMLName} L return tk::XMLName;
-<XMLTag>[ \t\r\n] V() return tk::XMLWhitespace;
+<XMLTag>\"(\n|[^"])*\"|'(\n|[^'])*' V() F(tk::XMLAttributeValue);
+<XMLTag>{XMLName} L F(tk::XMLName);
+<XMLTag>[ \t\r\n] V() F(tk::XMLWhitespace);
-<XMLContent>"{" L return tk::OpenBrace;
-<XMLContent>"<" L return tk::Left;
-<XMLContent>"</" L return tk::LeftSlash;
+<XMLContent>"{" L F(tk::OpenBrace);
+<XMLContent>"<" L F(tk::Left);
+<XMLContent>"</" L F(tk::LeftSlash);
@end
-"..." L C return tk::PeriodPeriodPeriod;
+"..." L C F(tk::PeriodPeriodPeriod);
@begin E4X
-"::" L C return tk::ColonColon;
-".." L C return tk::PeriodPeriod;
+"::" L C F(tk::ColonColon);
+".." L C F(tk::PeriodPeriod);
@end
@begin E4X ObjectiveC
-"@" L C return tk::At;
+"@" L C F(tk::At);
@end
-"&" L C return tk::Ampersand;
-"&&" L C return tk::AmpersandAmpersand;
-"&=" L C return tk::AmpersandEqual;
-"^" L C return tk::Carrot;
-"^=" L C return tk::CarrotEqual;
-"=" L C return tk::Equal;
-"==" L C return tk::EqualEqual;
-"===" L C return tk::EqualEqualEqual;
-"!" L C return tk::Exclamation;
-"!=" L C return tk::ExclamationEqual;
-"!==" L C return tk::ExclamationEqualEqual;
-"-" L C return tk::Hyphen;
-"-=" L C return tk::HyphenEqual;
-"--" L C return yylval->newline_ ? tk::HyphenHyphen_ : tk::HyphenHyphen;
-"->" L C return tk::HyphenRight;
-"<" L C return tk::Left;
-"<=" L C return tk::LeftEqual;
-"<<" L C return tk::LeftLeft;
-"<<=" L C return tk::LeftLeftEqual;
-"%" L C return tk::Percent;
-"%=" L C return tk::PercentEqual;
-"." L C return tk::Period;
-"|" L C return tk::Pipe;
-"|=" L C return tk::PipeEqual;
-"||" L C return tk::PipePipe;
-"+" L C return tk::Plus;
-"+=" L C return tk::PlusEqual;
-"++" L C return yylval->newline_ ? tk::PlusPlus_ : tk::PlusPlus;
-">" L C return tk::Right;
-">=" L C return tk::RightEqual;
-">>" L C return tk::RightRight;
-">>=" L C return tk::RightRightEqual;
-">>>" L C return tk::RightRightRight;
-">>>=" L C return tk::RightRightRightEqual;
-"*" L C return tk::Star;
-"*=" L C return tk::StarEqual;
-"~" L C return tk::Tilde;
-
-<Div>"/" L C return tk::Slash;
-<Div>"/=" L C return tk::SlashEqual;
-
-":" L C return tk::Colon;
-"," L C return tk::Comma;
-"?" L C return tk::Question;
-";" L C return tk::SemiColon;
-
-"(" L C return tk::OpenParen;
-")" L C return tk::CloseParen;
-
-"{" L C return yylval->newline_ ? tk::OpenBrace_ : tk::OpenBrace;
-"}" L C return tk::CloseBrace;
-
-"[" L C return tk::OpenBracket;
-"]" L C return tk::CloseBracket;
+"&" L C F(tk::Ampersand);
+"&&" L C F(tk::AmpersandAmpersand);
+"&=" L C F(tk::AmpersandEqual);
+"^" L C F(tk::Carrot);
+"^=" L C F(tk::CarrotEqual);
+"=" L C F(tk::Equal);
+"==" L C F(tk::EqualEqual);
+"===" L C F(tk::EqualEqualEqual);
+"!" L C F(tk::Exclamation);
+"!=" L C F(tk::ExclamationEqual);
+"!==" L C F(tk::ExclamationEqualEqual);
+"-" L C F(tk::Hyphen);
+"-=" L C F(tk::HyphenEqual);
+"--" L C F(yylval->newline_ ? tk::HyphenHyphen_ : tk::HyphenHyphen);
+"->" L C F(tk::HyphenRight);
+"<" L C F(tk::Left);
+"<=" L C F(tk::LeftEqual);
+"<<" L C F(tk::LeftLeft);
+"<<=" L C F(tk::LeftLeftEqual);
+"%" L C F(tk::Percent);
+"%=" L C F(tk::PercentEqual);
+"." L C F(tk::Period);
+"|" L C F(tk::Pipe);
+"|=" L C F(tk::PipeEqual);
+"||" L C F(tk::PipePipe);
+"+" L C F(tk::Plus);
+"+=" L C F(tk::PlusEqual);
+"++" L C F(yylval->newline_ ? tk::PlusPlus_ : tk::PlusPlus);
+">" L C F(tk::Right);
+">=" L C F(tk::RightEqual);
+">>" L C F(tk::RightRight);
+">>=" L C F(tk::RightRightEqual);
+">>>" L C F(tk::RightRightRight);
+">>>=" L C F(tk::RightRightRightEqual);
+"*" L C F(tk::Star);
+"*=" L C F(tk::StarEqual);
+"~" L C F(tk::Tilde);
+
+<Div>"/" L C F(tk::Slash);
+<Div>"/=" L C F(tk::SlashEqual);
+
+":" L C F(tk::Colon);
+"," L C F(tk::Comma);
+"?" L C F(tk::Question);
+";" L C F(tk::SemiColon);
+
+"(" L C F(tk::OpenParen);
+")" L C F(tk::CloseParen);
+
+"{" L C F(yyextra->statement_ ? tk::OpenBrace__ : yylval->newline_ ? tk::OpenBrace_ : tk::OpenBrace);
+"}" L C F(tk::CloseBrace);
+
+"[" L C F(tk::OpenBracket);
+"]" L C F(tk::CloseBracket);
@begin Java
-"@class" L C return tk::AtClass;
+"@class" L C F(tk::AtClass);
@end
@begin ObjectiveC
-"@end" L C return tk::AtEnd;
-"@implementation" L C return tk::AtImplementation;
-"@import" L C return tk::AtImport;
-"@selector" L C return tk::AtSelector;
+"@end" L C F(tk::AtEnd);
+"@implementation" L C F(yyextra->statement_ ? tk::AtImplementation_ : tk::AtImplementation);
+"@import" L C F(tk::AtImport);
+"@selector" L C F(tk::AtSelector);
@end
-"false" L C I(false, False(), False);
-"null" L C I(null, Null(), Null);
-"true" L C I(true, True(), True);
-
-"break" L R I(word, Word("break"), Break);
-"case" L C I(word, Word("case"), Case);
-"catch" L C I(word, Word("catch"), Catch);
-"continue" L R I(word, Word("continue"), Continue);
-"default" L C I(word, Word("default"), Default);
-"delete" L C I(word, Word("delete"), Delete);
-"do" L C I(word, Word("do"), Do);
-"else" L C I(word, Word("else"), Else);
-"finally" L C I(word, Word("finally"), Finally);
-"for" L C I(word, Word("for"), For);
-"function" L C I(word, Word("function"), Function);
-"if" L C I(word, Word("if"), If);
-"in" L C I(word, Word("in"), In);
-"instanceof" L C I(word, Word("instanceof"), InstanceOf);
-"new" L C I(word, Word("new"), New);
-"return" L R I(word, Word("return"), Return);
-"switch" L C I(word, Word("switch"), Switch);
-"this" L C I(this, This(), This);
-"throw" L R I(word, Word("throw"), Throw);
-"try" L C I(word, Word("try"), Try);
-"typeof" L C I(word, Word("typeof"), TypeOf);
-"var" L C I(word, Word("var"), Var);
-"void" L C I(word, Word("void"), Void);
-"while" L C I(word, Word("while"), While);
-"with" L C I(word, Word("with"), With);
-
-"debugger" L C I(word, Word("debugger"), Debugger);
-
-"const" L C I(word, Word("const"), Const);
-
-"class" L C I(word, Word("class"), Class);
-"enum" L C I(word, Word("enum"), Enum);
-"export" L C I(word, Word("export"), Export);
-"extends" L C I(word, Word("extends"), Extends);
-"import" L C I(word, Word("import"), Import);
-"super" L C I(word, Word("super"), Super);
-
-"implements" L C I(identifier, Identifier("implements"), Implements);
-"interface" L C I(identifier, Identifier("interface"), Interface);
-"package" L C I(identifier, Identifier("package"), Package);
-"private" L C I(identifier, Identifier("private"), Private);
-"protected" L C I(identifier, Identifier("protected"), Protected);
-"public" L C I(identifier, Identifier("public"), Public);
-"static" L C I(identifier, Identifier("static"), Static);
-
-"abstract" L C I(identifier, Identifier("abstract"), Abstract);
-"boolean" L C I(identifier, Identifier("boolean"), Boolean);
-"byte" L C I(identifier, Identifier("byte"), Byte);
-"char" L C I(identifier, Identifier("char"), Char);
-"double" L C I(identifier, Identifier("double"), Double);
-"final" L C I(identifier, Identifier("final"), Final);
-"float" L C I(identifier, Identifier("float"), Float);
-"goto" L C I(identifier, Identifier("goto"), Goto);
-"int" L C I(identifier, Identifier("int"), Int);
-"long" L C I(identifier, Identifier("long"), Long);
-"native" L C I(identifier, Identifier("native"), Native);
-"short" L C I(identifier, Identifier("short"), Short);
-"synchronized" L C I(identifier, Identifier("synchronized"), Synchronized);
-"throws" L C I(identifier, Identifier("throws"), Throws);
-"transient" L C I(identifier, Identifier("transient"), Transient);
-"volatile" L C I(identifier, Identifier("volatile"), Volatile);
-
-"let" L C I(identifier, Identifier("let"), Let);
-"yield" L C I(identifier, Identifier("yield"), Yield);
-
-"each" L C I(identifier, Identifier("each"), Each);
+"false" L C I(false, False(), tk::False);
+"null" L C I(null, Null(), tk::Null);
+"true" L C I(true, True(), tk::True);
+
+"break" L R I(word, Word("break"), tk::Break);
+"case" L C I(word, Word("case"), tk::Case);
+"catch" L C I(word, Word("catch"), tk::Catch);
+"continue" L R I(word, Word("continue"), tk::Continue);
+"default" L C I(word, Word("default"), tk::Default);
+"delete" L C I(word, Word("delete"), tk::Delete);
+"do" L C I(word, Word("do"), tk::Do);
+"else" L C I(word, Word("else"), tk::Else);
+"finally" L C I(word, Word("finally"), tk::Finally);
+"for" L C I(word, Word("for"), tk::For);
+"function" L C I(word, Word("function"), yyextra->statement_ ? tk::Function_ : tk::Function);
+"if" L C I(word, Word("if"), tk::If);
+"in" L C I(word, Word("in"), yyextra->in_.top() ? tk::In_ : tk::In);
+"instanceof" L C I(word, Word("instanceof"), tk::InstanceOf);
+"new" L C I(word, Word("new"), tk::New);
+"return" L R I(word, Word("return"), tk::Return);
+"switch" L C I(word, Word("switch"), tk::Switch);
+"this" L C I(this, This(), tk::This);
+"throw" L R I(word, Word("throw"), tk::Throw);
+"try" L C I(word, Word("try"), tk::Try);
+"typeof" L C I(word, Word("typeof"), tk::TypeOf);
+"var" L C I(word, Word("var"), tk::Var);
+"void" L C I(word, Word("void"), tk::Void);
+"while" L C I(word, Word("while"), tk::While);
+"with" L C I(word, Word("with"), tk::With);
+
+"debugger" L C I(word, Word("debugger"), tk::Debugger);
+
+"const" L C I(word, Word("const"), tk::Const);
+
+"class" L C I(word, Word("class"), tk::Class);
+"enum" L C I(word, Word("enum"), tk::Enum);
+"export" L C I(word, Word("export"), tk::Export);
+"extends" L C I(word, Word("extends"), tk::Extends);
+"import" L C I(word, Word("import"), tk::Import);
+"super" L C I(word, Word("super"), tk::Super);
+
+"implements" L C I(identifier, Identifier("implements"), tk::Implements);
+"interface" L C I(identifier, Identifier("interface"), tk::Interface);
+"package" L C I(identifier, Identifier("package"), tk::Package);
+"private" L C I(identifier, Identifier("private"), tk::Private);
+"protected" L C I(identifier, Identifier("protected"), tk::Protected);
+"public" L C I(identifier, Identifier("public"), tk::Public);
+"static" L C I(identifier, Identifier("static"), tk::Static);
+
+"abstract" L C I(identifier, Identifier("abstract"), tk::Abstract);
+"boolean" L C I(identifier, Identifier("boolean"), tk::Boolean);
+"byte" L C I(identifier, Identifier("byte"), tk::Byte);
+"char" L C I(identifier, Identifier("char"), tk::Char);
+"double" L C I(identifier, Identifier("double"), tk::Double);
+"final" L C I(identifier, Identifier("final"), tk::Final);
+"float" L C I(identifier, Identifier("float"), tk::Float);
+"goto" L C I(identifier, Identifier("goto"), tk::Goto);
+"int" L C I(identifier, Identifier("int"), tk::Int);
+"long" L C I(identifier, Identifier("long"), tk::Long);
+"native" L C I(identifier, Identifier("native"), tk::Native);
+"short" L C I(identifier, Identifier("short"), tk::Short);
+"synchronized" L C I(identifier, Identifier("synchronized"), tk::Synchronized);
+"throws" L C I(identifier, Identifier("throws"), tk::Throws);
+"transient" L C I(identifier, Identifier("transient"), tk::Transient);
+"volatile" L C I(identifier, Identifier("volatile"), tk::Volatile);
+
+"let" L C I(identifier, Identifier("let"), tk::Let);
+"yield" L C I(identifier, Identifier("yield"), tk::Yield);
+
+"each" L C I(identifier, Identifier("each"), tk::Each);
@begin E4X
-"namespace" L C I(identifier, Identifier("namespace"), Namespace);
-"xml" L C I(identifier, Identifier("xml"), XML);
+"namespace" L C I(identifier, Identifier("namespace"), tk::Namespace);
+"xml" L C I(identifier, Identifier("xml"), tk::XML);
@end
-{IdentifierStart}{IdentifierPart}* L C I(identifier, Identifier(Y), Identifier_);
+{IdentifierStart}{IdentifierPart}* L C I(identifier, Identifier(Y), tk::Identifier_);
-(\.[0-9]+|(0|[1-9][0-9]*)(\.[0-9]*)?){Exponent}? L C I(number, Number(strtod(yytext, NULL)), NumericLiteral);
+(\.[0-9]+|(0|[1-9][0-9]*)(\.[0-9]*)?){Exponent}? L C I(number, Number(strtod(yytext, NULL)), tk::NumericLiteral);
-0[xX][0-9a-fA-F]+ L C I(number, Number(strtoull(yytext + 2, NULL, 16)), NumericLiteral);
-0[0-7]+ L C I(number, Number(strtoull(yytext + 1, NULL, 8)), NumericLiteral);
-0[bB][0-1]+ L C I(number, Number(strtoull(yytext + 2, NULL, 2)), NumericLiteral);
+0[xX][0-9a-fA-F]+ L C I(number, Number(strtoull(yytext + 2, NULL, 16)), tk::NumericLiteral);
+0[0-7]+ L C I(number, Number(strtoull(yytext + 1, NULL, 8)), tk::NumericLiteral);
+0[bB][0-1]+ L C I(number, Number(strtoull(yytext + 2, NULL, 2)), tk::NumericLiteral);
\"([^"\\\n]|{Escape})*\"|'([^'\\\n]|{Escape})*' L C {
char *value(A char[yyleng]);
}
*local = '\0';
- I(string, String(value, local - value), StringLiteral);
+ I(string, String(value, local - value), tk::StringLiteral);
}
-\r?\n yylloc->end.lines(); yylloc->step(); N
+\r?\n|\r|\xe2\x80[\xa8\xa9] yylloc->end.lines(); yylloc->step(); N
[ \t] L
-<<EOF>> if (yyextra->auto_) { yyextra->auto_ = false; return tk::AutoComplete; } L yyterminate();
+<<EOF>> if (yyextra->auto_) { yyextra->auto_ = false; F(tk::AutoComplete); } L yyterminate();
. L {
CYDriver::Error error;
%token OpenBrace "{"
%token OpenBrace_ "\n{"
+%token OpenBrace__ ";{"
%token CloseBrace "}"
%token OpenBracket "["
@begin ObjectiveC
%token AtImplementation "@implementation"
+%token AtImplementation_ ";@implementation"
%token AtImport "@import"
%token AtEnd "@end"
%token AtSelector "@selector"
%token <word_> Finally "finally"
%token <word_> For "for"
%token <word_> Function "function"
+%token <word_> Function_ ";function"
%token <word_> If "if"
%token <word_> In "in"
+%token <word_> In_ "!in"
%token <word_> InstanceOf "instanceof"
%token <word_> New "new"
%token <word_> Return "return"
%token <literal_> RegularExpressionLiteral
%type <expression_> AdditiveExpression
-%type <expression_> AdditiveExpressionNoBF
%type <argument_> ArgumentList_
%type <argument_> ArgumentList
%type <argument_> ArgumentListOpt
%type <argument_> Arguments
%type <literal_> ArrayLiteral
-%type <expression_> AssigneeExpression
-%type <expression_> AssigneeExpressionNoBF
%type <assignment_> AssignmentExpression_
%type <expression_> AssignmentExpression
-%type <expression_> AssignmentExpressionNoBF
-%type <expression_> AssignmentExpressionNoIn
%type <identifier_> BindingIdentifier
%type <expression_> BitwiseANDExpression
-%type <expression_> BitwiseANDExpressionNoBF
-%type <expression_> BitwiseANDExpressionNoIn
%type <statement_> Block_
%type <statement_> Block
%type <boolean_> BooleanLiteral
%type <declaration_> BindingElement
%type <expression_> BitwiseORExpression
-%type <expression_> BitwiseORExpressionNoBF
-%type <expression_> BitwiseORExpressionNoIn
%type <expression_> BitwiseXORExpression
-%type <expression_> BitwiseXORExpressionNoBF
-%type <expression_> BitwiseXORExpressionNoIn
%type <statement_> BreakStatement
%type <statement_> BreakableStatement
+%type <expression_> CallExpression_
%type <expression_> CallExpression
-%type <expression_> CallExpressionNoBF
%type <clause_> CaseBlock
%type <clause_> CaseClause
%type <clause_> CaseClausesOpt
%type <comprehension_> ComprehensionList
%type <comprehension_> ComprehensionListOpt
%type <expression_> ConditionalExpression
-%type <expression_> ConditionalExpressionNoBF
-%type <expression_> ConditionalExpressionNoIn
%type <statement_> ContinueStatement
%type <statement_> DebuggerStatement
+%type <statement_> Declaration__
+%type <statement_> Declaration_
%type <statement_> Declaration
%type <clause_> DefaultClause
%type <statement_> DoWhileStatement
%type <statement_> ElseStatementOpt
%type <statement_> EmptyStatement
%type <expression_> EqualityExpression
-%type <expression_> EqualityExpressionNoBF
-%type <expression_> EqualityExpressionNoIn
%type <compound_> Expression_
%type <expression_> Expression
%type <expression_> ExpressionOpt
-%type <expression_> ExpressionNoBF
-%type <compound_> ExpressionNoIn_
-%type <expression_> ExpressionNoIn
-%type <expression_> ExpressionNoInOpt
%type <statement_> ExpressionStatement
%type <finally_> FinallyOpt
%type <comprehension_> ForComprehension
%type <statement_> IfStatement
%type <expression_> Initialiser
%type <expression_> InitialiserOpt
-%type <expression_> InitialiserNoIn
-%type <expression_> InitialiserNoInOpt
%type <statement_> IterationStatement
%type <statement_> LabelledStatement
%type <expression_> LeftHandSideExpression
-%type <expression_> LeftHandSideExpressionNoBF
-//%type <expression_> LetExpression
%type <statement_> LetStatement
%type <statement_> LexicalDeclaration
%type <literal_> Literal
%type <literal_> LiteralNoRE
-%type <literal_> LiteralRE
%type <expression_> LogicalANDExpression
-%type <expression_> LogicalANDExpressionNoBF
-%type <expression_> LogicalANDExpressionNoIn
%type <expression_> LogicalORExpression
-%type <expression_> LogicalORExpressionNoBF
-%type <expression_> LogicalORExpressionNoIn
%type <member_> MemberAccess
%type <expression_> MemberExpression_
%type <expression_> MemberExpression
-%type <expression_> MemberExpressionNoBF
%type <expression_> MultiplicativeExpression
-%type <expression_> MultiplicativeExpressionNoBF
-%type <expression_> NewExpression_
%type <expression_> NewExpression
-%type <expression_> NewExpressionNoBF
%type <null_> NullLiteral
%type <literal_> ObjectLiteral
+%type <expression_> Parenthetical
%type <expression_> PostfixExpression
-%type <expression_> PostfixExpressionNoBF
%type <expression_> PrimaryExpression
-%type <expression_> PrimaryExpressionNo
-%type <expression_> PrimaryExpressionNoBF
-%type <expression_> PrimaryExpressionNoRE
-%type <expression_> PrimaryExpressionBF
%type <statement_> Program
%type <statement_> ProgramBody
%type <statement_> ProgramBodyOpt
%type <property_> PropertyNameAndValueList_
%type <property_> PropertyNameAndValueList
%type <property_> PropertyNameAndValueListOpt
-%type <infix_> RelationalExpression_
+%type <expression_> RelationalExpression_
%type <expression_> RelationalExpression
-%type <expression_> RelationalExpressionNoBF
-%type <infix_> RelationalExpressionNoIn_
-%type <expression_> RelationalExpressionNoIn
%type <statement_> ReturnStatement
%type <rubyProc_> RubyProcExpression
-%type <rubyProc_> RubyProcExpressionNoOA
%type <functionParameter_> RubyProcParameterList_
%type <functionParameter_> RubyProcParameterList
%type <functionParameter_> RubyProcParameters
%type <functionParameter_> RubyProcParametersOpt
%type <expression_> ShiftExpression
-%type <expression_> ShiftExpressionNoBF
%type <declaration_> SingleNameBinding
+%type <statement_> Statement__
%type <statement_> Statement_
%type <statement_> Statement
%type <statement_> StatementList
%type <statement_> TryStatement
%type <expression_> UnaryExpression_
%type <expression_> UnaryExpression
-%type <expression_> UnaryExpressionNoBF
%type <declaration_> VariableDeclaration
-%type <declaration_> VariableDeclarationNoIn
%type <declarations_> VariableDeclarationList_
%type <declarations_> VariableDeclarationList
-%type <declarations_> VariableDeclarationListNoIn_
-%type <declarations_> VariableDeclarationListNoIn
%type <statement_> VariableStatement
%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 <expression_> 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 ""
+%left "++" "--"
%nonassoc "if"
%nonassoc "else"
-%nonassoc "++" "--"
-%nonassoc "(" "["
-
-%left "*" "/" "%"
-%left "+" "-"
-%left "<<" ">>" ">>>"
-%left "<" ">" "<=" ">=" "instanceof" "in"
-%left "==" "!=" "===" "!=="
-%left "&"
-%left "^"
-%left "|"
-%left "&&"
-%left "||"
-
-%right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
-
%start Program
%%
/* Lexer State {{{ */
+LexPushInOn
+ : { driver.in_.push(true); }
+ ;
+
+LexPushInOff
+ : { driver.in_.push(false); }
+ ;
+
+LexPopIn
+ : { driver.in_.pop(); }
+ ;
+
LexSetRegExp
: { driver.SetCondition(CYDriver::RegExpCondition); }
;
+
+LexSetStatement
+ : {
+ if (yychar == 0)
+ driver.statement_ = true;
+ else switch (yychar) {
+ case cy::parser::token::Function:
+ yychar = cy::parser::token::Function_;
+ break;
+
+ case cy::parser::token::OpenBrace:
+ case cy::parser::token::OpenBrace_:
+ yychar = cy::parser::token::OpenBrace__;
+ break;
+ }
+ }
+ ;
/* }}} */
-Brace
+BRACE
: "{"
| "\n{"
;
| { $$ = NULL; }
;
-PrimaryExpressionNo
+PrimaryExpression
: "@" LiteralNoRE { $$ = CYNew CYBox($2); }
| "@" ArrayLiteral { $$ = CYNew CYBox($2); }
| "@" ObjectLiteral { $$ = CYNew CYBox($2); }
- | "@" "(" Expression ")" { $$ = CYNew CYBox($3); }
+ | "@" Parenthetical { $$ = CYNew CYBox($2); }
;
@end
| StringLiteral { $$ = $1; }
;
-LiteralRE
- : RegularExpressionLiteral { $$ = $1; }
- ;
-
Literal
: LiteralNoRE { $$ = $1; }
- | LiteralRE { $$ = $1; }
+ | RegularExpressionLiteral { $$ = $1; }
;
NullLiteral
;
/* 11.1 Primary Expressions {{{ */
-PrimaryExpression
- : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
- ;
-
-PrimaryExpressionNoBF
- : PrimaryExpressionNo { $$ = $1; }
+Parenthetical
+ : "(" LexPushInOff Expression LexPopIn ")" { $$ = $3; }
;
-PrimaryExpressionNoRE
- : PrimaryExpressionBF { $$ = $1; }
- | PrimaryExpressionNo { $$ = $1; }
- ;
-
-PrimaryExpressionNo
+PrimaryExpression
: "this" { $$ = $1; }
| Identifier { $$ = CYNew CYVariable($1); }
- | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
| Literal { $$ = $1; }
| ArrayLiteral { $$ = $1; }
- | "(" Expression ")" { $$ = $2; }
- ;
-
-PrimaryExpressionBF
- : ObjectLiteral { $$ = $1; }
+ | ObjectLiteral { $$ = $1; }
+ | FunctionExpression { $$ = $1; }
+ | Parenthetical { $$ = $1; }
+ | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
;
/* }}} */
-/* 11.1.4 Array Initialiser {{{ */
+/* 11.1.4.1 Array Initialiser {{{ */
ArrayLiteral
- : "[" ElementListOpt "]" { $$ = CYNew CYArray($2); }
+ : "[" LexPushInOff ElementListOpt LexPopIn "]" { $$ = CYNew CYArray($3); }
;
Element
/* }}} */
/* 11.1.5 Object Initialiser {{{ */
ObjectLiteral
- : Brace PropertyNameAndValueListOpt "}" { $$ = CYNew CYObject($2); }
+ : BRACE LexPushInOff PropertyNameAndValueListOpt LexPopIn "}" { $$ = CYNew CYObject($3); }
;
PropertyNameAndValueList_
/* 11.2 Left-Hand-Side Expressions {{{ */
MemberAccess
- : "[" Expression "]" { $$ = CYNew CYDirectMember(NULL, $2); }
+ : "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYDirectMember(NULL, $3); }
| "." Identifier { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
| "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
;
MemberExpression_
- : "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($2, $3); }
+ : MemberExpression { $$ = $1; }
+ //| "super" { $$ = $1; }
;
MemberExpression
- : PrimaryExpression { $$ = $1; }
- | LexSetRegExp FunctionExpression { $$ = $2; }
- | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
- | LexSetRegExp MemberExpression_ { $$ = $2; }
- ;
-
-MemberExpressionNoBF
- : PrimaryExpressionNoBF { $$ = $1; }
- | MemberExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
- | MemberExpression_ { $$ = $1; }
- ;
-
-@begin C
-MemberExpressionNoRE
- : PrimaryExpressionNoRE { $$ = $1; }
- | FunctionExpression { $$ = $1; }
- | MemberExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
- | MemberExpression_ { $$ = $1; }
- ;
-@end
-
-NewExpression_
- : "new" NewExpression { $$ = CYNew cy::Syntax::New($2, NULL); }
+ : LexSetRegExp PrimaryExpression { $$ = $2; }
+ | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
+ | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
;
NewExpression
: MemberExpression { $$ = $1; }
- | LexSetRegExp NewExpression_ { $$ = $2; }
- ;
-
-NewExpressionNoBF
- : MemberExpressionNoBF { $$ = $1; }
- | NewExpression_ { $$ = $1; }
+ | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
;
-@begin C
-NewExpressionNoRE
- : MemberExpressionNoRE { $$ = $1; }
- | NewExpression_ { $$ = $1; }
+CallExpression_
+ : MemberExpression_
+ | CallExpression
;
-@end
CallExpression
- : MemberExpression Arguments { $$ = CYNew CYCall($1, $2); }
- | CallExpression Arguments { $$ = CYNew CYCall($1, $2); }
+ : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
| CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
;
-CallExpressionNoBF
- : MemberExpressionNoBF Arguments { $$ = CYNew CYCall($1, $2); }
- | CallExpressionNoBF Arguments { $$ = CYNew CYCall($1, $2); }
- | CallExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
- ;
-
-@begin C
-CallExpressionNoRE
- : MemberExpressionNoRE Arguments { $$ = CYNew CYCall($1, $2); }
- | CallExpressionNoRE Arguments { $$ = CYNew CYCall($1, $2); }
- | CallExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
+Arguments
+ : "(" LexPushInOff ArgumentListOpt LexPopIn ")" { $$ = $3; }
;
-@end
ArgumentList_
: "," ArgumentList { $$ = $2; }
| LexSetRegExp { $$ = NULL; }
;
-Arguments
- : "(" ArgumentListOpt ")" { $$ = $2; }
- ;
-
LeftHandSideExpression
: NewExpression { $$ = $1; }
| CallExpression { $$ = $1; }
;
-
-LeftHandSideExpressionNoBF
- : NewExpressionNoBF { $$ = $1; }
- | CallExpressionNoBF { $$ = $1; }
- ;
-
-@begin C
-LeftHandSideExpressionNoRE
- : NewExpressionNoRE { $$ = $1; }
- | CallExpressionNoRE { $$ = $1; }
- ;
-@end
/* }}} */
/* 11.3 Postfix Expressions {{{ */
PostfixExpression
- : AssigneeExpression { $$ = $1; }
+ : %prec "" LeftHandSideExpression { $$ = $1; }
| LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
| LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
;
-
-PostfixExpressionNoBF
- : AssigneeExpressionNoBF { $$ = $1; }
- | LeftHandSideExpressionNoBF "++" { $$ = CYNew CYPostIncrement($1); }
- | LeftHandSideExpressionNoBF "--" { $$ = CYNew CYPostDecrement($1); }
- ;
-
-@begin C
-PostfixExpressionNoRE
- : AssigneeExpressionNoRE { $$ = $1; }
- | LeftHandSideExpressionNoRE "++" { $$ = CYNew CYPostIncrement($1); }
- | LeftHandSideExpressionNoRE "--" { $$ = CYNew CYPostDecrement($1); }
- ;
-@end
/* }}} */
/* 11.4 Unary Operators {{{ */
UnaryExpression_
: PostfixExpression { $$ = $1; }
| LexSetRegExp UnaryExpression_ { $$ = $2; }
;
-
-UnaryExpressionNoBF
- : PostfixExpressionNoBF { $$ = $1; }
- | UnaryExpression_ { $$ = $1; }
- ;
-
-@begin C
-UnaryExpressionNoRE
- : PostfixExpressionNoRE { $$ = $1; }
- | UnaryExpression_ { $$ = $1; }
- ;
-@end
/* }}} */
/* 11.5 Multiplicative Operators {{{ */
MultiplicativeExpression
| MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
| MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
;
-
-MultiplicativeExpressionNoBF
- : UnaryExpressionNoBF { $$ = $1; }
- | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
- | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
- | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
- ;
/* }}} */
/* 11.6 Additive Operators {{{ */
AdditiveExpression
| AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
| AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
;
-
-AdditiveExpressionNoBF
- : MultiplicativeExpressionNoBF { $$ = $1; }
- | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
- | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
- ;
/* }}} */
/* 11.7 Bitwise Shift Operators {{{ */
ShiftExpression
| ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
| ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
;
-
-ShiftExpressionNoBF
- : AdditiveExpressionNoBF { $$ = $1; }
- | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
- | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
- | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
- ;
/* }}} */
/* 11.8 Relational Operators {{{ */
RelationalExpression_
- : RelationalExpressionNoIn_ { $$ = $1; }
- | "in" ShiftExpression { $$ = CYNew CYIn(NULL, $2); }
- ;
-
-RelationalExpression
- : ShiftExpression { $$ = $1; }
- | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
- ;
-
-RelationalExpressionNoIn_
- : "<" ShiftExpression { $$ = CYNew CYLess(NULL, $2); }
- | ">" ShiftExpression { $$ = CYNew CYGreater(NULL, $2); }
- | "<=" ShiftExpression { $$ = CYNew CYLessOrEqual(NULL, $2); }
- | ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual(NULL, $2); }
- | "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf(NULL, $2); }
- ;
-
-RelationalExpressionNoIn
: ShiftExpression { $$ = $1; }
- | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
;
-RelationalExpressionNoBF
- : ShiftExpressionNoBF { $$ = $1; }
- | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
+RelationalExpression
+ : RelationalExpression_ { $$ = $1; }
+ | RelationalExpression "<" RelationalExpression_ { $$ = CYNew CYLess($1, $3); }
+ | RelationalExpression ">" RelationalExpression_ { $$ = CYNew CYGreater($1, $3); }
+ | RelationalExpression "<=" RelationalExpression_ { $$ = CYNew CYLessOrEqual($1, $3); }
+ | RelationalExpression ">=" RelationalExpression_ { $$ = CYNew CYGreaterOrEqual($1, $3); }
+ | RelationalExpression "instanceof" RelationalExpression_ { $$ = CYNew CYInstanceOf($1, $3); }
+ | RelationalExpression "in" RelationalExpression_ { $$ = CYNew CYIn($1, $3); }
;
/* }}} */
/* 11.9 Equality Operators {{{ */
| EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
| EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
;
-
-EqualityExpressionNoIn
- : RelationalExpressionNoIn { $$ = $1; }
- | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = CYNew CYEqual($1, $3); }
- | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = CYNew CYNotEqual($1, $3); }
- | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = CYNew CYIdentical($1, $3); }
- | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = CYNew CYNotIdentical($1, $3); }
- ;
-
-EqualityExpressionNoBF
- : RelationalExpressionNoBF { $$ = $1; }
- | EqualityExpressionNoBF "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
- | EqualityExpressionNoBF "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
- | EqualityExpressionNoBF "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
- | EqualityExpressionNoBF "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
- ;
/* }}} */
/* 11.10 Binary Bitwise Operators {{{ */
BitwiseANDExpression
| BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
;
-BitwiseANDExpressionNoIn
- : EqualityExpressionNoIn { $$ = $1; }
- | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = CYNew CYBitwiseAnd($1, $3); }
- ;
-
-BitwiseANDExpressionNoBF
- : EqualityExpressionNoBF { $$ = $1; }
- | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
- ;
-
BitwiseXORExpression
: BitwiseANDExpression { $$ = $1; }
| BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
;
-BitwiseXORExpressionNoIn
- : BitwiseANDExpressionNoIn { $$ = $1; }
- | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = CYNew CYBitwiseXOr($1, $3); }
- ;
-
-BitwiseXORExpressionNoBF
- : BitwiseANDExpressionNoBF { $$ = $1; }
- | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
- ;
-
BitwiseORExpression
: BitwiseXORExpression { $$ = $1; }
| BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
;
-
-BitwiseORExpressionNoIn
- : BitwiseXORExpressionNoIn { $$ = $1; }
- | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = CYNew CYBitwiseOr($1, $3); }
- ;
-
-BitwiseORExpressionNoBF
- : BitwiseXORExpressionNoBF { $$ = $1; }
- | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
- ;
/* }}} */
/* 11.11 Binary Logical Operators {{{ */
LogicalANDExpression
| LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
;
-LogicalANDExpressionNoIn
- : BitwiseORExpressionNoIn { $$ = $1; }
- | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = CYNew CYLogicalAnd($1, $3); }
- ;
-
-LogicalANDExpressionNoBF
- : BitwiseORExpressionNoBF { $$ = $1; }
- | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
- ;
-
LogicalORExpression
: LogicalANDExpression { $$ = $1; }
| LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
;
-
-LogicalORExpressionNoIn
- : LogicalANDExpressionNoIn { $$ = $1; }
- | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = CYNew CYLogicalOr($1, $3); }
- ;
-
-LogicalORExpressionNoBF
- : LogicalANDExpressionNoBF { $$ = $1; }
- | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
- ;
/* }}} */
/* 11.12 Conditional Operator ( ? : ) {{{ */
ConditionalExpression
: LogicalORExpression { $$ = $1; }
- | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = CYNew CYCondition($1, $3, $5); }
- ;
-
-ConditionalExpressionNoIn
- : LogicalORExpressionNoIn { $$ = $1; }
- | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = CYNew CYCondition($1, $3, $5); }
- ;
-
-ConditionalExpressionNoBF
- : LogicalORExpressionNoBF { $$ = $1; }
- | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = CYNew CYCondition($1, $3, $5); }
+ | LogicalORExpression "?" LexPushInOff AssignmentExpression LexPopIn ":" AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
;
/* }}} */
/* 11.13 Assignment Operators {{{ */
| "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign(NULL, $2); }
;
-AssigneeExpression
- : LeftHandSideExpression { $$ = $1; }
-@begin C
- | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
-@end
- ;
-
-AssigneeExpressionNoBF
- : LeftHandSideExpressionNoBF { $$ = $1; }
@begin C
- | UnaryAssigneeExpression { $$ = $1; }
-@end
- ;
-
-@begin C
-AssigneeExpressionNoRE
- : LeftHandSideExpressionNoRE { $$ = $1; }
- | UnaryAssigneeExpression { $$ = $1; }
+LeftHandSideExpression
+ : LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
;
@end
AssignmentExpression
: ConditionalExpression { $$ = $1; }
- | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
- ;
-
-AssignmentExpressionNoIn
- : ConditionalExpressionNoIn { $$ = $1; }
- | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = CYNew CYAssign($1, $3); }
- | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = CYNew CYMultiplyAssign($1, $3); }
- | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = CYNew CYDivideAssign($1, $3); }
- | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = CYNew CYModulusAssign($1, $3); }
- | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = CYNew CYAddAssign($1, $3); }
- | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = CYNew CYSubtractAssign($1, $3); }
- | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = CYNew CYShiftLeftAssign($1, $3); }
- | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
- | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
- | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = CYNew CYBitwiseAndAssign($1, $3); }
- | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
- | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = CYNew CYBitwiseOrAssign($1, $3); }
- ;
-
-AssignmentExpressionNoBF
- : ConditionalExpressionNoBF { $$ = $1; }
- | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
+ | LeftHandSideExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
;
/* }}} */
/* 11.14 Comma Operator {{{ */
: Expression { $$ = $1; }
| LexSetRegExp { $$ = NULL; }
;
-
-ExpressionNoIn_
- : "," ExpressionNoIn { $$ = CYNew CYCompound($2); }
- | { $$ = NULL; }
- ;
-
-ExpressionNoIn
- : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
- ;
-
-ExpressionNoInOpt
- : ExpressionNoIn { $$ = $1; }
- | LexSetRegExp { $$ = NULL; }
- ;
-
-ExpressionNoBF
- : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
- ;
/* }}} */
/* 12 Statements {{{ */
-Statement_
+Statement__
: Block { $$ = $1; }
| VariableStatement { $$ = $1; }
| EmptyStatement { $$ = $1; }
- | ExpressionStatement { $$ = $1; }
| IfStatement { $$ = $1; }
| BreakableStatement { $$ = $1; }
| ContinueStatement { $$ = $1; }
| DebuggerStatement { $$ = $1; }
;
+Statement_
+ : LexSetRegExp Statement__ { $$ = $2; }
+ | ExpressionStatement { $$ = $1; }
+ ;
+
Statement
- : LexSetRegExp Statement_ { $$ = $2; }
+ : LexSetStatement Statement_ { $$ = $2; }
;
-Declaration
+Declaration__
: FunctionDeclaration { $$ = $1; }
| LexicalDeclaration { $$ = $1; }
;
+Declaration_
+ : LexSetRegExp Declaration__ { $$ = $2; }
+ ;
+
+Declaration
+ : LexSetStatement Declaration_ { $$ = $2; }
+ ;
+
BreakableStatement
: IterationStatement { $$ = $1; }
| SwitchStatement { $$ = $1; }
/* }}} */
/* 12.1 Block {{{ */
Block_
- : Brace StatementListOpt "}" { $$ = $2; }
+ : BRACE StatementListOpt "}" { $$ = $2; }
;
Block
- : Block_ { $$ = CYNew CYBlock($1); }
+ : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
;
StatementList
StatementListItem
: Statement { $$ = $1; }
- | LexSetRegExp Declaration { $$ = $2; }
+ | Declaration { $$ = $1; }
;
/* }}} */
/* 12.2 Declarations {{{ */
: VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
;
-VariableDeclarationListNoIn_
- : "," VariableDeclarationListNoIn { $$ = $2; }
- | { $$ = NULL; }
- ;
-
-VariableDeclarationListNoIn
- : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = CYNew CYDeclarations($1, $2); }
- ;
-
VariableDeclaration
: BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
// XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
;
-VariableDeclarationNoIn
- : BindingIdentifier InitialiserNoInOpt { $$ = CYNew CYDeclaration($1, $2); }
- // XXX: | BindingPattern InitialiserNoIn { $$ = CYNew CYDeclaration($1, $2); }
- ;
-
Initialiser
: "=" AssignmentExpression { $$ = $2; }
;
: Initialiser { $$ = $1; }
| { $$ = NULL; }
;
-
-InitialiserNoIn
- : "=" AssignmentExpressionNoIn { $$ = $2; }
- ;
-
-InitialiserNoInOpt
- : InitialiserNoIn { $$ = $1; }
- | { $$ = NULL; }
- ;
/* }}} */
/* 12.2.4 Destructuring Binding Patterns {{{ */
// XXX: *
/* }}} */
/* 12.4 Expression Statement {{{ */
ExpressionStatement
- : ExpressionNoBF Terminator { $$ = CYNew CYExpress($1); }
+ : Expression Terminator { $$ = CYNew CYExpress($1); }
;
/* }}} */
/* 12.5 The if Statement {{{ */
/* }}} */
/* 12.6.3 The for Statement {{{ */
ForStatement
- : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($3, $5, $7, $9); }
+ : "for" "(" LexPushInOn ForStatementInitialiser LexPopIn ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
;
ForStatementInitialiser
- : ExpressionNoInOpt { $$ = $1; }
- | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = CYNew CYForDeclarations($3); }
+ : ExpressionOpt { $$ = $1; }
+ | LexSetRegExp "var" VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
;
/* }}} */
/* 12.6.4 The for-in Statement {{{ */
ForInStatement
- : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = CYNew CYForIn($3, $5, $7); }
+ : "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
;
ForInStatementInitialiser
: LeftHandSideExpression { $$ = $1; }
- | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
+ | LexSetRegExp "var" VariableDeclaration { $$ = $3; }
;
/* }}} */
;
CaseBlock
- : Brace CaseClausesOpt "}" { $$ = $2; }
+ : BRACE CaseClausesOpt "}" { $$ = $2; }
;
CaseClause
/* 13 Function Definition {{{ */
FunctionDeclaration
- : "function" Identifier "(" FormalParameterListOpt ")" Brace FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
+ : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
;
FunctionExpression
- : "function" IdentifierOpt "(" FormalParameterListOpt ")" Brace FunctionBody "}" { $$ = CYNew CYFunctionExpression($2, $4, $7); }
+ : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt LexPopIn ")" BRACE LexPushInOff FunctionBody LexPopIn "}" { $$ = CYNew CYFunctionExpression($2, $5, $10); }
;
FormalParameterList_
@begin ObjectiveC
/* Cycript (Objective-C): @class Declaration {{{ */
ClassSuperOpt
- /* XXX: why the hell did I choose MemberExpressionNoBF? */
- : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
+ /* XXX: why the hell did I choose MemberExpression? */
+ : ":" LexSetRegExp MemberExpression { $$ = $3; }
| { $$ = NULL; }
;
;
ClassFieldList
- : Brace ClassFieldListOpt "}" { $$ = NULL; }
+ : BRACE ClassFieldListOpt "}" { $$ = NULL; }
;
ClassFieldListOpt
;
ClassMessageDeclaration
- : MessageScope TypeOpt MessageParameters Brace FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
+ : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
;
ClassMessageDeclarationListOpt
;
ClassExpression
- : "@implementation" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassExpression($2, $3, $4, $5, $6); }
+ : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt LexPopIn "@end" { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
;
ClassStatement
- : "@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
+ : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
;
CategoryName
;
CategoryStatement
- : "@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
+ : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
;
-PrimaryExpressionBF
+PrimaryExpression
: ClassExpression { $$ = $1; }
;
-Statement_
+Statement__
: ClassStatement { $$ = $1; }
| CategoryStatement { $$ = $1; }
;
;
MessageExpression
- : "[" AssignmentExpression { driver.contexts_.push_back($2); } SelectorList "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($2, $4); }
- | "[" LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" { $$ = CYNew CYSendSuper($5); }
+ : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList LexPopIn "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
+ | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList LexPopIn "]" { $$ = CYNew CYSendSuper($6); }
;
SelectorExpression_
| { $$ = NULL; }
;
-PrimaryExpressionNo
+PrimaryExpression
: MessageExpression { $$ = $1; }
- | "@selector" "(" SelectorExpression ")" { $$ = CYNew CYSelector($3); }
+ | "@selector" "(" LexPushInOff SelectorExpression LexPopIn ")" { $$ = CYNew CYSelector($4); }
;
/* }}} */
/* Cycript (Objective-C): @import Directive {{{ */
@begin C
/* Cycript (C): Pointer Indirection/Addressing {{{ */
UnaryAssigneeExpression
- : "*" UnaryExpressionNoRE { $$ = CYNew CYIndirect($2); }
+ : "*" UnaryExpression { $$ = CYNew CYIndirect($2); }
;
UnaryExpression_
@end
/* YUI: Documentation Comments {{{ */
-Statement_
+Statement__
: Comment { $$ = $1; }
;
/* }}} */
;
/* }}} */
/* 11.1 Primary Expressions {{{ */
-PrimaryExpressionNo
+PrimaryExpression
: PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
| XMLInitialiser { $$ = $1; }
| XMLListInitialiser { $$ = $1; }
PropertySelector_
: PropertySelector { $$ = $1; }
- | "[" Expression "]" { $$ = CYNew CYSelector($2); }
+ | "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYSelector($3); }
;
PropertySelector
;
XMLElement
- : "<" XMLTagContent "/>" LexPop
- | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
+ : "<" LexPushInOff XMLTagContent LexPop LexPopIn "/>"
+ | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop LexPopIn ">"
;
XMLTagContent
;
XMLExpression
- : Brace LexPushRegExp Expression "}" LexPop
+ : BRACE LexPushRegExp Expression LexPop "}"
;
XMLTagName
/* }}} */
/* 11.1.5 XMLList Initialiser {{{ */
XMLListInitialiser
- : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = CYNew CYXMLList($3); }
+ : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop LexPopIn "</>" { $$ = CYNew CYXMLList($4); }
;
/* }}} */
/* 11.2 Left-Hand-Side Expressions {{{ */
: "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
;
-Statement_
+Statement__
: DefaultXMLNamespaceStatement { $$ = $1; }
; */
/* }}} */
;
ForComprehension
- : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
- | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForEachInComprehension($4, $6); }
+ : "for" "(" LexPushInOn Identifier LexPopIn "!in" Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
+ | "for" "each" "(" LexPushInOn Identifier LexPopIn "!in" Expression ")" { $$ = CYNew CYForEachInComprehension($5, $8); }
;
ComprehensionList
| { $$ = NULL; }
;
-PrimaryExpressionNo
- : "[" AssignmentExpression ComprehensionList "]" { $$ = CYNew CYArrayComprehension($2, $3); }
+PrimaryExpression
+ : "[" LexPushInOff AssignmentExpression ComprehensionList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
;
/* }}} */
/* JavaScript 1.7: for each {{{ */
ForInStatement
- : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = CYNew CYForEachIn($4, $6, $8); }
+ : "for" "each" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForEachIn($5, $8, $10); }
;
/* }}} */
-/* JavaScript 1.7: let Expressions {{{ */
-/*LetExpression
- : "let" "(" VariableDeclarationList ")" Expression { $$ = CYNew CYLetExpression($3, $5); }
- ;
-
-MemberExpression
- : LexSetRegExp LetExpression { $$ = $2; }
- ;*/
-/* }}} */
/* JavaScript 1.7: let Statements {{{ */
LetStatement
: "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
;
-Statement_
+Statement__
: LetStatement
;
/* }}} */
: "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
;
-RubyProcExpressionNoOA
- : "{" RubyProcParameters StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
- ;
-
-PrimaryExpressionNo
- : RubyProcExpressionNoOA { $$ = $1; }
- ;
-
-LeftHandSideExpression
- : LeftHandSideExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
- ;
-
-LeftHandSideExpressionNoBF
- : LeftHandSideExpressionNoBF RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
+PrimaryExpression
+ : "{" LexPushInOff RubyProcParameters StatementListOpt LexPopIn "}" { $$ = CYNew CYRubyProc($3, $4); }
;
-@begin C
-LeftHandSideExpressionNoRE
- : LeftHandSideExpressionNoRE RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
+CallExpression
+ : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
;
-@end
/* }}} */
%%