[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / utils / ugen / lex.l
1 %{
2 #define YYSTYPE long
3
4 #ifdef __STDC__
5 #define PROTO(x)        x
6 #else
7 #define PROTO(x)        ()
8 #endif
9
10 # include "syntax.tab.h"
11 # include <stdio.h>
12 # include "id.h"
13 # include "tree.h"
14 # include "funs.h"
15 extern  YYSTYPE yylval;
16 extern  FILE *fc, *fhs;
17 #undef ECHO /* partain */
18 #define ECHO /*fprintf(stderr, "%s", yytext)*/
19
20 %}
21 %%
22 ";"                     { ECHO; return(SEMICOL); }
23 ":"                     { ECHO; return(COLON); }
24 "<"                     { ECHO; return(STDEF); }
25 ">"                     { ECHO; return(ENDDEF); }
26 "type"                  { ECHO; return(TYPE); }
27 "end"                   { ECHO; return(END); }
28 [A-Za-z][A-Za-z0-9_]*   {
29                                 ECHO;
30                                 yylval = (YYSTYPE) installid(yytext);
31                                 return(ID);
32                         }
33 .                       ECHO;
34 "\n"                    ECHO; 
35 "/*"([^*]|"*"[^/]|\n)*"*/" ECHO;
36 "%{{"([^%]|"%"[^}]|\n)*"%}}" { /* partain: for Haskell includes */
37                                 ECHO;
38                                 yytext[yyleng-3] = '\0';
39                                 fprintf(fhs, "\n%s",  &yytext[3]);
40                         }
41 "%{"([^%]|"%"[^}]|\n)*"%}" {
42                                 ECHO;
43                                 yytext[yyleng-2] = '\0';
44                                 fprintf(fc, "\n%s",  &yytext[2]);
45                         }
46 %%
47 int
48 yywrap()
49 {
50         return(1);
51 }