vscode-antlr4: Split grammar changes not detected during debug
I have a separate lexer and parser grammar files. When I change the lexer file its changes are not picked up and reflected in the (awesome!) debug view.
I also sometime get an parser error that the TOKEN referenced cannot be found.
<Error>"<missing TOKEN>"
I use options { tokenVocab=<lexer-file>; } in the parser grammar file to reference the lexer file.
Also use lexer grammar <lexer-file> and parser grammar <parser-file> in respective files.
The two files live side-by-side in the same directory.
Closing the debug view before debugging again, does not help.
Deleting the temp .antlr folder does not help.
When I restart vscode I get one good run.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25 (10 by maintainers)
Commits related to this issue
- Ensure correct path separator for files used as keys Fixes bug #97. — committed to mike-lischke/vscode-antlr4 by mike-lischke 5 years ago
Ok, I think I have found something, @mike-lischke
I was seeing 3 SourceContext objects for my test case with 2 files. The lexer file -that is a dependency to the parser file and the file I was editing - was in there 2 times. Cant be, I hear you say, It’s a map that guarantees a unique key. They were unique.
One file path (the key) ended with
path/file.g4and one ended withpath\file.g4. This difference exists because when the lexer file is loaded as a dependency (while debugging the parser) its path is built up in code. That code uses a hard coded forward slash. But on Windows, vscode reports the file path with a back-slash.This code lives in the backend
facade.tsin theloadDependencymethod.The solution is to use a file path separator that is in sync with the operating system its running on. When I changed the hard-coded forward slash to a backward one (I am on Windows) it worked like charm.
path.join()should work, right?