Re: Need help specifying a grammar rule

Ben Elliston <bje@cygnus.com>
13 Apr 1998 11:07:18 -0400

          From comp.compilers

Related articles
Need help specifying a grammar rule roseberry@bigfoot.com (Michael J. Roseberry) (1998-04-13)
Re: Need help specifying a grammar rule bje@cygnus.com (Ben Elliston) (1998-04-13)
| List of all articles for this month |

From: Ben Elliston <bje@cygnus.com>
Newsgroups: comp.compilers
Date: 13 Apr 1998 11:07:18 -0400
Organization: Compilers Central
Keywords: yacc, parse

> [ how do you say this in yacc? ]
> expression ::=
> relation { AND relation }
> | relation { AND THEN relation }
> | relation { OR relation }
> | relation { OR ELSE relation }
> | relation { XOR relation }


> [Unless I'm missing something, you should be able to write this pretty
> much as is with some precedence rules. -John]


With the curly brace metasyntax removed, these are essentially the
classic:


expr + expr


forms (which lead to shift/reduce conflicts in yacc!)


As John notes, precedence rules are a quick way to fix these (or rephrase
the grammar).


Ben


---
Ben Elliston
bje@cygnus.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.