]> git.saurik.com Git - cycript.git/blobdiff - Cycript.l
Finished JS Bison/Flex parser.
[cycript.git] / Cycript.l
index 10be43f1a9af6a725cf2ed2f9b15705ea0fc251e..24e72d7c1a87eded81d10264ec670b576f299436 100644 (file)
--- a/Cycript.l
+++ b/Cycript.l
@@ -17,71 +17,88 @@ number        [-]?{digit}*[.]?{digit}+
 
 %%
 
-"&"    { 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; }
+"&"    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 CYTokenColon;
+","    return CYTokenComma;
+"?"    return CYTokenQuestion;
+";"    return CYTokenSemiColon;
+
+"("    return CYTokenOpenParen;
+")"    return CYTokenCloseParen;
+"{"    return CYTokenOpenBrace;
+"}"    return CYTokenCloseBrace;
+"["    return CYTokenOpenBracket;
+"]"    return CYTokenCloseBracket;
+
+"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;
+
+[a-zA-Z$_][a-zA-Z$_0-9]* return CYTokenIdentifier;
+[0-9]+                   return CYTokenNumber;
+
+[ \t\n]                  ;