/**************************************** readpar.l the (f)lex description for parameter list Chimera Acquisizione e. de filippo ver 0.1 (November 2010) *****************************************/ %{ #include "TCHIEvent.h" #include "readpar.tab.h" %} %option noyywrap yylineno %s slcomment digit [0-9] id [A-Za-z0-9]+ eol \n cs "/" space [ \t]+ equal "=" hash "#" mod [Mm][Oo][Dd] par [Pp][Aa][Rr] addr [Aa][Dd][Dd][Rr] crate [Cc][Rr][Aa][Tt][Ee] board [Bb][Oo][Aa][Rr][Dd] tel [Tt][Ee][Ll] postel [Pp][Oo][Ss][Tt][Ee][Ll] %% "*" BEGIN(slcomment); [^\n]* {BEGIN(INITIAL);} {eol} {BEGIN(INITIAL);} {eol} {return(EOL);} {cs} {return(SLASH);} {hash} {return(HASH);} {space} ; {cs}{space} {warning(yylineno, "/ not followed by a command", yytext);} {digit}+ { yylval.i_value = atoi(yytext); return(NUM); } \"[^"\n]*(\"|\n) { if(yyleng[yytext-1]=='\n') { warning(yylineno, "Missing \" ", yytext); } else { strcpy(yylval.s_value, yytext+1); yylval.s_value[yyleng-2]='\0'; return(STRING); } } "QDC" { yylval.mod_value=QDC; return(MODULE); } "TDC" { yylval.mod_value=TDC; return(MODULE); } "ADC" {yylval.mod_value=ADC; return(MODULE);} {mod} {return(MOD);} {par} {return(PAR);} {addr} {return(ADDR);} {crate} {return(CRATE);} {board} {return(BOARD);} {tel} {return(TEL);} {equal} {return(EQUAL);} {postel} {return(POSTEL);} \r {} /* discard line-break for not-unix format ASCII files */ {id} {warning(yylineno, "Not recognized token", yytext);} . {warning(yylineno, "Not recognized symbol", yytext);} %% int ParseParFile(FILE *fd) { yylineno = 1; yyin = fd; do { yyparse(); }while(!feof(yyin)); return yylineno; } void yyerror(const char *str) { printf("Syntax error at line: %d \n", yylineno); TCHIEvent::fnumerrors++; } void warning(int line, const char *str, char *symb) { printf("line>> %d: %s (%s)\n", line, str, symb); }