[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lex/yacc/gcc help
From: |
Akim Demaille |
Subject: |
Re: lex/yacc/gcc help |
Date: |
Tue, 5 Nov 2013 10:43:45 +0100 |
Le 1 nov. 2013 à 14:36, Mark Hounschell <address@hidden> a écrit :
> # make
> ./translate5 cpu.def
> cat yacc1.yinit yacctoks yacc2.yinit yaccrules yacc3.yinit > yacc.in
> yacc -d yacc.in
> cat lex1.linit lextext lexfield lex2.linit > lex.in
> flex -l lex.in
> gcc -ansi -w y.tab.c -o cpu.asm -lgcc
> yacc.in: In function ëyyparseí:
> yacc.in:2322:3: error: unknown type name ëBEGINí
BEGIN is something expected in a lex file, not in a Yacc
file. This is fishy.
> case 207:
> # line 2305 "yacc.in"
> { if (yychar != -1) {
> yyclearin;
> while (yyleng > 0) {
> unput(yytext[--yyleng]); }}
> BEGIN ctxn;} break;
It looks like your Yacc parser is trying to influence your
lex scanner. In a properly designed scanner/parser couple,
you should never see things such as "BEGIN" or "unput" in
the parser: that's the scanner's job only.
Either be brave and change all this, or maybe there is a way
out, I don't know, by trying to #include the whole scanner in
the yacc file. In either case, expect pain :(