[antlr-interest] Optional tokens

Anthony Youngman Anthony.Youngman at eca-international.com
Fri May 27 07:03:43 PDT 2005


Not sure how closely it approximates to your problem, but you could also
look at some DATABASIC grammars.

There's one with MaVerick (www.maverick-dbms.org), Monty's REVELATION
grammar, and there should be a very simple "demo grammar" of mine
somewhere on the Antlr site.

The problem these BASICs have is in handling IF/THEN/ELSE. Normally ';'
and <lf> are interchangeable to mean "end of statement", but if (and
only if) a statement follows a conditional (THEN or ELSE) on the same
line, the meaning of <lf> changes to "end of conditional block".

As a result, my grammar treats <lf> as a token, but mostly throws it
away. I can't remember how I do it, and don't have access to my .g at
the moment...

Cheers,
Wol

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of hammett
Sent: 23 May 2005 07:53
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Optional tokens

Hiya!

> I will repeat John's question. If a NEWLINE can occur anywhere, where
does 
> a statement end? If it can only occur (and must occur) at a statement
end 
> then defactoring and putting it at the end of each of your statement
types 
> will should solve your problem.

Allow me to rephrase my problem: a NEWLINE is meaningless anywhere but
at 
statements end, which means that it must be ignored as a token anywhere
but 
at statements end.

I believe aspl VBScript grammar solved that nicely. Gonna use their 
approach.


Thanks

-- 
Cheers,
hammett
http://www.castleproject.org/~hammett




****************************************************************************

This transmission is intended for the named recipient only. It may contain private and confidential information. If this has come to you in error you must not act on anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, or show it to anyone. Please e-mail the sender to inform us of the transmission error or telephone ECA International immediately and delete the e-mail from your information system.

Telephone numbers for ECA International offices are: Sydney +61 (0)2 8272 5300, Hong Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.

****************************************************************************



More information about the antlr-interest mailing list