COMMON/xa-pre-process/xapp.l

35 lines
733 B
Plaintext
Raw Permalink Normal View History

2018-08-07 02:14:36 +00:00
%{
#include <stdio.h>
#include <string.h>
#include "xapp.tab.h"
2018-08-07 02:14:36 +00:00
%}
DEC [0-9]+(\.[0-9]+)?
HEX \$[0-9A-Fa-f]+(\.[0-9A-Fa-f]+)?
OCT &[0-7]+(\.[0-7]+)?
BIN %[01]+(\.[01]+)?
%%
[A-Za-z_][A-Za-z0-9_]* { strncpy(yylval.sval, yytext, sizeof(yylval.sval)); return IDENTIFIER; }
{DEC}|{HEX}|{OCT}|{BIN} { strncpy(yylval.sval, yytext, sizeof(yylval.sval)); return CONSTANT; }
"<<" return LEFT_OP;
">>" return RIGHT_OP;
(<=)|(=<) return LE_OP;
(>=)|(=>) return GE_OP;
(<>)|(><) return NE_OP;
"&&" return AND_OP;
"||" return OR_OP;
[ \t\r\n]+ ; /* Ignore whitespace */
2018-08-07 02:14:36 +00:00
[-()<>+~!*/%=&^|] return yytext[0];
. { fprintf(stderr, "SET (invalid character '%s')\n", yytext); exit(1); }
%%
int yywrap(void) {
return 1;
}