%{ /* * Purpose: reads from the .obj file and sends tokens to the * parser * * Use lex or flex to translate this source into C and then * compile normally using a C compiler. * * extern: - lineno (for error reporting purposes) * * Modified version of Sam Samai's o2r_lex.l * * Updated: 4/5/95 * */ #ifdef LEX_DEBUG #include "lex_debug.i" int yynerrs = 0; #else /*#include "database.h"*/ #include "obj_gram.tab.h" #define token(x) x #endif /* * */ #include #ifdef DEBUG #define DBG(s) s #else #define DBG(s) #endif #define MAX_STR_LEN 512 /* maximum length of type String */ #define END(v) (v-1 + sizeof v / sizeof v[0]) #define yywrap() (1) static int screen(void); static void getstring(void); int ignore = 0; extern int lineno; %} letter [a-zA-Z_] digit [0-9] sign [-]? exp [Ee][-+]?{digit}+ letter_or_digit [a-zA-Z_0-9/] white_space [ \t\n] blank [ \t] other . %% ^"#>con"{white_space}*$ { DBG(printf("Comment On\n");)ignore = 1;lineno++;} ^"#>coff"{white_space}*$ { DBG(printf("Comment Off\n");)ignore = 0;lineno++;} ^"#"[^">"].* { lineno++;} ^"#>" { if(!ignore) return screen();} \" { printf("STRING!\n");getstring(); return token(String);} "/"?{letter}{letter_or_digit}*"."?{letter_or_digit}* {if(!ignore) return screen();} {sign}{digit}+ | {sign}{digit}+"."{digit}*({exp})? | {sign}{digit}*"."{digit}+({exp})? | {sign}{digit}+{exp} { if (!ignore) { yylval.y_scl = atof(yytext); return token(Const); } } {white_space}+ ; {other} {if (!ignore) return token(yytext[0]);} %% #include "raw_tab.h" static char strspace[MAX_STR_LEN]; static void getstring(void) { int i, finished = 0; char c; for (i=0; irw_name, yytext)) == 0) return mid->rw_yylex; else if (c < 0) low = mid + 1; else high = mid - 1; } yylval.y_str = yytext; return token(Identifier); }