2 /* This file is part of GCC.
4 GCC is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 3, or (at your option) any later
9 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING3. If not see
16 <http://www.gnu.org/licenses/>. */
22 extern int yyparse (void);
26 ID [_a-zA-Z][a-zA_Z0-9_$]*
27 QSTRING \"[^\"\n]*[\"\n]
30 %option yylineno noyywrap nounput 8bit never-interactive
33 "/*" { BEGIN (comment); }
34 <comment>[^*\n]* { /* eat it up flex you be le hungry maybe? */ }
35 <comment>"*"+[^*/\n]* { /* eat up boyo */ }
36 <comment>\n { ++yylineno; }
37 <comment>"*"+"/" { BEGIN (INITIAL); }
41 break { return BREAK; }
42 return { return RETURN; }
43 continue { return CONTINUE; }
48 while { return WHILE; }
50 static { return STATIC; }
51 struct { return STRUCT; }
53 "else if" { return ELIF; }
57 bool { return TYPE_BOOL; }
58 int { return TYPE_INT; }
59 float { return TYPE_FLOAT; }
60 uint { return TYPE_UINT; }
62 match { return MATCH; }
63 true { return XTRUE; }
64 false { return XFALSE; }
65 trait { return TRAIT; }
73 "->" { return RTYPE; }
88 "==" { return EQUAL_EQUAL; }
89 "!=" { return NOT_EQUAL; }
91 "<=" { return LESS_EQUAL; }
93 ">=" { return GREATER_EQUAL; }
95 \/\/.* ; /* // style comment */
98 yylval.string = xstrdup (yytext + 1);
99 if (yylval.string [yyleng - 2] != '\"')
100 error ("Un-termintated character string!\n");
102 yylval.string [yyleng - 2] = '\0';
109 if (mpfr_set_str (x, yytext, 10, GMP_RNDU))
111 fatal_error ("error initilizing integer value <%s>!\n", yytext);
113 yylval.integer = mpfr_get_si (x, GMP_RNDU);
118 {DIGIT}+"."{DIGIT}+ {
121 if (mpfr_set_str (x, yytext, 10, GMP_RNDU))
123 fatal_error ("error initilizing float value <%s>!\n", yytext);
125 yylval.ffloat = mpfr_get_flt (x, GMP_RNDU);
131 yylval.string = xstrdup (yytext);
140 bool grs_do_compile (const char * in)
143 FILE * fd = fopen (in, "rb");
148 linemap_add (line_table, LC_ENTER, 0, in, 0);
151 linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
156 fprintf (stderr, "error opening file %s\n", in);