Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer can generate parsers #306

Closed
mike-lischke opened this issue Apr 1, 2017 · 5 comments
Closed

No longer can generate parsers #306

mike-lischke opened this issue Apr 1, 2017 · 5 comments
Assignees

Comments

@mike-lischke
Copy link
Contributor

mike-lischke commented Apr 1, 2017

I haven't done this for a while (and it worked before) but with the latest antlr4ts package generating files from grammars fails. The problem is that paths are now handled different than before and I'm not 100% sure this is a problem of antlr4ts and not, maybe, by vscode (where I use this node module).

What happens is this:

  1. I have a scripts entry in my package.json for my node module:
  "scripts": {
    "antlr4ts": "antlr4ts grammars/ANTLRv4LexBasic.g4 grammars/ANTLRv4Lexer.g4 grammars/ANTLRv4Parser.g4 -o parser/ -visitor"
  },

As you can see my 3 grammar files are located in a subfolder called grammars.

  1. I run the script via npm:
npm run-script antlr4ts
  1. This gives me this output:
> antlr4-graps@1.2.17 antlr4ts /Volumes/Extern/Work/projects/antlr4-graps
> antlr4ts grammars/ANTLRv4LexBasic.g4 grammars/ANTLRv4Lexer.g4 grammars/ANTLRv4Parser.g4 -o parser/ -visitor

Generating file '/Volumes/Extern/Work/projects/antlr4-graps/parser/grammars/ANTLRv4LexBasic.ts' for grammar 'grammars/ANTLRv4LexBasic.g4'
Generating file '/Volumes/Extern/Work/projects/antlr4-graps/parser/grammars/ANTLRv4LexBasic.tokens' for grammar 'grammars/ANTLRv4LexBasic.g4'
Generating file '/Volumes/Extern/Work/projects/antlr4-graps/parser/grammars/ANTLRv4Lexer.ts' for grammar 'grammars/ANTLRv4Lexer.g4'
Generating file '/Volumes/Extern/Work/projects/antlr4-graps/parser/grammars/ANTLRv4Lexer.tokens' for grammar 'grammars/ANTLRv4Lexer.g4'
error(160): ANTLRv4Parser.g4:43:18: cannot find tokens file 'parser/ANTLRv4Lexer.tokens'
warning(125): ANTLRv4Parser.g4:47:5: implicit definition of token 'DOC_COMMENT' in parser
warning(125): ANTLRv4Parser.g4:47:41: implicit definition of token 'SEMI' in parser
warning(125): ANTLRv4Parser.g4:51:6: implicit definition of token 'LEXER' in parser
warning(125): ANTLRv4Parser.g4:51:12: implicit definition of token 'GRAMMAR' in parser
warning(125): ANTLRv4Parser.g4:51:22: implicit definition of token 'PARSER' in parser
warning(125): ANTLRv4Parser.g4:68:5: implicit definition of token 'OPTIONS' in parser
warning(125): ANTLRv4Parser.g4:68:13: implicit definition of token 'LBRACE' in parser
...

The problem here is that the output is not placed in the parser subfolder as specified, but in parser/grammars. Well, actually only the output for the first grammar. Further generation fails then because these generated files are not found.

I'm using the latest antlr4ts and antlr4ts-cli node modules.

@sharwell
Copy link
Member

sharwell commented Apr 1, 2017

😕 I haven't made any releases any time recently. Were you using a non-Windows system by any chance? If so you were probably hitting #303.

@mike-lischke
Copy link
Contributor Author

Yes, that looks related. I'm on macOS and the code generation used to work before. As a workaround I copied the jar to my grammar folder and generated my grammars directly without antlr4ts-cli.

@mike-lischke
Copy link
Contributor Author

I just realized that I also need the code generation for getting the ATN for a given grammar, so it's quite essential for me that this gets fixed soon. Sorry for the extra pressure but I'm blocked here currently.

@sharwell
Copy link
Member

sharwell commented Apr 7, 2017

Duplicate of #303

@parrt
Copy link

parrt commented Nov 4, 2017

@sharwell I added -Xexact-output-dir option to fold in a fix to output dir. See antlr/antlr4#2065

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants