Re: Shift/Reduce Conflicts on ABNF Grammar

lostbits <[email protected]> Wed, 12 Nov 2025 08:20:04 -0800
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
Hi Josh;

I haven't looked at the grammar closely but as a note, are you using 
Bison as both a lexer and parser? May I suggest that you separate lexing 
from parsing and use flex and Bison rather than Bison alone? This does 
nothing to solve your problem, but increases speed of execution, 
decreases the size of tables, reduces the parsing statements, and makes 
it easier to maintain.

art

On 11/12/2025 7:44 AM, Josh Meise wrote:
> Hello,
>
> I trust you are well.
>
> I am working on building a LALR parser for ABNF grammars using Bison and am
> running into shift/reduce conflicts pertaining to whitespace.
>
> The rule that is causing this issue is the alternation rule (from the RFC
> for ABNF <https://datatracker.ietf.org/doc/html/rfc5234>):
> alternation = concatenation *(*c-wsp "/" *c-wsp concatenation)
> concatenation = repetition *(1*c-wsp repetition)     /* I have just set
> repetition to be a character value for simplicity */
> c-wsp = WSP / (c-nl WSP)
> c-nl = comment / CRLF
> comment =  ";" *(WSP / VCHAR) CRLF
>
> I have attached my current Bison grammar. I believe I know what is causing
> the conflict but am having some trouble coming to a solution. Any advice
> would be greatly appreciated.
>
> Best,
> Josh