94b2b13d
Pedro Roque
PHACT source
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
%option bison-bridge
%option noinput
%option nounput
%{
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
void yyerror(char *);
#include "parser.tab.h"
%}
%%
\n { /*yylineno++;*/ /* ignore EOL */ }
[ \t\r] { /* ignore whitespace */ }
%.* { /* ignore comments */ }
"true" { yylval->iValue = 1; return FZ_BOOL_LIT; }
"false" { yylval->iValue = 0; return FZ_BOOL_LIT; }
-?[0-9]+ { yylval->iValue = atoi(yytext); return FZ_INT_LIT; }
-?0x[0-9A-Fa-f]+ { yylval->iValue = atoi(yytext); return FZ_INT_LIT; }
-?0o[0-7]+ { yylval->iValue = atoi(yytext); return FZ_INT_LIT; }
-?[0-9]+\.[0-9]+ { yylval->dValue = strtod(yytext,NULL);
return FZ_FLOAT_LIT; }
-?[0-9]+\.[0-9]+[Ee][+-]?[0-9]+ { yylval->dValue = strtod(yytext,NULL);
return FZ_FLOAT_LIT; }
-?[0-9]+[Ee][+-]?[0-9]+ { yylval->dValue = strtod(yytext,NULL);
return FZ_FLOAT_LIT; }
[=:;{}(),\[\]\.] { return *yytext; }
\.\. { return FZ_DOTDOT; }
:: { return FZ_COLONCOLON; }
"annotation" { return FZ_ANNOTATION; }
"any" { return FZ_ANY; }
"array" { return FZ_ARRAY; }
"bool" { return FZ_BOOL; }
"case" { return FZ_CASE; }
"constraint" { return FZ_CONSTRAINT; }
"default" { return FZ_DEFAULT; }
"else" { return FZ_ELSE; }
"elseif" { return FZ_ELSEIF; }
"endif" { return FZ_ENDIF; }
"enum" { return FZ_ENUM; }
"float" { return FZ_FLOAT; }
"function" { return FZ_FUNCTION; }
"if" { return FZ_IF; }
"include" { return FZ_INCLUDE; }
"int" { return FZ_INT; }
"let" { return FZ_LET; }
"maximize" { yylval->bValue = false; return FZ_MAXIMIZE; }
"minimize" { yylval->bValue = true; return FZ_MINIMIZE; }
"of" { return FZ_OF; }
"satisfy" { return FZ_SATISFY; }
"output" { return FZ_OUTPUT; }
"par" { yylval->bValue = false; return FZ_PAR; }
"predicate" { return FZ_PREDICATE; }
"record" { return FZ_RECORD; }
"set" { return FZ_SET; }
"show_cond" { return FZ_SHOWCOND; }
"show" { return FZ_SHOW; }
"solve" { return FZ_SOLVE; }
"string" { return FZ_STRING; }
"test" { return FZ_TEST; }
"then" { return FZ_THEN; }
"tuple" { return FZ_TUPLE; }
"type" { return FZ_TYPE; }
"var" { yylval->bValue = true; return FZ_VAR; }
"variant_record" { return FZ_VARIANT_RECORD; }
"where" { return FZ_WHERE; }
[A-Za-z][A-Za-z0-9_]* { yylval->sValue = strdup(yytext); return FZ_ID; }
_[_]*[A-Za-z][A-Za-z0-9_]* { yylval->sValue = strdup(yytext); return FZ_U_ID; }
\"[^"\n]*\" {
yylval->sValue = strdup(yytext+1);
yylval->sValue[strlen(yytext)-2] = 0;
return FZ_STRING_LIT; }
. { yyerror("Unknown character"); }
%%
int yywrap(void) {
return 1;
}
|