]> git.saurik.com Git - cycript.git/commitdiff
Maybe finished lexer.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 29 Sep 2009 23:44:55 +0000 (23:44 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 29 Sep 2009 23:44:55 +0000 (23:44 +0000)
Cycript.l
Cycript.y

index b1aa8a645fadbafae50774fef9863ba0e3f52e7a..1424d1e7e91c3114a6bddbc9a8d9e78851ec7561 100644 (file)
--- a/Cycript.l
+++ b/Cycript.l
@@ -13,10 +13,8 @@ typedef cy::parser::token tk;
 %option interactive
 %option reentrant
 
 %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}
 
 %%
 
 
 %%
 
@@ -104,7 +102,14 @@ number        [-]?{digit}*[.]?{digit}+
 "with"       return tk::With;
 
 [a-zA-Z$_][a-zA-Z$_0-9]* return tk::Identifier;
 "with"       return tk::With;
 
 [a-zA-Z$_][a-zA-Z$_0-9]* return tk::Identifier;
-[0-9]+                   return tk::NumericLiteral;
+
+(\.[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]                  ;
 
 
 [ \t\n]                  ;
 
index 0ecb777b42b9fd0b4cc72c355856e9592373ed95..0cfbe6e062f0922e0e083e2b59eddb7e71b1672f 100644 (file)
--- a/Cycript.y
+++ b/Cycript.y
@@ -120,6 +120,43 @@ int cylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
 
 %start Program;
 
 
 %start Program;
 
+WordOpt
+    : Word
+    |
+    ;
+
+Word
+    : Identifier
+    | "break"
+    | "case"
+    | "catch"
+    | "continue"
+    | "default"
+    | "delete"
+    | "do"
+    | "else"
+    | "false"
+    | "finally"
+    | "for"
+    | "function"
+    | "if"
+    | "in"
+    | "instanceof"
+    | "new"
+    | "null"
+    | "return"
+    | "switch"
+    | "this"
+    | "throw"
+    | "true"
+    | "try"
+    | "typeof"
+    | "var"
+    | "void"
+    | "while"
+    | "with"
+    ;
+
 IdentifierOpt
     : Identifier
     |
 IdentifierOpt
     : Identifier
     |
@@ -153,12 +190,12 @@ SelectorCall_
     ;
 
 SelectorCall
     ;
 
 SelectorCall
-    : IdentifierOpt ":" AssignmentExpression SelectorCall_
+    : WordOpt ":" AssignmentExpression SelectorCall_
     ;
 
 SelectorList
     : SelectorCall
     ;
 
 SelectorList
     : SelectorCall
-    | Identifier
+    | Word
     ;
 
 ObjectiveCall
     ;
 
 ObjectiveCall