Re: Grammar question.

"Tim G" <timgspam@comcast.net>
8 May 2002 00:19:15 -0400

          From comp.compilers

Related articles
Grammar question. morten@kikobu.com (Morten) (2002-04-23)
Re: Grammar question. timgspam@comcast.net (Tim G) (2002-05-08)
| List of all articles for this month |
From: "Tim G" <timgspam@comcast.net>
Newsgroups: comp.compilers
Date: 8 May 2002 00:19:15 -0400
Organization: Giganews.Com - Premium News Outsourcing
References: 02-04-139
Keywords: syntax
Posted-Date: 08 May 2002 00:19:15 EDT

"Morten" wrote:
>
> I have the following pseudo EBNF grammar:
>
> for ::= 'for' <string> (in | (where? (update | return)))
> in ::= 'in' <string> where? return
> where ::= <evaluates to bool>
> update ::= 'update' <string> 'to' <string>
> return ::= 'return' <string>
>
> I wish the in clause to be mutually exclusive with the update
> clause. They can both have an optional where clause. Can this be
> expressed in a nicer way than what I've done above?
>


I always spell things out like:


for := for_form1 | for_form2
for_form1 := 'for' <string> 'in' <string> where? return
for_form2 := 'for' <string> where? update


or something like that ;)


Hope this helps,
tim


Post a followup to this message

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