Alien-LibJIT
view release on metacpan or search on metacpan
libjit/tools/gen-ops-scanner.l view on Meta::CPAN
*/
#include "gen-ops-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 *genops_filename = "";
long genops_linenum = 1;
/*
* Return a token code from the lexical analyser.
*/
#define RETURNTOK(x) return (x)
/*
* Forward declarations.
*/
static void genops_skip_comment(void);
static char *genops_read_code_block(void);
static char *genops_read_header_block(void);
static char *genops_read_literal(void);
/*
* Duplicate a string.
*/
static char *genops_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]
%%
"empty" { RETURNTOK(K_EMPTY); }
"int" { RETURNTOK(K_INT); }
"long" { RETURNTOK(K_LONG); }
"ptr" { RETURNTOK(K_PTR); }
"float32" { RETURNTOK(K_FLOAT32); }
"float64" { RETURNTOK(K_FLOAT64); }
"nfloat" { RETURNTOK(K_NFLOAT); }
"any" { RETURNTOK(K_ANY); }
"neg" { RETURNTOK(K_NEG); }
"<<" { RETURNTOK(K_SHL); }
">>" { RETURNTOK(K_SHR); }
"shr_un" { RETURNTOK(K_SHR_UN); }
"==" { RETURNTOK(K_EQ); }
"!=" { RETURNTOK(K_NE); }
"<=" { RETURNTOK(K_LE); }
">=" { RETURNTOK(K_GE); }
"address_of" { RETURNTOK(K_ADDRESS_OF); }
"address_of_label" { RETURNTOK(K_ADDRESS_OF_LABEL); }
"branch" { RETURNTOK(K_BRANCH); }
"call" { RETURNTOK(K_CALL); }
"call_external" { RETURNTOK(K_CALL_EXTERNAL); }
"jump_table" { RETURNTOK(K_JUMP_TABLE); }
"op_def" { RETURNTOK(K_OP_DEF); }
"op_intrinsic" { RETURNTOK(K_OP_INTRINSIC); }
"op_type" { RETURNTOK(K_OP_TYPE); }
"op_values" { RETURNTOK(K_OP_VALUES); }
"opcodes" { RETURNTOK(K_OPCODES); }
"reg" { RETURNTOK(K_REG); }
"%option" { RETURNTOK(K_POPTION); }
"i_i" { RETURNTOK(K_i_i); }
"i_ii" { RETURNTOK(K_i_ii); }
"i_piii" { RETURNTOK(K_i_piii); }
"i_iI" { RETURNTOK(K_i_iI); }
"i_II" { RETURNTOK(K_i_II); }
"I_I" { RETURNTOK(K_I_I); }
"I_II" { RETURNTOK(K_I_II); }
"i_pIII" { RETURNTOK(K_i_pIII); }
"l_l" { RETURNTOK(K_l_l); }
"l_ll" { RETURNTOK(K_l_ll); }
"i_plll" { RETURNTOK(K_i_plll); }
"i_l" { RETURNTOK(K_i_l); }
"i_ll" { RETURNTOK(K_i_ll); }
"l_lI" { RETURNTOK(K_l_lI); }
"L_L" { RETURNTOK(K_L_L); }
"L_LL" { RETURNTOK(K_L_LL); }
"i_pLLL" { RETURNTOK(K_i_pLLL); }
"i_LL" { RETURNTOK(K_i_LL); }
"L_LI" { RETURNTOK(K_L_LI); }
"f_f" { RETURNTOK(K_f_f); }
"f_ff" { RETURNTOK(K_f_ff); }
"i_f" { RETURNTOK(K_i_f); }
( run in 0.493 second using v1.01-cache-2.11-cpan-0068ddc7af1 )