%s CODE NOTE EXP1 EXP2 %{ /* * $Header: /usr/build/vile/vile/filters/RCS/est-filt.l,v 1.3 2003/05/20 20:38:41 tom Exp $ * * Filter to add vile "attribution" sequences to selected bits of enscript * syntax-description files. */ #include DefineFilter("est"); static char *Comment_attr; static char *Ident_attr; static char *Keyword_attr; static char *Number_attr; static char *String_attr; %} SSTRING \'(\\.|[^'\\])*\' DSTRING \"((\\\")|[^"\n])*\" KEYWORD [a-zA-Z_][a-zA-Z_0-9]* IDENT \$[a-zA-Z_0-9]+ SIGN [-+] INTEGER {SIGN}?([0-9]+) REAL {SIGN}?[0-9]+\.[0-9]*|{SIGN}?\.[0-9]+ RANGE "["(\\.|.)+"]" %% "/*" { BeginQuote(NOTE, Comment_attr); } "*"[^/] { flt_bfr_append(yytext, yyleng); } \n { flt_bfr_append(yytext, yyleng); } [^*\n] { flt_bfr_append(yytext, yyleng); } "*/" { FinishQuote(CODE); } {KEYWORD} { WriteToken(keyword_attr(yytext)); } {INTEGER} | {REAL} { WriteToken(Number_attr); } {IDENT} { WriteToken(Ident_attr); } {SSTRING} { WriteToken(String_attr); } {DSTRING} { WriteToken(String_attr); } "/" { BeginQuote(EXP1, String_attr); } \\. { flt_bfr_append(yytext, yyleng); BEGIN(EXP2); } {RANGE} { flt_bfr_append(yytext, yyleng); BEGIN(EXP2); } [^*\\] { flt_bfr_append(yytext, yyleng); BEGIN(EXP2); } \\. { flt_bfr_append(yytext, yyleng); } {RANGE} { flt_bfr_append(yytext, yyleng); } [^/] { flt_bfr_append(yytext, yyleng); } "/" { FinishQuote(CODE); } %% static void init_filter(int before GCC_UNUSED) { } static void do_filter(FILE *inputs) { yyin = inputs; Comment_attr = class_attr(NAME_COMMENT); Ident_attr = class_attr(NAME_IDENT); Keyword_attr = class_attr(NAME_KEYWORD); Number_attr = class_attr(NAME_NUMBER); String_attr = class_attr(NAME_LITERAL); BEGIN(CODE); while (yylex() > 0) { } flt_bfr_error(); }