From: | iank@idiom.com (Ian L. Kaplan) |
Newsgroups: | comp.compilers |
Date: | 1 Nov 2000 18:33:01 -0500 |
Organization: | Unknown |
References: | 00-10-061 00-10-193 00-10-209 00-10-221 |
Keywords: | parse, tools |
Posted-Date: | 01 Nov 2000 18:33:01 EST |
>ANTLR is at the top of my list of tools to consider. I do have a couple
>of concerns I would like answers to though:
>
>(1) [...] So how hard is it to ignore ANTLR's lexer generator capabilities
> and call one or more different lexers written in another language (e.g.,
> assembly)?
The ANTLR documentation describes how a non-ANTLR lexer can be
integrated with ANTLR. I have not done this myself, but looking
at the documentation it looks pretty straight forward.
>
>(2) Is it easy to create and merge multiple parsers into the same compiler?
Yes, ANTLR does support multiple parsers. Each parser object can be
separately named.
>
>(3) Being written in Java concerns me. What is the performance like?
The performance of an ANTLR generated C++ parser is good. Probably
very close or better than what you could write by hand using
recursive descent.
The performance of the ANTLR tool generating the parser is not that
good. ANTLR is written in Java and my experience has been that Java
based compiler applications are slow. One of my personal gripes
about Sun is that I don't feel that they have been very honest about
Java performance. For my comments on this see
http://www.bearcave.com/software/java/why_native.html
Having said this, I don't think that the performance of the ANTLR
tool is a problem. It takes a couple of minutes where it should
take thirty seconds. But big deal. Buy a faster computer (I'm
using a 300 MHz system with a fast SCSI disk).
>
>(4) How large a system can you compile with ANTLR?
From looking at HLA, it is a far smaller grammar than, say, Java. I
work with the Java grammar and ANTLR is a great tool for my
purposes.
I've already mentioned to Randy that I've been using YACC/Bison at
work on an existing compiler tool (which I did not write). The human
mind tends to forget unpleasant things. I had forgotten how clunky
and antiquated YACC/Bison is. YACC is a quarter of a century old. I
really don't miss having to put comments in the grammar labeling the
pieces of the production (e.g., $1 $2).
>My main concern at this point is "should I write it manually or should I
>use a tool?" The obvious answer to someone not familiar with HLA is to
>learn and use a better tool. As I've said, I'm considering ANTLR and
>my browser has links to lots of other compiler tool pages.
I had many of the concerns that Randy has written about. There is
always a risk when learning a new tool that the time will be wasted
because the tool is not appropriate. For the Java grammar I'm working
with the ANTLR choice has been a very good one. The only part of
ANTLR which I don't use is the automatic AST generation, which is
still a bit difficult to use if you don't want ANTLR's standard
reference counted AST nodes.
Having written all that: HLA looks like it has a relatively simple
grammar. ANTLR does have a learning curve and it may be just as well
to write the parser by hand. This might simplify the issues of the
parser calling the lexer calling the parser mentioned in the original
posting. ANTLR is complex. It is open source, so it is also
constantly evolving (which is both good and bad).
Ian Kaplan
www.bearcave.com
Return to the
comp.compilers page.
Search the
comp.compilers archives again.