[antlr-interest] How to implement one script parser?
jimi at intersystems.com
Mon Mar 5 09:16:19 PST 2007
The C output of ANTLR3 requires that you link the parser/lexer with the
C runtime library. However this builds in both DLL and .LIB for (Windows
terminology) so you can link it in with your script engine as either DLL
or archive form. With the archive form it would only pick up the things
you actually use. However the entire library is about 40K (Windows) in
optimized mode and you may be able to make I smaller than this by
optimizing for code size rather than performance. There are no license
restrictions on the runtime of course.
As far as the whole thing being less than 100K, well that depends on the
target machine. For instance while the library is 40K on Windows 32 bit
Intel, it is about 240K on 64 bit HPUX for exactly the same output. But
the binaries come with all sorts of ancillary information. What you are
better off looking at is the memory footprint once executing.
You might be able to keep it all under 100K with the correct
optimizations but in general when you start embedding output text in
there, the text itself takes up data space. The executable code may well
be less than this though - it depends entirely on what you script is
going to do, whether you need a tree parser as well as a parser (you may
well need one for a complicated script language and so on.)
The best way to start might be to take the existing C grammar and
convert it to ANTLR 3 (maybe someone did that already) then select C
output language. I will be doing this before too long but it will be a
few weeks yet.
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Miguel Ping
Sent: Monday, March 05, 2007 2:38 AM
To: Hongjun Chen
Subject: Re: [antlr-interest] How to implement one script parser?
What do you mean with spec.2? I think any parser written with ANTLR
needs ANTLR runtime libs to run... You should be able to wrap it up
all in a single package, including antlr libs, but I think you will
always need antlr runtime... Putting it another way, the generated
parser that antlr makes uses some antlr runtime stuff to work
properly. At least I think that's how it works in the Java version,
but it should be the same in any other language...
On 3/5/07, Hongjun Chen <r66092 at freescale.com> wrote:
> Hi all,
> I am new to ANTLR, and I intend to develop one script parser
> ANTLR, but I wonder whether ANTLR can meet my need. The spec. of
> parser is listed below, could anyone shed light on these problems? I
> appreciate your help.
> Spec.1 Script parser should be written in C-language;
> Spec.2 Script parser can execute without any help of ANTLR;
> Spec.3 The grammar of script is similar to C or python;
> Spec.4 The size of script parser should not exceed 100KByte.
> Could anyone provide one example/steps on constructing a script
> so, it must be very helpful. Thanks in advance!
> Best Regards,
> Hongjun Chen
More information about the antlr-interest