Re: BNF DEFINITION - help!

"Eric A. Anderson" <eanders+@CMU.EDU>
Mon, 12 Sep 1994 19:34:35 GMT

          From comp.compilers

Related articles
BNF DEFINITION - help! banks@iowasp.physics.uiowa.edu (1994-09-11)
Re: BNF DEFINITION - help! eanders+@CMU.EDU (Eric A. Anderson) (1994-09-12)
Re: BNF DEFINITION - help! ellard@bbn.com (1994-09-17)
Re: BNF DEFINITION - help! godau@dec2.wi-inf.uni-essen.de (H.-Juergen Godau) (1994-09-18)
Re: BNF DEFINITION - help! mab@dst17.wdl.loral.com (1994-09-20)
| List of all articles for this month |

Newsgroups: comp.compilers
From: "Eric A. Anderson" <eanders+@CMU.EDU>
Keywords: parse
Organization: Carnegie Mellon, Pittsburgh, PA
References: 94-09-024
Date: Mon, 12 Sep 1994 19:34:35 GMT

[question was to show BNF for odd length strings over {a,b} with the
first and middle tokens the same]


I believe this will work; I hope the question was already due.


Amid -> a | a Amid a | a Amid b | b Amid a | b Amid b
Bmid -> b | a Bmid a | a Bmid b | b Bmid a | b Bmid b
These two generate all odd length strings with either a or b in the middle


Agood -> a Amid a | a Amid b | a
Bgood -> b Bmid a | b Bmid b | b
These two take the previous two productions and guarentee the right
thing is on the front while leaving the end unspecified, they also
handle two special cases.


LANG -> Agood | Bgood
This combines our two pieces together.
--
It seems to me that you should be able to do Amid' and Bmid' so they
generate even length strings with the character you want as the
rightmost of the middle pair. This should eliminate the special case.
However, it didn't occur to me how to do that.
                      -Eric
--


Post a followup to this message

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