[antlr-interest] Flumoxed by Javascript Target

Jim Idle jimi at temporal-wave.com
Thu Apr 30 08:58:21 PDT 2009


Hugo Leeney wrote:
> Hi All,
>
> I had an idea that it would be good to use some of my Antlr knowledge
> to solve a problem I'm solving in javascript. Unfortunately I haven't
> been able to get started yet.
>
> I'm totally confused how I should start. This page
> (http://www.antlr.org/wiki/display/ANTLR3/ANTLR3JavaScriptTarget) says
> the the javascript target is integrated into the release but when I
> try a simple grammar the simple Calculator example I get
>
> error(10):  internal error: group JavaScript does not satisfy interface ANTLRCor
> e: mismatched arguments on these templates [treeParser(grammar, name, scopes, to
> kens, tokenNames, globalAction, rules, numRules, bitsets, labelType, ASTLabelTyp
> e, superClass, members, filterMode)]
>
> Looking at the google group I thought I should go about building the
> javascript target -
> http://code.google.com/p/antlr-javascript/wiki/BuildingANTLRJavaScriptTarget
>
> That page seems to be out of date though. It says -
> "Build ANTLR itself. See the note by Hamilton at this page
> http://www.antlr.org/wiki/pages/viewpage.action?pageId=732 "
>
> That page says to build ANTLR by calling 'ant' in the main directory
> where build.xml is... ANTLR 3.1.3 uses Maven right? Theres no
> build.xml  (outside of some of the target source directories).
>
> Can anyone give me friendly shove in the right direction?
>   
I don't think that the Javascript target was ever finished to be honest.

Many people find it easier to unjar the 3.1.3 jar, then set CLASSPATH to 
include the expanded directories (note you will see that there is the 
tool, runtime and so on), but I hate messing around with CLASSPATH as it 
always seems to get out of sync ;-). You can then work on your templates 
directly in that tree.

If you are serious about developing a target, then the best thing to do 
is ask Terence for a perforce account, sync the source and create a new 
directory js2 or something like that. Then copy the templates from the 
Java target and add a Targetxxx.java. Go through each template and add a 
text like "TBD - template xyz", so that when the code is generated, you 
will always get an error telling you what you have not yet done. There 
are debug options and so on but doing this will force you to read every 
template before you start and you will know a lot more about what you 
are facing (and can give up then if you like ;-).

When you have a p4 sync you can build the jars by following the 
instructions in BUILD.txt

Jim


More information about the antlr-interest mailing list