|need help with using a grammar to construct a sentence from a group of email@example.com (Glen Plantz) (1998-04-13)|
|Re: need help with using a grammar to construct a sentence from a grou firstname.lastname@example.org (1998-04-18)|
|Re: need help with using a grammar to construct a sentence from a grou email@example.com (resslere) (1998-04-21)|
|Re: need help with using a grammar to construct a sentence from a grou firstname.lastname@example.org (Jake Donham) (1998-04-27)|
|Re: using a grammar to construct a sentence from a group of words a-bnc@MICROSOFT.com (Nicholas Carey BEST Consulting) (1998-04-29)|
|Re: need help with using a grammar to construct a sentence from a grou email@example.com (1998-05-04)|
|Re: need help with using a grammar to construct a sentence from a grou firstname.lastname@example.org (Axel Schairer) (1998-05-04)|
|From:||Glen Plantz <email@example.com>|
|Date:||13 Apr 1998 00:51:14 -0400|
|Organization:||CTS Network Services|
I have a problem where I need to do the opposite of parsing; given
a grammar and a group of words, I need to use the grammar to construct
a valid sentence. The actual application involves constructing a
valid message for a simulation system where the simulation system
understands a "message" that is made up of an ordered sequence of
records which in turn have fields. There is a "grammar" to the
placement and sequence of these records, so the analogy to
constructing an english sentence from a "pile of words" works well.
The input to the problem is a series of tables that hold data to go
into the records that will make up the message that I'm
constructing. There is one table per record type, and after these
tables are filled with data, the tables need to be placed into the
correct sequence and placement according to the grammar, possibly into
a linked list or whatever.
It's been a while since my last compiler class, so I dug up my
compiler texts to research the problem. I understand how to recognize
a sentence given a grammar, but I can't seem to come up with a good
solution to "going the opposite direction"; constructing a sentence
from a group of words.
I also tried to apply the "Composite" pattern from the Design
Patterns "gang of four" book, but I'm not sure that pattern applies
very well to this problem.
What's frustrating is that I know this problem has probably been
solved many times before, but I can't seem to find an algorithm or
pattern to apply here.
I'd really appreciate someone helping me to find my "blind spot"
here. I'll post the responses if anyone is interested.
The language we are using is Java, specifically the JDK 1.1.4.
Thanks in advance for helping me out,
Senior Software Engineer
email - Work - "firstname.lastname@example.org"
Personal - "email@example.com"
[There's been discussions here on generating test data for parsers, which
is close to what you want. -John]
Return to the
Search the comp.compilers archives again.