]> Joshua Wise's Git repositories - snipe.git/blobdiff - parse/l2.lex
Initial import of l2c
[snipe.git] / parse / l2.lex
similarity index 66%
rename from parse/l1.lex
rename to parse/l2.lex
index a80f9369e8809fe8412f79a1aefe9ea4284a2d64..9caa8e1a829e4fc91469f47a958c4002372af63a 100644 (file)
@@ -1,7 +1,9 @@
-(* L1 Compiler
+(* L2 Compiler
  * Lexer
  * Author: Kaustuv Chaudhuri <kaustuv+@cs.cmu.edu>
  * Modified: Frank Pfenning <fp@cs.cmu.edu>
+ * Modified: Chris Lu <czl@andrew.cmu.edu>
+ * Modified: Joshua Wise <jwise@andrew.cmu.edu>
  *)
 
 structure A = Ast
@@ -49,7 +51,7 @@ in
 end
 
 %%
-%header (functor L1LexFn(structure Tokens : L1_TOKENS));
+%header (functor L2LexFn(structure Tokens : L2_TOKENS));
 %full
 %s COMMENT COMMENT_LINE;
 
@@ -76,14 +78,40 @@ ws = [\ \t\012];
 <INITIAL> "*="        => (Tokens.STAREQ (yypos, yypos + size yytext));
 <INITIAL> "/="        => (Tokens.SLASHEQ (yypos, yypos + size yytext));
 <INITIAL> "%="        => (Tokens.PERCENTEQ (yypos, yypos + size yytext));
+<INITIAL> "<<="       => (Tokens.LSHEQ (yypos, yypos + size yytext));
+<INITIAL> ">>="       => (Tokens.RSHEQ (yypos, yypos + size yytext));
+<INITIAL> "&="        => (Tokens.BITANDEQ (yypos, yypos + size yytext));
+<INITIAL> "^="        => (Tokens.BITXOREQ (yypos, yypos + size yytext));
+<INITIAL> "|="        => (Tokens.BITOREQ (yypos, yypos + size yytext));
 
 <INITIAL> "+"         => (Tokens.PLUS (yypos, yypos + size yytext));
 <INITIAL> "-"         => (Tokens.MINUS (yypos, yypos + size yytext));
+<INITIAL> "!"         => (Tokens.BANG (yypos, yypos + size yytext));
 <INITIAL> "*"         => (Tokens.STAR (yypos, yypos + size yytext));
 <INITIAL> "/"         => (Tokens.SLASH (yypos, yypos + size yytext));
 <INITIAL> "%"         => (Tokens.PERCENT (yypos, yypos + size yytext));
+<INITIAL> "<<"        => (Tokens.LSH (yypos, yypos + size yytext));
+<INITIAL> ">>"        => (Tokens.RSH (yypos, yypos + size yytext));
+<INITIAL> "||"        => (Tokens.LOGOR (yypos, yypos + size yytext));
+<INITIAL> "&&"        => (Tokens.LOGAND (yypos, yypos + size yytext));
+<INITIAL> "&"         => (Tokens.BITAND (yypos, yypos + size yytext));
+<INITIAL> "^"         => (Tokens.BITXOR (yypos, yypos + size yytext));
+<INITIAL> "|"         => (Tokens.BITOR (yypos, yypos + size yytext));
+<INITIAL> "~"         => (Tokens.BITNOT (yypos, yypos + size yytext));
+<INITIAL> "=="        => (Tokens.EQ (yypos, yypos + size yytext));
+<INITIAL> "!="        => (Tokens.NEQ (yypos, yypos + size yytext));
+<INITIAL> "<"         => (Tokens.LT (yypos, yypos + size yytext));
+<INITIAL> "<="        => (Tokens.LE (yypos, yypos + size yytext));
+<INITIAL> ">="        => (Tokens.GE (yypos, yypos + size yytext));
+<INITIAL> ">"         => (Tokens.GT (yypos, yypos + size yytext));
 
 <INITIAL> "return"    => (Tokens.RETURN (yypos, yypos + size yytext));
+<INITIAL> "if"        => (Tokens.IF (yypos, yypos + size yytext));
+<INITIAL> "while"     => (Tokens.WHILE (yypos, yypos + size yytext));
+<INITIAL> "for"       => (Tokens.FOR (yypos, yypos + size yytext));
+<INITIAL> "continue"  => (Tokens.CONTINUE (yypos, yypos + size yytext));
+<INITIAL> "break"     => (Tokens.BREAK (yypos, yypos + size yytext));
+<INITIAL> "else"      => (Tokens.ELSE (yypos, yypos + size yytext));
 
 <INITIAL> {decnum}    => (number (yytext, yypos));
 
This page took 0.079103 seconds and 4 git commands to generate.