1
2
3
4
5
6
7
8
9
10
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
125
126
127
128
129
|
%{
/* otp.l: Lexical analysis for OTP files
This file is part of Omega,
which is based on the web2c distribution of TeX,
Copyright (c) 1994--2001 John Plaice and Yannis Haralambous
Copyright (c) 2002 Behdad Esfahbod
Copyright (c) 2002 Roozbeh Pournader
Omega is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Omega is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Omega; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include "routines.h"
#include "yystype.h"
#include "y_tab.h"
#define YY_NO_UNPUT
int line_number = 1;
int i,j,last;
extern YYSTYPE yylval;
%}
hexnumber @\"[a-fA-F0-9]+
octnumber @'[0-7]+
decnumber [0-9]+
id ([a-zA-Z][_a-zA-Z0-9]*)
string \"([^\"]|\"\")*\"
%%
[ \t] {}
"%".*\n { line_number++;}
\r\n|\n|\r { line_number++;}
{hexnumber} {
yylval.yint=0;
for (i=2; i<yyleng; i++) {
j = yytext[i];
if ((j>='0')&&(j<='9')) {
yylval.yint = (yylval.yint*16)+(j-'0');
} else if ((j>='a')&&(j<='f')) {
yylval.yint = (yylval.yint*16)+(j-'a'+10);
} else { /* ((j>='A') && (j>='F')) */
yylval.yint = (yylval.yint*16)+(j-'A'+10);
}
if (yylval.yint>65535) {
fprintf(stderr, "line %d: value too large (%x)\n",
line_number, yylval.yint);
exit(1);
}
}
return(NUMBER);
}
{octnumber} {
yylval.yint=0;
for (i=2; i<yyleng; i++) {
j = yytext[i];
yylval.yint = (yylval.yint*8)+(j-'0');
if (yylval.yint>65535) {
fprintf(stderr, "line %d: value too large (%o)\n",
line_number, yylval.yint);
exit(1);
}
}
return(NUMBER);
}
{decnumber} {
yylval.yint=0;
for (i=0; i<yyleng; i++) {
j = yytext[i];
yylval.yint = (yylval.yint*10)+(j-'0');
if (yylval.yint>65535) {
fprintf(stderr, "line %d: value too large (%d)\n",
line_number, yylval.yint);
exit(1);
}
}
return(NUMBER);
}
"`"[\x20-\x7e]"'" {
yylval.yint=yytext[1];
return(NUMBER);
}
{id} { yylval.ystring=xstrdup(yytext); return(ID); }
{string} {
char *newtext;
last=yyleng-2;
i=0;
j=1;
newtext=yylval.ystring=xstrdup(yytext);
while (j<=last) {
newtext[i]=yytext[j];
if ((yytext[j]=='"') && (yytext[j+1]=='"')) j=j+2;
else j++;
i++;
}
newtext[i]='\0';
return(STRING);
}
=> return(RIGHTARROW);
"<"= return(LEFTARROW);
input: return(INPUT);
output: return(OUTPUT);
aliases: return(ALIASES);
states: return(STATES);
tables: return(TABLES);
expressions: return(EXPRESSIONS);
push: return(PUSH);
pop: return(POP);
div: return(DIV);
mod: return(MOD);
beg: return(BEG);
end: return(END);
. return(yytext[0]);
%%
|