%x COMMENT CODE %{ /* * $Header: /usr/build/vile/vile/filters/RCS/rexxfilt.l,v 1.7 2003/05/20 20:38:41 tom Exp $ * * Filter to add vile "attribution" sequences to selected bits of REXX source * - T.Dickey */ #include DefineFilter("rexx"); static char *Comment_attr; static char *Number_attr; static char *String_attr; static int my_state; %} SSTRING \'([^'])*\' DSTRING \"([^"])*\" STRINGS ({SSTRING}|{DSTRING}) KEYWORD [a-zA-Z@#$!?_][a-zA-Z0-9.@#$!?_]* SIGN [-+] DECIMAL [0-9_]+ OCTAL 0[0-7_]+ HEXADECIMAL 0x[0-9a-fA-F_]+ REAL [-+]?([0-9_]*\.[0-9][0-9_]*)([eE][+-]?[0-9_]+)? NUMBER {SIGN}?({DECIMAL}|{OCTAL}|{HEXADECIMAL}|{REAL}) %% {KEYWORD} { WriteToken(ci_keyword_attr(yytext)); } "/*" { WriteToken(Comment_attr); BEGIN(COMMENT); } [^*]* { WriteToken(Comment_attr); } "*"+[^*/]* { WriteToken(Comment_attr); } "*"+"/" { WriteToken(Comment_attr); BEGIN(my_state); } {STRINGS} { WriteToken(String_attr); } {NUMBER} { WriteToken(Number_attr); } %% static void init_filter(int before GCC_UNUSED) { } static void do_filter(FILE *inputs) { yyin = inputs; Comment_attr = class_attr(NAME_COMMENT); Number_attr = class_attr(NAME_NUMBER); String_attr = class_attr(NAME_LITERAL); my_state = CODE; BEGIN(my_state); while (yylex() > 0) { } }