Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Dec 1996 12:01:44 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        rb@gid.co.uk (Bob Bishop)
Cc:        terry@lambert.org, hackers@freebsd.org
Subject:   Re: Yacc -p<NAME> is broken
Message-ID:  <199612061901.MAA24232@phaeton.artisoft.com>
In-Reply-To: <v01540b00aecda232d9b7@[194.32.164.2]> from "Bob Bishop" at Dec 6, 96 10:21:34 am

next in thread | previous in thread | raw e-mail | index | archive | help
> At 7:13 pm 5/12/96, Terry Lambert wrote:
> >[...]
> >Frequently, if you are mixing grammars, you have a -P<NAME> on the lex
> >to go with the -p<NAME> on the yacc...
> 
> I agree it's broken. I suspect it's always been broken, but there are other
> ways to skin that particular cat. Several times I've seen people stuffing
> lex/yacc output thru sed to fix the prefixes; I don't like that much.
> 
> What I usually do is use a 'super-grammar' whose top-level rule just
> switches between the real gramars based on a token which I arrange to stuff
> up the pipe when the parser starts. Lex/yacc output seems to restartable:
> this works OK.

Actually, I screwed up.

According to:

	lex & yacc
	John R. Levine, Tony Mason, & Doug Brown
	O'Reilly & Associates, Inc.
	ISBN 1-56592-000-7

The "-p" flag ("-P" for flex -- stupid flex) is supposed to affect:

yyback		yybgin		yycrank		yyerror
yyestate	yyextra		yyfnd		yyin
yyinput		yyleng		yylex		yylineno
yylook		yylsp		yylstate	yylval
yymatch		yymorfg		yyolsp		yyout
yyoutput	yyprevious	yysbuf		yysptr
yysvec		yytchar		yytext		yytop
yyunput		yyvstop		yywrap


For the record, it doesn't.  8-(.

Also for the record, I believe yytext_ptr should be affected
as well, or it should at least be static.

I was sent some yacc patches from one of the other BSD's; apparently
yacc fails on two variables as well.


I still think that, even though the behaviour is documented, the
yylval is an external reference from the yacc; I may choose to not
use the same prefix for my yacc "-p" and my lex "-p"; if so, I
think they should still be capable of interoperating using the
inclusion of y.tab.h and an explicit {yy}lex() call replacement
stub.

In any case, with all the non-static globals, it's inlikely that
you could safely use multiple lexers in the same program without
seriously fixing lex.

					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612061901.MAA24232>