summaryrefslogtreecommitdiff
path: root/plugins/govm/tok.l
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-11-18 22:56:59 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-11-18 22:56:59 (GMT)
commit26d75963fba34d8e5a5b9a6186604110552f3a38 (patch)
tree96c227003d0a1c8f71d2378d8e4477b963909708 /plugins/govm/tok.l
parent51e5dac69a78930fb05ccd8d9cfe59b9cd51c03a (diff)
Provided a small assembler for the GoVM architecture.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@136 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/govm/tok.l')
-rw-r--r--plugins/govm/tok.l63
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/govm/tok.l b/plugins/govm/tok.l
new file mode 100644
index 0000000..adec51d
--- /dev/null
+++ b/plugins/govm/tok.l
@@ -0,0 +1,63 @@
+%{
+
+#include "gram.h"
+
+%}
+
+%option noinput
+%option nounput
+%option noyywrap
+%option yylineno
+
+%%
+
+;[^$]* return COMMENT;
+
+add return ADD;
+and return AND;
+call return CALL;
+div return DIV;
+dup return DUP;
+equ return EQU;
+goe return GOE;
+gt return GT;
+jmp return JMP;
+jz return JZ;
+lb return LB;
+li return LI;
+loe return LOE;
+lt return LT;
+lws return LWS;
+lw return LW;
+mul return MUL;
+nop return NOP;
+nor return NOR;
+not return NOT;
+or return OR;
+pop return POP;
+push return PUSH;
+rot3 return ROT3;
+rot return ROT;
+salloc return SALLOC;
+sb return SB;
+shl return SHL;
+shr return SHR;
+sub return SUB;
+sws return SWS;
+sw return SW;
+syscall return SYSCALL;
+xor return XOR;
+
+0x[0-9a-f]{1,4} { yylval.number = strtol(yytext + 2, NULL, 16); return NUMBER; }
+[A-Za-z0-9]+: { yylval.text = yytext; return LABEL; }
+
+a return REG_A;
+b return REG_B;
+c return REG_C;
+d return REG_D;
+e return REG_E;
+f return REG_F;
+
+[A-Za-z0-9]+ { yylval.text = yytext; return TEXT; }
+
+[ \t]+