%{
//////////////////////////////////////////////////////////////////////////////
//Copyright 2008
// Andrew Gacek, Steven Holte, Gopalan Nadathur, Xiaochu Qi, Zach Snow
//////////////////////////////////////////////////////////////////////////////
// This file is part of Teyjus. //
// //
// Teyjus is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// (at your option) any later version. //
// //
// Teyjus is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with Teyjus. If not, see . //
//////////////////////////////////////////////////////////////////////////////
#include "y.tab.h"
#include
#include
static int commentLev = 0;
%}
LETTER [A-Za-z]
DIGIT [0-9]
SYMBOL "_"|"+"|"-"|"*"|"/"|"!"|"~"|"@"|"$"|"%"|"^"|"&"|"*"|"<"|">"|"="|"'"|":"|","
ID ({LETTER}|{SYMBOL})({LETTER}|{DIGIT}|{SYMBOL})*
NUM {DIGIT}+
WSPACE [ \t]+
STRING [^*/]+
STRING2 [^}]+
%x COMMENT COMMENT2 INCLUDE
%%
"\n" {continue; }
";" {return SEMICOLON; }
"[" {return LBRACKET; }
"]" {return RBRACKET; }
"OPERAND TYPES" {return OPTYPES; }
"OPCODE" {return OPCODE; }
"INSTR CATEGORY" {return INSTRCAT; }
"MAX OPERAND" {return MAXOPERAND; }
"CALL_I1_LEN" {return CALL_I1_LEN; }
"INSTRUCTIONS" {return INSTRUCTIONS; }
{WSPACE} {continue; }
"/%" {commentLev = 1; BEGIN(COMMENT); continue; }
"/*" {BEGIN(COMMENT2); continue; }
"{" {BEGIN(INCLUDE); continue; }
{ID} {yylval.name = strdup(yytext); return ID; }
{NUM} {yylval.isval.ival = atoi(yytext);
yylval.isval.sval = strdup(yytext);
return NUM; }
"*/" {BEGIN(INITIAL); continue; }
{STRING} {yylval.text = strdup(yytext); return STRING; }
[^%/\n]+ {continue; }
"/%" {commentLev++; continue; }
"%/" {commentLev--;
if (!commentLev) BEGIN(INITIAL); continue; }
"}" {BEGIN(INITIAL); continue; }
{STRING2} {yylval.text = strdup(yytext); return STRING2; }
. {return ERROR; }