mike-lischke / antlr4ng

Next Generation TypeScript runtime for ANTLR4
Other
66 stars 11 forks source link

Lexer's _input property is not exported in types #5

Closed antoniom closed 8 months ago

antoniom commented 8 months ago

My grammar uses a semantic predicate

TEXT: ('{' { String.fromCharCode(this._input.LA(1)) !== "{" }? | ~[{] )+ ;

Moving from antlr4's "native" Javascript runtime to antlr4ng Typescript runtime I noticed that the generated Lexer is complaining because this._input does not exist.

By looking at Lexer.d.ts I figured out that the property is not included, was this intentional?

Moreover, I have noticed that _input is also stored in a _tokenFactorySourcePair tuple. Can i use _tokenFactorySourcePair[1] to obtain my _input ?

mike-lischke commented 8 months ago

I'm in the process of renaming certain properties to their canonical TypeScript form. Particularly those with a leading (and sometimes trailing) underscore strike me odd every time I see them. antlr4ts also contains a few renames, but does not go the full way.

What I renamed so far are:

antoniom commented 8 months ago

Didn't notice inputStream, thanks!

br0nstein commented 8 months ago

@mike-lischke It seems like Lexer is missing _mode (and other fields that should be public per ANTLR4 java docs)

mike-lischke commented 8 months ago

Right, many things are missing. I'm on the way to fix all that (see the effort in the ts-migration branch). Haven't come to Lexer yet, though.