[antlr-interest] Beginer's question, not fitting in subject

Scott Stanchfield scott at javadude.com
Sat Apr 9 08:28:36 PDT 2005


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