%{
-#include "Cycript.tab.h"
+#include "Cycript.tab.hh"
+typedef cy::parser::token tk;
+#define YY_EXTRA_TYPE CYParser *
%}
%option prefix="cy"
%option yylineno
%option nounput
%option interactive
+%option reentrant
-delim [ \t]
-whitesp {delim}+
-digit [0-9]
-number [-]?{digit}*[.]?{digit}+
+Exponent [eE][+-]?[0-9]+
+Escape \\['"\\bfnrtv]|\\0|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}
%%
-"&" { return CYTokenAmpersand; }
-"&&" { return CYTokenAmpersandAmpersand; }
-"&=" { return CYTokenAmpersandEqual; }
-"^" { return CYTokenCarrot; }
-"^=" { return CYTokenCarrotEqual; }
-"=" { return CYTokenEqual; }
-"==" { return CYTokenEqualEqual; }
-"===" { return CYTokenEqualEqualEqual; }
-"!" { return CYTokenExclamation; }
-"!=" { return CYTokenExclamationEqual; }
-"!==" { return CYTokenExclamationEqualEqual; }
-"-" { return CYTokenHyphen; }
-"-=" { return CYTokenHyphenEqual; }
-"--" { return CYTokenHyphenHyphen; }
-"->" { return CYTokenHyphenRight; }
-"<" { return CYTokenLeft; }
-"<=" { return CYTokenLeftEqual; }
-"<<" { return CYTokenLeftLeft; }
-"<<=" { return CYTokenLeftLeftEqual; }
-"%" { return CYTokenPercent; }
-"%=" { return CYTokenPercentEqual; }
-"." { return CYTokenPeriod; }
-"|" { return CYTokenPipe; }
-"|=" { return CYTokenPipeEqual; }
-"||" { return CYTokenPipePipe; }
-"+" { return CYTokenPlus; }
-"+=" { return CYTokenPlusEqual; }
-"++" { return CYTokenPlusPlus; }
-">" { return CYTokenRight; }
-">=" { return CYTokenRightEqual; }
-">>" { return CYTokenRightRight; }
-">>=" { return CYTokenRightRightEqual; }
-">>>" { return CYTokenRightRightRight; }
-">>>=" { return CYTokenRightRightRightEqual; }
-"/" { return CYTokenSlash; }
-"/=" { return CYTokenSlashEqual; }
-"*" { return CYTokenStar; }
-"*=" { return CYTokenStarEqual; }
-"~" { return CYTokenTilde; }
-
-"break" { return CYTokenBreak; }
-"case" { return CYTokenCase; }
-"catch" { return CYTokenCatch; }
-"continue" { return CYTokenContinue; }
-"default" { return CYTokenDefault; }
-"delete" { return CYTokenDelete; }
-"do" { return CYTokenDo; }
-"else" { return CYTokenElse; }
-"false" { return CYTokenFalse; }
-"finally" { return CYTokenFinally; }
-"for" { return CYTokenFor; }
-"function" { return CYTokenFunction; }
-"if" { return CYTokenIf; }
-"in" { return CYTokenIn; }
-"instanceof" { return CYTokenInstanceOf; }
-"new" { return CYTokenNew; }
-"null" { return CYTokenNull; }
-"return" { return CYTokenReturn; }
-"switch" { return CYTokenSwitch; }
-"this" { return CYTokenThis; }
-"throw" { return CYTokenThrow; }
-"true" { return CYTokenTrue; }
-"try" { return CYTokenTry; }
-"typeof" { return CYTokenTypeOf; }
-"var" { return CYTokenVar; }
-"void" { return CYTokenVoid; }
-"while" { return CYTokenWhile; }
-"with" { return CYTokenWith; }
+"&" return tk::Ampersand;
+"&&" return tk::AmpersandAmpersand;
+"&=" return tk::AmpersandEqual;
+"^" return tk::Carrot;
+"^=" return tk::CarrotEqual;
+"=" return tk::Equal;
+"==" return tk::EqualEqual;
+"===" return tk::EqualEqualEqual;
+"!" return tk::Exclamation;
+"!=" return tk::ExclamationEqual;
+"!==" return tk::ExclamationEqualEqual;
+"-" return tk::Hyphen;
+"-=" return tk::HyphenEqual;
+"--" return tk::HyphenHyphen;
+"->" return tk::HyphenRight;
+"<" return tk::Left;
+"<=" return tk::LeftEqual;
+"<<" return tk::LeftLeft;
+"<<=" return tk::LeftLeftEqual;
+"%" return tk::Percent;
+"%=" return tk::PercentEqual;
+"." return tk::Period;
+"|" return tk::Pipe;
+"|=" return tk::PipeEqual;
+"||" return tk::PipePipe;
+"+" return tk::Plus;
+"+=" return tk::PlusEqual;
+"++" return tk::PlusPlus;
+">" return tk::Right;
+">=" return tk::RightEqual;
+">>" return tk::RightRight;
+">>=" return tk::RightRightEqual;
+">>>" return tk::RightRightRight;
+">>>=" return tk::RightRightRightEqual;
+"/" return tk::Slash;
+"/=" return tk::SlashEqual;
+"*" return tk::Star;
+"*=" return tk::StarEqual;
+"~" return tk::Tilde;
+
+":" return tk::Colon;
+"," return tk::Comma;
+"?" return tk::Question;
+";" return tk::SemiColon;
+
+"(" return tk::OpenParen;
+")" return tk::CloseParen;
+
+"{" return tk::OpenBrace;
+"}" return tk::CloseBrace;
+
+"[" return tk::OpenBracket;
+"]" return tk::CloseBracket;
+
+"break" return tk::Break;
+"case" return tk::Case;
+"catch" return tk::Catch;
+"continue" return tk::Continue;
+"default" return tk::Default;
+"delete" return tk::Delete;
+"do" return tk::Do;
+"else" return tk::Else;
+"false" return tk::False;
+"finally" return tk::Finally;
+"for" return tk::For;
+"function" return tk::Function;
+"if" return tk::If;
+"in" return tk::In;
+"instanceof" return tk::InstanceOf;
+"new" return tk::New;
+"null" return tk::Null;
+"return" return tk::Return;
+"switch" return tk::Switch;
+"this" return tk::This;
+"throw" return tk::Throw;
+"true" return tk::True;
+"try" return tk::Try;
+"typeof" return tk::TypeOf;
+"var" return tk::Var;
+"void" return tk::Void;
+"while" return tk::While;
+"with" return tk::With;
+
+[a-zA-Z$_][a-zA-Z$_0-9]* return tk::Identifier;
+
+(\.[0-9]+|(0|[1-9][0-9]*)(\.[0-9]*)?){Exponent}? return tk::NumericLiteral;
+
+0[xX][0-9a-fA-F]+ return tk::NumericLiteral;
+0[bB][0-1]+ return tk::NumericLiteral;
+
+\"([^"\\\n]|{Escape})*\" return tk::StringLiteral;
+'([^'\\\n]|{Escape})*' return tk::StringLiteral;
+
+[ \t\n] ;
+
+%%
+
+void CYParser::ScannerInit() {
+ cylex_init(&scanner_);
+ cyset_extra(this, scanner_);
+}
+
+void CYParser::ScannerDestroy() {
+ cylex_destroy(scanner_);
+}