Trans.: RE: [antlr-interest] Beginer's question, not fitting in subject

Alexandre antlr at alxp.gr
Sun Apr 10 01:48:04 PDT 2005


Hmm... no, CSP stands for Constraint Satisfaction Problem (you have a number of
constraints on variables, and must assign values to all the variables so that
all of the constraints are satisfied).

What I didn't precise is that this syntax is just part of a whole file with a
more complex syntax, but very easy to deal with by a parser generator. So
that's why I want to use antlr, mixing it with a classic treatment for this
specific part.

Anyway thank you for your proposals, at least they confirmed my ideas.

Have a good day (I'm in Europe),

Alexandre

Selon Scott Stanchfield <scott at javadude.com>:

> IBM's Cross-System Product?
>
> Still looks like a space-delimited, line-oriented input. Is that's the case,
> I wouldn't take the learning curve or overhead of a parser generator...
>
> Later,
> -- Scott
>
> > -----Original Message-----
> > From: antlr-interest-bounces at antlr.org
> > [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Alexandre
> > Sent: Saturday, April 09, 2005 12:28 PM
> > To: antlr-interest at antlr.org
> > Subject: Trans.: RE: [antlr-interest] Beginer's question,not
> > fitting in subject
> >
> >
> > Thank you for your answer.
> >
> > So I suppose this means that my feeling was right, to let
> > Java checking it...
> >
> > But the problem is a litte bit more tricky. The syntax I have
> > is imposed, and is different of what I gave. It is precisely this :
> > V= [4,5,6]
> > sr1 ac1	T
> > sr1 ac1	NT
> > sr1 ac2	NT
> > sr2 ac1	T
> > sr2 ac1	NT
> > sr2 ac2	T
> > sr2 ac2	NT
> > (It represents a CSP constraint if it does mean something to
> > you, V are the variables, then follow the values that they
> > are allowed to have, in the same order). Of course lines do
> > not have more importance than spaces or tabs. I could have V=
> > [4,5,6] sr1 ac1 T sr1 ac1 NT which is right, but V= [4,5,6]
> > sr1 ac1 T sr1 ac1 or V= [4,5,6] sr1 ac1 T sr1 ac1 NT sr1 are wrong...
> >
> > So I should have a rule only for each value (sr1, NT, ...),
> > then put Java instructions to build dynamically the (here)
> > three elements collections, as Tokens come, and throw an
> > error if something is missing. In fact this syntax is
> > simpler, we don't need RegEx's (maybe that's why I've been
> > given it). Do you think that's good, or have other suggestion ?
> >
> > Thank you again,
> >
> > Alexandre
> >
> > Selon Scott Stanchfield <scott at javadude.com>:
> >
> > > I should note that I meant to use the RegEx for each line after
> > > reading the line using the BufferedReader.
> > >
> > > Later,
> > > - Scott
> > >
> > > > -----Original Message-----
> > > > From: antlr-interest-bounces at antlr.org
> > > > [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Scott
> > > > Stanchfield
> > > > Sent: Saturday, April 09, 2005 11:29 AM
> > > > To: 'Alexandre'; antlr-interest at antlr.org
> > > > Subject: RE: [antlr-interest] Beginer's question, not fitting in
> > > > subject
> > > >
> > > > Seriously... I think ANTLR is overkill for items like this.
> > > >
> > > > Whenever you have line-oriented input and all lines have the same
> > > > format, I'd recommend using good old BufferedReader to read the
> > > > lines and StringTokenizer to separate them.
> > > >
> > > > If you want a little more checking to see if the parens
> > and commas
> > > > are actually there, then you'll want to use a Java regular
> > > > expression (Pattern +
> > > > Matcher) if you can use Java 1.4 or later.
> > > >
> > > > Hope this helps!
> > > > -- Scott
> > > >
> > > > > -----Original Message-----
> > > > > From: antlr-interest-bounces at antlr.org
> > > > > [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Alexandre
> > > > > Sent: Saturday, April 09, 2005 11:23 AM
> > > > > To: antlr-interest at antlr.org
> > > > > Subject: [antlr-interest] Beginer's question, not fitting in
> > > > > subject
> > > > >
> > > > > Hello,
> > > > >
> > > > > I have a classic, I guess, question. The language I am
> > trying to
> > > > > define cannot be represented by a grammar, as it is of the form
> > > > > (a)n(b)n. What my file must do is something like defining
> > > > tuples, that
> > > > > is series of elements. Suppose that the syntax to
> > define a serie
> > > > > of values a serie of variables can have is something like :
> > > > > (X1, X2, X3)
> > > > > (1, 2, 3)
> > > > > (4, 5, 6)
> > > > >
> > > > > Of course the number of variables is totally arbitrary,
> > but for a
> > > > > given number, the number the values in each following tuple
> > > > of values
> > > > > must be the same. How can I make that with antlr ? I
> > > > thought about not
> > > > > having antlr detecting it, that is to accept any list
> > of the form
> > > > > (..,..) for the values, and then treat (in Java) the result
> > > > of each,
> > > > > and throwing if necessary an exception. But that isn't pretty
> > > > > beautiful.
> > > > >
> > > > > Do you have any suggestion ?
> > > > >
> > > > > Thank you,
> > > > >
> > > > > Alexandre
> > > > >


More information about the antlr-interest mailing list