Re: [dev] miniyacc

From: Michael Forney <>
Date: Wed, 8 May 2019 01:34:36 -0700

On 2019-05-07, Daniel Cegiełka <> wrote:
> Hi,
> I'm going to use Quentin's miniyacc with (for example) bc.y from Plan 9:
> 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"):
> 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

Received on Wed May 08 2019 - 10:34:36 CEST

This archive was generated by hypermail 2.3.0 : Wed May 08 2019 - 10:36:09 CEST