~ubuntu-branches/ubuntu/jaunty/texlive-bin/jaunty

« back to all changes in this revision

Viewing changes to build/TeX/texk/web2c/web2c/web2c.l

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2008-06-26 23:14:59 UTC
  • mfrom: (2.1.30 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080626231459-y02rjsrgtafu83yr
Tags: 2007.dfsg.2-3
add missing source roadmap.fig of roadmap.eps in fontinst documentation
(Closes: #482915) (urgency medium due to RC bug)
(new patch add-missing-fontinst-source)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%{
2
 
/* web2c.l -- lexical analysis for Tangle output.  Public domain.  */
3
 
 
4
 
#include "web2c.h"
5
 
#include "y_tab.h"
6
 
 
7
 
/* Hack to make it possible to compile the generated code with C++
8
 
   Required if you use flex. */
9
 
#ifdef __cplusplus
10
 
#define webinput yyinput
11
 
#else
12
 
#define webinput input
13
 
#endif
14
 
 
15
 
/* For some reason flex wants to do a system call, so we must lose our
16
 
   definition of the Pascal read.  */
17
 
#undef read
18
 
 
19
 
char conditional[20], negbuf[2], temp[20];
20
 
extern boolean doing_statements;
21
 
 
22
 
 
23
 
/* We only read one input file.  This is the default definition, but
24
 
   giving it ourselves avoids the need to find -lfl or -ll at link time.
25
 
   This is a good thing, since libfl.a is often installed somewhere that
26
 
   the linker doesn't search by default.  */
27
 
int
28
 
yywrap P1H(void)
29
 
{
30
 
  return 1;
31
 
}
32
 
#define YY_SKIP_YYWRAP /* not that it matters */
33
 
%}
34
 
DIGIT           [0-9]
35
 
ALPHA           [a-zA-Z]
36
 
ALPHANUM        ({DIGIT}|{ALPHA})
37
 
IDENTIFIER      ({ALPHA}{ALPHANUM}*)
38
 
NUMBER          ({DIGIT}+)
39
 
SIGN            ("+"|"-")
40
 
SIGNED          ({SIGN}?{NUMBER})
41
 
WHITE           [ \n\t]+
42
 
REAL            ({NUMBER}"."{NUMBER}("e"{SIGNED})?)|({NUMBER}"e"{SIGNED})
43
 
COMMENT         (("{"[^}]*"}")|("(*"([^*]|"*"[^)])*"*)"))
44
 
W               ({WHITE}|"packed ")+
45
 
WW              ({WHITE}|{COMMENT}|"packed ")*
46
 
HHB0            ("hh"{WW}"."{WW}"b0")
47
 
HHB1            ("hh"{WW}"."{WW}"b1")
48
 
 
49
 
%%
50
 
{W}                             ;
51
 
"{"             { while (webinput() != '}'); }
52
 
 
53
 
"#"             {
54
 
                    register int c;
55
 
                    putc('#', out);
56
 
                    while ((c = webinput()) && c != ';')
57
 
                        putc(c, out);
58
 
                    putc('\n', out);
59
 
                }
60
 
 
61
 
"ifdef("        {register int c;
62
 
                 register char *cp=conditional;
63
 
                 new_line();
64
 
                 while ((c = webinput()) != '\'')
65
 
                    ;
66
 
                 while ((c = webinput()) != '\'')
67
 
                    *cp++ = c;
68
 
                 *cp = '\0';
69
 
                 (void) webinput();
70
 
                 if (doing_statements) fputs("\t;\n", out);
71
 
                 fprintf(out, "#ifdef %s\n", conditional);
72
 
                }
73
 
 
74
 
"endif("        {register int c;
75
 
                 new_line();
76
 
                 fputs("#endif /* ", out);
77
 
                 while ((c = webinput()) != '\'')
78
 
                    ;
79
 
                 while ((c = webinput()) != '\'')
80
 
                    (void) putc(c, out);
81
 
                 (void) webinput();
82
 
                 conditional[0] = '\0';
83
 
                 fputs(" */\n", out);
84
 
                }
85
 
 
86
 
"ifndef("       {register int c;
87
 
                 register char *cp=conditional;
88
 
                 new_line();
89
 
                 while ((c = webinput()) != '\'')
90
 
                    ;
91
 
                 while ((c = webinput()) != '\'')
92
 
                    *cp++ = c;
93
 
                 *cp = '\0';
94
 
                 (void) webinput();
95
 
                 if (doing_statements) fputs("\t;\n", out);
96
 
                 fprintf(out, "#ifndef %s\n", conditional);
97
 
                }
