javac lexer parser rewrite

leszekp at Safe-mail.net leszekp at Safe-mail.net
Wed Feb 8 07:52:15 PST 2012


Both hand-coded parser and generated one has some advantages and disadvantages.
Of course it is good to have plain java code and have the possiblitity to debug it.

But as level of complication rises, at some point hand-written parser becomes unamanageable anyway.
In example Pascal language was designed to be LL(1) and hand-written recursive descent
parser for this language is probably quite understandable. But java wasn't designed that way
and its hand-written parser has a lot of quirks which made it complicated to understand.

I am experimenting with jflex generated java lexer. It is very fast - comparable
to original javac Scanner, it is promising.

regards
Leszek

-------- Original Message --------
From: Per Bothner <per.bothner at oracle.com>
To: Maurizio Cimadamore <maurizio.cimadamore at oracle.com>
Cc: leszekp at safe-mail.net, compiler-dev at openjdk.java.net
Subject: Re: javac lexer parser rewrite
Date: Tue, 07 Feb 2012 08:35:51 -0800

> On 02/07/2012 02:27 AM, Maurizio Cimadamore wrote:
> > So, is it messy? Sure - is it fast? Yes, like hell. So, to summarise, I
> > think that any effort to try to improve our parser/lexer architecture is
> > definitively welcome - however, anyone embarking on such a project
> > should keep the above numbers in mind - if you can achieve the same
> > speed (well, even marginally slower would be acceptable) than it'd be an
> > option well worth considering.
> 
> Another advantage of a hard-written parser/lexer, besides speed, is that
> it is flexible (if you need to handle special cases).
> 
> Furthermore, it is easy to understand what is going on, and easier to debug.
> Imagine trying to set breakpoints in a generated parser or otherwise try
> to figure out why something is parsed the way it is.  A hard-written
> parser/lexer is more verbose and shows all the details - but at least
> what you see is plain debuggable Java code, and you don't need a special
> tool or understanding.
> -- 
> 	--Per Bothner
> per.bothner at oracle.com   per at bothner.com   http://per.bothner.com/



More information about the compiler-dev mailing list