Javascript Target Woes

181 views
Skip to first unread message

jg4296

unread,
Mar 31, 2015, 1:38:17 AM3/31/15
to antlr-di...@googlegroups.com
Hi, Following the instructions on the javascript target page results in a couple of issues.

Firstly, I get a lot of 'not well-formed' issues and syntax errors when loading up the javascript target (in Firefox, in Chrome it doesn't even load due to cross domain issues).

Secondly, when walking the tree with a custom listener, I get a TypeError of 'listener.enterEveryRule is not a function'. If I add that (and exitEveryRule and VisitTerminal), then the walk occurs, but without any of my custom exit and enter rule functions firing apart from the everyRule and visitTerminal functions.

Am I missing something obvious somewhere or is this just the state of the javascript target at the moment?

Thanks
John

Terence Parr

unread,
Mar 31, 2015, 11:32:43 AM3/31/15
to antlr-di...@googlegroups.com
Hi John, can you submit some bugs with well formed simple examples to


Ter
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Vergnaud

unread,
Apr 1, 2015, 11:13:31 AM4/1/15
to antlr-di...@googlegroups.com
Mmmm

The JavaScript runtime has been tested with IE, Safari, Chrome, Firefox and Node.js. 
What is your setup - asking this question because of the cross domain issue.
 
What is a "custom listener" ?. The runtime only support listeners derived from the generated listener, which itself derives from ParseTreeListener.
You're definitely missing something, although it may not be obvious.

Eric

jg4296

unread,
Apr 3, 2015, 3:44:30 PM4/3/15
to antlr-di...@googlegroups.com
By custom listener I meant the extended/derived listener object, 'KeyPrinter' in the documentation. And yeah, it was something obvious: When using require for the generated listener, I needed to do:

var KeyPrinter = function(){
   MyGrammarListener.MyGrammarListener.call(this);
}
KeyPrinter.prototype = Object.create(MyGrammarListener.MyGrammarListener.prototype);

Instead of just a single MyGrammarListener.

The syntax issues and not well-formed issues are showing up on firefox 35.0.1 on OSX 10.10.2, at line 1 for the majority of files in the antlr4 directory of the javascript runtime.


Eric Vergnaud

unread,
Apr 5, 2015, 2:38:41 AM4/5/15
to antlr-di...@googlegroups.com
Good to hear that you're back on track.
Line 1 of every file in the antlr directory is a comment, so you'll have to provide a bit more information.
Best is to do this on GitHub.
Reply all
Reply to author
Forward
0 new messages