Re: Grammar help

"Casse Hugues" <casse@netcourrier.com>
15 Jul 2002 23:53:32 -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: "Casse Hugues" <casse@netcourrier.com>
Newsgroups: comp.compilers
Date: 15 Jul 2002 23:53:32 -0400
Organization: Compilers Central
References: 02-06-077
Keywords: parse
Posted-Date: 15 Jul 2002 23:53:32 EDT

On Sat, 29 Jun 2002 00:11:25 +0200, Randy Beckwith wrote:
> 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
>


    Ok,I think that the following grammar should work and is short (but the
bad thing is that is accept the empty grammar):


rule ::= opt_caller opt_called opt_dates
opt_caller ::= /* empty */
| caller
opt_called ::= /* empty */
| called
opt_dates ::= /* empty */
| dates
dates ::= date
| dates date


Post a followup to this message

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