-
Notifications
You must be signed in to change notification settings - Fork 59
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
TypeError on collectCandidates #15
Comments
I created a "pure" TypeScript project and used |
I am also seeing this same issue when using the Using:
My grammar test (based on the docs):
The grammar is compiled using My code (based on the docs):
The error:
The lines: I've tried adding the inputStream to the parser via Is |
I modified my parser manually and was able to prevent the errors from being thrown. It appears that the
I think this is a bit of progress, however I'm still getting 0 candidates back. I assume this has to do with the lack of
Given the other errors I was seeing, I'm assuming there's something fundamentally different about the JavaScript parser/lexer than the ones generated by |
@kaidjohnson You know you are writing to a closed issue? Please don't hijack already finished issues but create a new one, if required. Indeed there are differences between the JS and TS runtime versions. The authors of @antlr4ts insist on implementing their runtime in a way that is optimal for the TS language, thereby sacrificing compatibility. Best would be you open an issue against @antlr4ts, asking for more compatibility. However, I remember a discussion where people spoke about making the TS target the main one and generating the JS target from it. The current handwritten JS target would then be obsolete. |
@mike-lischke It wasn't my intention to "hijack" anything. The issue I was seeing was the same as the user that posted the original issue here, and I thought I might get some additional insight into what the options were to get around it. Every git repo owner seems to have a different preference for creating tickets -- some complain about opening duplicates, some complain about extending closed tickets. It's always a 50/50 gamble; didn't mean to ruffle any feathers. My current JS target was not handwritten, but rather generated via the core antlr4 library. FWIW, I did work around the issue after a bit more trial-and-error by generating my parser and lexer via antlr4ts, converting the resulting ts (es2015 target) to js (using babel) -- the typescript es5 target wasn't handling the class conversion well -- and then using the core antlr4 runtime (not the ts version) for use in the browser. The parser needed to patched slightly to be compatible with the core Parser class from antlr4ts, but after that small patch (see below), I am getting tokens back. Here's the patch, which essentially just copies over the missing method from antlr4ts:
For now, this resolves the issue for me and I am able to run the antlr4-c3 engine in the browser. Should I run into any other issues, I'll be sure to open a new ticket. Thanks! |
Hi,
I am trying to start a project to try out the c3 engine, but I am running into a little obstacle early on. I am setting up the scaffold as outlined in the
Getting Started
section of the README, but I get the following error when I do thecore.collectCandidates(0)
call:I am assuming that there is some initialization that I haven't done, but I cannot figure it out. Below is the setup leading up to the failing call.
This is using a parser generated by
antlr 4.7.1
with a JavaScript target andantlr4-c3 1.1.8
. Hopefully someone can glance at the code and tell me where I am going astray.Stepping through the code, it looks like when I call
c3.CodeCompletionCore(parser)
the member variables get set (includingthis.parser = parser;
), but when I callcore.collectCandidates
, theparser.inputStream
variable is undefined:It looks to me like I am not setting the
tokenStream
correctly since there is no definition of the inputStream on the parser object.The text was updated successfully, but these errors were encountered: