[antlr-interest] Writing a two pass compiler.

Monty Zukowski monty at codetransform.com
Sat Jan 22 10:52:40 PST 2005


	From: 	  monty at codetransform.com
	Subject: 	Re: [antlr-interest] Writing a two pass compiler.
	Date: 	January 21, 2005 8:21:28 AM PST
	To: 	  olczyk2002 at yahoo.com

\On Jan 20, 2005, at 8:47 PM, Thaddeus Olczyk wrote:
> I have a grammar for a language which I discover is
> written quite poorly. Certain types of strings can
> have different meanings depending on context, so
> I cannot unambiguously tokenise the strings.
> Mainly this is do to the fact that there is
> no way to distinguish text data from "source".
>
> Having examined the language closely, I believe it
> can be parsed using antlr to generate a two pass
> compiler. Pass2 being a context sensitive parse.
>
> A difficuly for me is that I've only written a few
> very trivial parsers ( at the calcualtor level ). I
> was wondering if there were any simple samples of
> antlr being used to implement a two pass compiler to
> guide
> me along the way.
>

I'm not aware of any full blown examples of two pass parsing.  I do 
have a small example of something similar, where I embed another parser 
in a TokenFilter in order to disambiguate strings, numbers and labels 
based on things like whether they follow a GOTO or not.  Read my 
article at http://www.codetransform.com/filterexample.html and then 
post any questions here.  Perhaps you will have some tricky examples 
you will need help with.  If so please post some sample code to be 
parsed as well as your best guess for the rules involved.

Monty Zukowski

ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit -- 
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2105 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050122/88b59aae/attachment.bin


More information about the antlr-interest mailing list