PIPS
lexer.l
Go to the documentation of this file.
1 /*
2 
3  $Id: lexer.l 23128 2016-07-01 11:58:21Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 %option nounput
26 %option noinput
27 %start COMMENT TEXT
28 
29 %{
30 #ifdef HAVE_CONFIG_H
31  #include "pips_config.h"
32 #endif
33 #include <stdio.h>
34 #include <string.h>
35 #include "genC.h"
36 #include "makefile.h"
37 #include "readmakefile.h"
38 %}
39 
40 %%
41 <TEXT>[ \t\n]* ;
42 <TEXT>"/*" {BEGIN COMMENT;}
43 <TEXT>"//[^\n]*\n" ;
44 <COMMENT>"*/" {BEGIN TEXT;}
45 <COMMENT>(.|\n) ;
46 <TEXT>PROGRAM {return PROGRAM;}
47 <TEXT>MODULE {return MODULE;}
48 <TEXT>MAIN {return MAIN;}
49 <TEXT>COMMON {return COMMON;}
50 <TEXT>CALLEES {return TK_CALLEES;}
51 <TEXT>CALLERS {return CALLERS;}
52 <TEXT>ALL {return ALL;}
53 <TEXT>SELECT {return SELECT;}
54 <TEXT>COMPILATION_UNIT {return COMPILATION_UNIT;}
55 <TEXT>< {return REQUIRED;}
56 <TEXT>> {return PRODUCED;}
57 <TEXT>\# {return MODIFIED;}
58 <TEXT>= {return PRESERVED;}
59 <TEXT>\! {return PRE_TRANSFORMATION;}
60 <TEXT>\* {return POST_TRANSFORMATION;}
61 <TEXT>\. {return DOT;}
62 <TEXT>[-_a-zA-Z0-9]+ { pipsmake_lval.name=strdup(yytext); return NAME;}
63 <TEXT,COMMENT>. {
64  fprintf(stderr,
65  "[readmakefile] unknown char %c (%d)\n",
66  *yytext, *yytext);
67  exit(1);
68  }
69 %%
70 
71 int yywrap()
72 {
73  return 1;
74 }
75 
76 int init_lex()
77 {
78  BEGIN TEXT;
79  return 1;
80 }
81 
82 void yyerror_lex_part(const char *s)
83 {
84  fprintf(stderr, "[yyerror_lex_part] %s near %s\n", s, yytext);
85 }