%s NORMAL COMMENT QUERY %{ /* * $Header: /usr/build/vile/vile/filters/RCS/ecl-filt.l,v 1.2 2003/05/20 20:38:41 tom Exp $ * * Filter to add vile "attribution" sequences to Prolog/ECLiPSe code * * Joachim Schimpf (j.schimpf@ic.ac.uk) */ #include DefineFilter("ecl"); static char *Comment_attr; static char *Preproc_attr; %} LINECOMMENT %.*\n BRCOMMENT "/*"[^*]*[*]+([^*/][^*]*[*]*)*"/" BRCOMMENT1 "/*"[/]?(([^*][/]+)|[^/])*"*/" KEYWORD [a-z][a-zA-Z0-9_]* STARTQUERY ^[:?]-/[a-z \t\n] SSTRING \'(\\.|\\\n|[^'\\])*\' DSTRING \"(\\.|\\\n|[^"\\])*\" STRINGS ({SSTRING}|{DSTRING}) %% {KEYWORD} { WriteToken(keyword_attr(yytext)); } {LINECOMMENT} { WriteToken(Comment_attr); } {BRCOMMENT} { WriteToken(Comment_attr); } {STARTQUERY} { WriteToken(Preproc_attr); BEGIN(QUERY); } \./[ \t\n] { WriteToken(Preproc_attr); BEGIN(NORMAL); } {STRINGS} { WriteToken(Preproc_attr); } {LINECOMMENT} { WriteToken(Comment_attr); } {BRCOMMENT} { WriteToken(Comment_attr); } . { WriteToken(Preproc_attr); } 0\' { ECHO; } {STRINGS} { ECHO; } . { ECHO; } %% static void init_filter(int before GCC_UNUSED) { } static void do_filter(FILE *inputs) { yyin = inputs; Comment_attr = class_attr(NAME_COMMENT); Preproc_attr = class_attr(NAME_PREPROC); BEGIN(NORMAL); while (yylex() > 0) { } }