URL
https://opencores.org/ocsvn/tinyvliw8/tinyvliw8/trunk
Subversion Repositories tinyvliw8
[/] [tinyvliw8/] [trunk/] [tools/] [asm/] [src/] [tokens.l] - Rev 6
Compare with Previous | Blame | View Log
/**
* \file tokens.l
*/
%{
# include "parser.h"
extern void nextline();
extern void yyerror(const char *s);
// extern int yylval;
%}
%%
".equ" { return CONSTSEC; }
".res" { return RESSEC; }
".code" { return CODESEC; }
".irq"[0-3] { yylval.num = yytext[4] - '0'; return IRQSEC; }
"ldi" { return LOADI; }
"ld" { return LOAD; }
"sti" { return STOREI; }
"st" { return STORE; }
"rla" { return RLA; }
"rlc" { return RLC; }
"rra" { return RRA; }
"rrc" { return RRC; }
"mov" { return MOVE; }
"addi" { return ADDI; }
"add" { return ADD; }
"or" { return OR; }
"xor" { return XOR; }
"xnor" { return XNOR; }
"nor" { return NOR; }
"and" { return AND; }
"nand" { return NAND; }
"jmp" { return JMP; }
"jnz" { return JNZ; }
"jz" { return JZ; }
"jc" { return JC; }
":" { return COLON; }
";" { return SEMICOLON; }
"+" { return PLUS; }
"-" { return MINUS; }
"~" { return TILDE; }
"|" { return PIPE; }
"$" { return DOLLAR; }
"#" { return HASH; }
"@" { return AT; }
"," { return COMMA; }
r[0-7] { yylval.num = yytext[1] - '0'; return REG; }
0x[0-9a-f][0-9a-f] { yylval.num = strtol(&yytext[2], 0, 16); return HEXNUM; }
0x[0-7][0-9a-f][0-9a-f] { yylval.num = strtol(&yytext[2], 0, 16); return HEXADDR; }
[_0-9a-z]+ { yylval.str = strdup(yytext); return NAME; }
[A-Z]+ { yylval.str = strdup(yytext); return UNAME; }
[ \r\t] { ; }
\n { nextline(); return NEWLINE;}
"//".*\n { nextline(); return NEWLINE;}
. { yyerror("illegal token\n"); }
%%
#ifndef yywrap
yywrap() { return 1; }
#endif