4

What is the status of the JavaScript target in ANTLR 3.4 or 3.5? I have been looking online for an answer to this question but so far I have found nothing. I know that it was broken in v3.2 and then it was fixed in v3.3, but it's not listed in the ANTLR 3.4 release notes as a target that is consistent with ANTLR 3.4.

I have a project in which I need to convert the Java target ANTLR grammar which I had previously written to JavaScript and I want to make sure that the JavaScript target is supported by ANTLR 3.4 or 3.5 before I proceed.

kchadha
  • 61
  • 4

1 Answers1

2

ANTLR 3.1 and 3.2 had some bugs w.r.t. generating JavaScript code1, but you should be okay with version 3.3.

You can find the JavaScript runtime here: http://www.antlr3.org/download/antlr-javascript-runtime-3.1.zip

A small demo of how to use ANTLR + JS can be found in this Q&A: ANTLR PCRE Grammar to JS Target

1 http://www.antlr.org/wiki/display/ANTLR3/ANTLR3JavaScriptTarget

Community
  • 1
  • 1
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
  • Hi Bart, I tested a very simple grammar and the one in the tutorial you linked to above in ANTLR 3.4 and 3.5 and neither of them work in either version as you said they would. They do work in ANTLR 3.3. In ANTLR 3.4 and 3.5 I get the same error as the person in the tutorial you linked to above (the generated JS parser has errors like empty Objects). I also noticed that in the tutorial, you said you removed global backtracking from your original grammar in order to make it work with the JS target. Does the JS target not support global backtracking? – kchadha Dec 01 '13 at 18:34
  • @kchadha, ah, okay, I removed 3.4 and 3.5. Thanks. I' not 100% sure, but I think backtracking works in the JS target, but one should try to avoid it (regardless of what target you use). – Bart Kiers Dec 01 '13 at 21:10