Alien-LibJIT
view release on metacpan or search on metacpan
libjit/tools/gen-rules-scanner.l view on Meta::CPAN
* <http://www.gnu.org/licenses/>.
*/
#include "gen-rules-parser.h"
#include <config.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#elif defined(HAVE_STRINGS_H)
# include <strings.h>
#endif
#ifndef HAVE_UNISTD_H
# define YY_NO_UNISTD_H
#endif
extern YYSTYPE yylval;
/*
* Current file and line number.
*/
char *gensel_filename = "";
long gensel_linenum = 1;
/*
* Return a token code from the lexical analyser.
*/
#define RETURNTOK(x) return (x)
/*
* Forward declarations.
*/
static void gensel_skip_comment(void);
static char *gensel_read_block(void);
static char *gensel_read_literal(void);
/*
* Duplicate a string.
*/
static char *gensel_strdup(const char *str)
{
char *new_str;
if(!str)
{
return 0;
}
new_str = (char *)malloc(strlen(str) + 1);
if(!new_str)
{
return 0;
}
strcpy(new_str, str);
return new_str;
}
%}
%option outfile="lex.yy.c"
%option noyywrap
%option nounput
DIGIT [0-9]
IDALPHA [a-zA-Z_]
WHITE [ \t\v\r\f]
%%
"->" { RETURNTOK(K_PTR); }
"any" { RETURNTOK(K_ANY); }
"all" { RETURNTOK(K_ALL); }
"imm" { RETURNTOK(K_IMM); }
"immzero" { RETURNTOK(K_IMMZERO); }
"imms8" { RETURNTOK(K_IMMS8); }
"immu8" { RETURNTOK(K_IMMU8); }
"imms16" { RETURNTOK(K_IMMS16); }
"immu16" { RETURNTOK(K_IMMU16); }
"imms32" { RETURNTOK(K_IMMS32); }
"immu32" { RETURNTOK(K_IMMU32); }
"local" { RETURNTOK(K_LOCAL); }
"frame" { RETURNTOK(K_FRAME); }
"ternary" { RETURNTOK(K_TERNARY); }
"branch" { RETURNTOK(K_BRANCH); }
"note" { RETURNTOK(K_NOTE); }
"copy" { RETURNTOK(K_COPY); }
"commutative" { RETURNTOK(K_COMMUTATIVE); }
"if" { RETURNTOK(K_IF); }
"clobber" { RETURNTOK(K_CLOBBER); }
"scratch" { RETURNTOK(K_SCRATCH); }
"space" { RETURNTOK(K_SPACE); }
"stack" { RETURNTOK(K_STACK); }
"x87_arith" { RETURNTOK(K_X87_ARITH); }
"x87_arith_reversible" { RETURNTOK(K_X87_ARITH_REVERSIBLE); }
"%inst_type" { RETURNTOK(K_INST_TYPE); }
"%regclass" { RETURNTOK(K_REG_CLASS); }
"%lregclass" { RETURNTOK(K_LREG_CLASS); }
"manual" { RETURNTOK(K_MANUAL); }
"more_space" { RETURNTOK(K_MORE_SPACE); }
"!"?{IDALPHA}({DIGIT}|{IDALPHA})* {
yylval.name = gensel_strdup(yytext);
if(!(yylval.name))
{
exit(1);
}
RETURNTOK(IDENTIFIER);
}
{WHITE}+ ;
\n { ++gensel_linenum; }
\" { yylval.name = gensel_read_literal();
RETURNTOK(LITERAL); }
"{" { yylval.code.filename = gensel_filename;
yylval.code.linenum = gensel_linenum;
yylval.code.block = gensel_read_block();
( run in 0.386 second using v1.01-cache-2.11-cpan-119454b85a5 )