On 2019-05-07, Daniel Cegiełka <daniel.cegielka_AT_gmail.com> wrote:
> Hi,
>
> I'm going to use Quentin's miniyacc with (for example) bc.y from Plan 9:
> https://github.com/9fans/plan9port/blob/master/src/cmd/bc.y
>
> Of course, I had to modify the code (a bit), but unfortunately I still
> get an error when using miniyacc - works correctly with yacc from
> OpenBSD and Plan 9.
>
> I'm getting a message from this place ("production rule too long"):
> https://c9x.me/git/miniyacc.git/tree/yacc.c#n1110
>
> I tried to increase the value of IdntSz and MaxRhs, but it didn't help
> in any way.
It looks like this error is caused when miniyacc encounters a
character that it doesn't recognize as a token. nexttk() returns a
zero-length TIdnt token, causing an infinite loop, filling up r->rhs.
Try the attached patch, which makes it fail on invalid tokens.
In the example bc.y you linked, I think the '={' is causing problems,
and is from an obsolete yacc syntax:
Some implementations recognize "={" as equivalent to '{' because it
appears in historical documentation. This construction was recognized
and documented as obsolete as long ago as 1978, in the referenced
Yacc: Yet Another Compiler-Compiler. This volume of POSIX.1-2017 chose
to leave it as obsolete and omit it.
I also ran into this problem on some other grammar files containing
comments. One other issue I noticed is miniyacc doesn't seem to handle
escape sequences in literals (i.e. '\n').
After working around those issues, I get a different error
$n has no type (on line 171)
I think this is due to the usage of $2 referring to a token (EQOP in
this case) rather than a non-terminal. I haven't investigated this
further.
Received on Wed May 08 2019 - 10:34:36 CEST