]> khamidou — GitHub mirrors - miniforth.git/commitdiff
added support for comments in as
authorkhamidou <khamidou@gmail.com>
Tue, 18 Jan 2011 08:04:43 +0000 (09:04 +0100)
committerkhamidou <khamidou@gmail.com>
Tue, 18 Jan 2011 08:04:43 +0000 (09:04 +0100)
aslexer.l

index 37f1e6b7f965b98b65a2a74de331e40b49139c06..d03f84af0d5831ea26c600f545d52116d93a9d63 100644 (file)
--- a/aslexer.l
+++ b/aslexer.l
@@ -3,9 +3,18 @@
        #include "tokens.h"
 %}
 
+%s in_comment
 %%
 
 <<EOF>>                { return -1;            }
+
+
+;              BEGIN(in_comment);
+<in_comment>\n   BEGIN(INITIAL);
+<in_comment>[^\n]+    // eat comment
+<in_comment>;       // eat the lone ';'
+
+
 "push"         { return T_PUSH;        }
 "pop"          { return T_POP;         }
 "nop"          { return T_NOP;         }
 "inc"          { return T_INC;         }
 "dec"          { return T_DEC;         }
 "call"         { return T_CALL;        }
+"ret"          { return T_RET; }
 "jmp"          { return T_JMP;         }
 [ \t\n]+       /* ignore whitespace */
 
 [0-9]+         { return NUMBER;        }
-;              { return COMMA;         }
 [a-zA-Z][a-zA-Z0-9]*:  { return T_LABEL;       }
 [a-zA-Z][a-zA-Z0-9]*   { return WORD;  }