antlr3 icon indicating copy to clipboard operation
antlr3 copied to clipboard

JavaScript target is broken in the latest (v3.5) release

Open zerkms opened this issue 11 years ago • 10 comments

If you try to compile any grammar for tests directory, say t001lexer.g

lexer grammar t001lexer;
options {
  language = JavaScript;
}

ZERO: '0';

you'll get a bunch of errors including:

error(24):  template error: JavaScript.stg 27:6: required parameters (filterMode) must appear before optional parameters

Which is expected because of

lexer(grammar, name, tokens, scopes, rules, numRules, labelType="Token",
      filterMode, superClass="org.antlr.runtime.Lexer") ::= <<

in JavaScript.stg

Reproducible in linux and windows using OpenJDK v 1.6.0_20 and JRE 1.7.0_21 correspondingly

The actual result: nothing is generated

The expected result: the .js and .tokens files to be generated

zerkms avatar May 12 '13 23:05 zerkms

I've got same problem. Are there any solutions?

vlkv avatar Sep 24 '13 04:09 vlkv

Is this just a simple matter of changing the order of the arguments? ie:

lexer(grammar, name, tokens, scopes, rules, numRules, filterMode, labelType="Token", superClass="org.antlr.runtime.Lexer") ::= <<

I don't know enough about named argument passing in Javascript to discuss this...

whitten avatar Sep 24 '13 14:09 whitten

sounds like that's the problem. That could be just one of many as I've never used that target.

parrt avatar Sep 25 '13 17:09 parrt

For now we have to use antlr-3.3 (where JavaScript target seems to be working). And in 3.3 JavaScript.stg looks no different from 3.5 version. So I guess that the problem is not in the stg template file itself.

Could you please fix JS target in 3.5? We are going to use it heavily in our business project

vlkv avatar Sep 27 '13 05:09 vlkv

@vlkv The language targets for this project are typically updated by the individual maintainer of the particular target. I don't know who, if anyone, is currently working on or maintaining the JavaScript target.

sharwell avatar Sep 27 '13 12:09 sharwell

As an aside, is there a JavaScript target for Version 4 ?

On Fri, Sep 27, 2013 at 8:19 AM, Sam Harwell [email protected]:

@vlkv https://github.com/vlkv The language targets for this project are typically updated by the individual maintainer of the particular target. I don't know who, if anyone, is currently working on or maintaining the JavaScript target.

— Reply to this email directly or view it on GitHubhttps://github.com/antlr/antlr3/issues/111#issuecomment-25241071 .

whitten avatar Sep 27 '13 13:09 whitten

@whitten Not currently, and no one has currently volunteered to take on that task. Unlike ANTLR 3, targets for ANTLR 4 are completely independent projects developed, hosted, and maintained by the maintainer of that target.

sharwell avatar Sep 27 '13 13:09 sharwell

Hey! I'm using Antlr 3.5 and even I am getting error for Javascript Target. Is there any solution for the problem?

djadmin avatar Feb 20 '14 09:02 djadmin

3.4 also has this issue. 3.3 doesn't, but it is buggy, mixing C to JS by putting something like (const char*) to the generated file :(

sorawee avatar Jul 06 '15 21:07 sorawee

Hi,

You probably want to switch to 4.5.1 directly. I don’t expect anyone will look into this.

Eric

Le 7 juil. 2015 à 05:58, sorawee [email protected] a écrit :

3.4 also has this issue. 3.3 doesn't, but it is buggy, mixing C to JS by putting something like (const char*) to the generated file :(

— Reply to this email directly or view it on GitHub https://github.com/antlr/antlr3/issues/111#issuecomment-119008577.

ericvergnaud avatar Jul 07 '15 12:07 ericvergnaud