Grammar help

"Randy Beckwith" <rbeckwith@commetrex.com>
28 Jun 2002 18:11:25 -0400

          From comp.compilers

Related articles
grammar help pjhaynes@worldnet.att.net (Peter Haynes) (2000-04-05)
Grammar help rbeckwith@commetrex.com (Randy Beckwith) (2002-06-28)
Re: Grammar help kgw-news@stiscan.com (2002-07-02)
Re: Grammar help casse@netcourrier.com (Casse Hugues) (2002-07-15)
| List of all articles for this month |
From: "Randy Beckwith" <rbeckwith@commetrex.com>
Newsgroups: comp.compilers
Date: 28 Jun 2002 18:11:25 -0400
Organization: http://groups.google.com/
Keywords: parse, question, comment
Posted-Date: 28 Jun 2002 18:11:25 EDT

Hello, all.


I'm trying to write a simple grammar that will eventually be used with
Bison but have run into a snag. Basically, I'm trying to get at a list
of rules:


rules_list := rule | rule rules_list


That's the easy part. <g> Now a rule can be based on CallerID,
CalledID, Date or ExcludeDate. There can be 0 or 1 CallerID, 0 or 1
CalledID, 0 or more Date and 0 or more ExcludeDate. I can do the the
"0 or 1's" and the "0 or more's" but can't figure out how to get them
all together.


As an example, you could have rule matches on:


CallerID
CalledID
CallerID AND CalledID
CallerID AND CalledID AND Date
Date
Date AND Date
CallerID AND Date
CalledID AND Date AND ExcludeDate AND ExcludeDate


Thanks for your help.


Randy
[In a situation like this, it's often easier to match a more generic
list in the parser, then check semantically that the list is valid.
The parser is simpler, and you can produce much better error messages.
-John ]


Post a followup to this message

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