help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lex/yacc/gcc help


From: Mark Hounschell
Subject: Re: lex/yacc/gcc help
Date: Tue, 05 Nov 2013 08:11:25 -0500
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0

On 11/05/2013 04:43 AM, Akim Demaille wrote:

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 :(



Thanks Akim,

Like I said in my original post, I am yacc/lex ignorant. The strange thing, that I haven't mentioned is that this all built successfully 4, 5, or more years ago on Linux. I was recently able to find that executable that I had checked into CVS those years back and it works. I also found some notes of what I originally had to do to get it to build. All I had to do back then was:

1. Changed all ocurrances of yylval.ntype
                          to yylval.nvaltype.ntype
2. Changed all occurances of yylval.nval
                          to yylval.nvaltype.nval

3. Changed all occurances of yybgin to yy_start

4. Changed all occurances of "k =/ 10" to "k /= 10"

As far as including the whole scanner in the yacc file, the y.tab.c file does include the lex file but at the very end of it. After this BEGIN shows up.

End of y.tab.c:

/* Line 2041 of yacc.c  */
#line 2355 "yacc.in"


#include "mic.c"

#include "fields.c"
#include "lex.yy.c"

I assume lex.yy.c is the whole scanner? And I also assume you mean trying to include it before the BEGIN?

Regards
Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]