1 char rcsid_lex
[] = "$Id$";
10 static char buf
[BUFSIZ
];
12 static int yyline
= 1;
14 typedef int (*ReadFn
) ARGS((void));
16 static char *StrCopy
ARGS((char *));
17 static int code_get
ARGS((void));
18 static int simple_get
ARGS((void));
19 static void ReadCharString
ARGS((ReadFn
, int));
20 static void ReadCodeBlock
ARGS((void));
21 static void ReadOldComment
ARGS((ReadFn
));
26 char *t
= (char *)zalloc(strlen(s
) + 1);
35 if ((ch
= getchar()) == '\n') {
45 if ((ch
= getchar()) == '\n') {
57 while (code_get() != EOF
) ;
62 ReadCharString(rdfn
, which
) ReadFn rdfn
; int which
;
66 int firstline
= yyline
;
68 while ((ch
= rdfn()) != EOF
) {
69 if (ch
== which
&& !backslash
) {
72 if (ch
== '\\' && !backslash
) {
78 yyerror1("Unexpected EOF in string on line ");
79 fprintf(stderr
, "%d\n", firstline
);
84 ReadOldComment(rdfn
) ReadFn rdfn
;
86 /* will not work for comments delimiter in string */
90 int firstline
= yyline
;
92 while ((ch
= rdfn()) != EOF
) {
95 } else if (ch
== '/' && starred
) {
101 yyerror1("Unexpected EOF in comment on line ");
102 fprintf(stderr
, "%d\n", firstline
);
110 int firstline
= yyline
;
112 while ((ch
= getchar()) != EOF
) {
124 if (ch
== '"' || ch
== '\'') {
125 ReadCharString(code_get
, ch
);
126 } else if (ch
== '/') {
130 ReadOldComment(code_get
);
137 yyerror1("Unclosed block of C code started on line ");
138 fprintf(stderr
, "%d\n", firstline
);
156 while ((ch
= getchar()) != EOF
) {
175 ReadOldComment(simple_get
);
179 yyerror("illegal char /");
194 if (ptr
>= &buf
[BUFSIZ
]) {
195 yyerror("ID too long");
201 } while (isalpha(ch
) || isdigit(ch
) || ch
== '_');
204 if (!strcmp(buf
, "term")) return K_TERM
;
205 if (!strcmp(buf
, "start")) return K_START
;
206 if (!strcmp(buf
, "gram")) return K_GRAM
;
207 yyerror("illegal character after %%");
210 yyerror("illegal character after %%");
216 if (ptr
>= &buf
[BUFSIZ
]) {
217 yyerror("ID too long");
223 } while (isalpha(ch
) || isdigit(ch
) || ch
== '_');
226 yylval
.y_string
= StrCopy(buf
);
235 } while (isdigit(ch
));
240 yyerror1("illegal char ");
241 fprintf(stderr
, "(\\%03o)\n", ch
);
248 void yyerror1(const char *str
)
250 fprintf(stderr
, "line %d: %s", yyline
, str
);
254 yyerror(const char *str
)
257 fprintf(stderr
, "\n");