98
 
 
99
 
"endifn("       {register int c;
100
 
                 new_line();
101
 
                 fputs("#endif /* not ", out);
102
 
                 while ((c = webinput()) != '\'')
103
 
                    ;
104
 
                 while ((c = webinput()) != '\'')
105
 
                    putc(c, out);
106
 
                 (void) webinput();
107
 
                 conditional[0] = '\0';
108
 
                 fputs(" */\n", out);
109
 
                }
110
 
 
111
 
 
112
 
"procedure "[a-z]+";"[ \n\t]*"forward;" ;
113
 
 
114
 
"function "[(),:a-z]+";"[ \n\t]*"forward;"      ;
115
 
 
116
 
"@define"       return last_tok=define_tok;
117
 
"@field"        return last_tok=field_tok;
118
 
"and"           return last_tok=and_tok;
119
 
"array"         return last_tok=array_tok;
120
 
"begin"         return last_tok=begin_tok;
121
 
"case"          return last_tok=case_tok;
122
 
"const"         return last_tok=const_tok;
123
 
"div"           return last_tok=div_tok;
124
 
"break"         return last_tok=break_tok;
125
 
"do"            return last_tok=do_tok;
126
 
"downto"        return last_tok=downto_tok;
127
 
"else"          return last_tok=else_tok;
128
 
"end"           return last_tok=end_tok;
129
 
"file"          return last_tok=file_tok;
130
 
"for"           return last_tok=for_tok;
131
 
"function"      return last_tok=function_tok;
132
 
"goto"          return last_tok=goto_tok;
133
 
"if"            return last_tok=if_tok;
134
 
"label"         return last_tok=label_tok;
135
 
"mod"           return last_tok=mod_tok;
136
 
"not"           return last_tok=not_tok;
137
 
"of"            return last_tok=of_tok;
138
 
"or"            return last_tok=or_tok;
139
 
"procedure"     return last_tok=procedure_tok;
140
 
"program"       return last_tok=program_tok;
141
 
"record"        return last_tok=record_tok;
142
 
"repeat"        return last_tok=repeat_tok;
143
 
{HHB0}          return last_tok=hhb0_tok;
144
 
{HHB1}          return last_tok=hhb1_tok;
145
 
"then"          return last_tok=then_tok;
146
 
"to"            return last_tok=to_tok;
147
 
"type"          return last_tok=type_tok;
148
 
"until"         return last_tok=until_tok;
149
 
"var"           return last_tok=var_tok;
150
 
"while"         return last_tok=while_tok;
151
 
"others"        return last_tok=others_tok;
152
 
 
153
 
{REAL}          {               
154
 
                  sprintf (temp, "%s%s", negbuf, yytext);
155
 
                  negbuf[0] = '\0';
156
 
                  return last_tok=r_num_tok;
157
 
                }
158
 
 
159
 
{NUMBER}        {
160
 
                  sprintf (temp, "%s%s", negbuf, yytext);
161
 
                  negbuf[0] = '\0';
162
 
                  return last_tok=i_num_tok;
163
 
                }
164
 
 
165
 
("'"([^']|"''")"'")             return last_tok=single_char_tok;
166
 
 
167
 
("'"([^']|"''")*"'")            return last_tok=string_literal_tok;
168
 
 
169
 
"+"             { if ((last_tok>=undef_id_tok &&
170
 
                      last_tok<=field_id_tok) ||
171
 
                      last_tok==i_num_tok ||
172
 
                      last_tok==r_num_tok ||
173
 
                      last_tok==')' ||
174
 
                      last_tok==']')
175
 
                   return last_tok='+';
176
 
                else return last_tok=unary_plus_tok; }
177
 
 
178
 
"-"             { if ((last_tok>=undef_id_tok &&
179
 
                      last_tok<=field_id_tok) ||
180
 
                      last_tok==i_num_tok ||
181
 
                      last_tok==r_num_tok ||
182
 
                      last_tok==')' ||
183
 
                      last_tok==']')
184
 
                   return last_tok='-';
185
 
                else {
186
 
                  int c;
187
 
                  while ((c = webinput()) == ' ' || c == '\t')
188
 
                    ;
189
 
                  unput(c);
190
 
                  if (c < '0' || c > '9') {
191
 
                        return last_tok = unary_minus_tok;
192
 
                  }
193
 
                  negbuf[0] = '-';
194
 
                }}
195
 
 
196
 
"*"             return last_tok='*';
197
 
"/"             return last_tok='/';
198
 
"="             return last_tok='=';
199
 
"<>"            return last_tok=not_eq_tok;
200
 
"<"             return last_tok='<';
201
 
">"             return last_tok='>';
202
 
"<="            return last_tok=less_eq_tok;
203
 
">="            return last_tok=great_eq_tok;
204
 
"("             return last_tok='(';
205
 
")"             return last_tok=')';
206
 
"["             return last_tok='[';
207
 
"]"             return last_tok=']';
208
 
":="            return last_tok=assign_tok;
209
 
".."            return last_tok=two_dots_tok;
210
 
"."             return last_tok='.';
211
 
","             return last_tok=',';
212
 
";"             return last_tok=';';
213
 
":"             return last_tok=':';
214
 
"^"             return last_tok='^';
215
 
 
216
 
{IDENTIFIER}    { strcpy (last_id, yytext);
217
 
                  l_s = search_table (last_id);
218
 
                  return
219
 
                    last_tok = (l_s == -1 ? undef_id_tok : sym_table[l_s].typ);
220
 
                }
221
 
 
222
 
 
223
 
.               { /* Any bizarre token will do.  */
224
 
                  return last_tok = two_dots_tok; }
225
 
%%
226
 
/* Some helper routines.  Defining these here means we don't have references
227
 
   to yytext outside of this file.  Which means we can omit one of the more
228
 
   troublesome autoconf tests. */
229
 
void
230
 
get_string_literal P1C(char *, s)
231
 
{
232
 
    int i, j;
233
 
    j = 1;
234
 
    s[0] = '"';
235
 
    for (i=1; yytext[i-1] != 0; i++) {
236
 
        if (yytext[i] == '\\' || yytext[i] == '"')
237
 
            s[j++] = '\\';
238
 
        else if (yytext[i] == '\'')
239
 
            i++;
240
 
        s[j++] = yytext[i];
241
 
    }
242
 
    s[j-1] = '"';
243
 
    s[j] = 0;
244
 
}
245
 
 
246
 
void
247
 
get_single_char P1C(char *, s)
248
 
{
249
 
    s[0]='\'';
250
 
    if (yytext[1] == '\\' || yytext[1] == '\'') {
251
 
        s[1] = '\\';
252
 
        s[2] = yytext[1];
253
 
        s[3] = '\'';
254
 
        s[4] = 0;
255
 
    } else {
256
 
        s[1] = yytext[1];
257
 
        s[2] = '\'';
258
 
        s[3] = 0;
259
 
    }
260
 
}
261
 
 
262
 
void
263
 
get_result_type P1C(char *, s)
264
 
{
265
 
    strcpy(s, yytext);
266
 
}
267
 
 
268
 
 
269
 
/* Since a syntax error can never be recovered from, we exit here with
270
 
   bad status.  */
271
 
 
272
 
int
273
 
yyerror P1C(string, s)
274
 
{
275
 
  /* This is so the convert script can delete the output file on error.  */
276
 
  puts ("@error@");
277
 
  fflush (stdout);
278
 
  fputs (s, stderr);
279
 
  fprintf (stderr, ": Last token = %d (%c), ", last_tok, last_tok);
280
 
  fprintf (stderr, "error buffer = `%s',\n\t", yytext);
281
 
  fprintf (stderr, "last id = `%s' (", last_id);
282
 
  ii = search_table (last_id);
283
 
  if (ii == -1)
284
 
    fputs ("not in symbol table", stderr);
285
 
  else
286
 
    switch (sym_table[ii].typ)
287
 
      {
288
 
      case undef_id_tok:
289
 
        fputs ("undefined", stderr);
290
 
        break;
291
 
      case var_id_tok:
292
 
        fputs ("variable", stderr);
293
 
        break;
294
 
      case const_id_tok:
295
 
        fputs ("constant", stderr);
296
 
        break;
297
 
      case type_id_tok:
298
 
        fputs ("type", stderr);
299
 
        break;
300
 
      case proc_id_tok:
301
 
        fputs ("parameterless procedure", stderr);
302
 
        break;
303
 
      case proc_param_tok:
304
 
        fputs ("procedure with parameters", stderr);
305
 
        break;
306
 
      case fun_id_tok:
307
 
        fputs ("parameterless function", stderr);
308
 
        break;
309
 
      case fun_param_tok:
310
 
        fputs ("function with parameters", stderr);
311
 
        break;
312
 
      default:
313
 
        fputs ("unknown!", stderr);
314
 
        break;
315
 
      }
316
 
  fputs (").\n", stderr);
317
 
  exit (1);
318
 
 
319
 
  /* Avoid silly warnings.  */
320
 
  return 0;
321
 
}