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

Initial implementation of ANTLR4 Lexer Support #5206

Merged
merged 4 commits into from
Jan 8, 2023

Conversation

lkishalmi
Copy link
Contributor

Take number 2.

This is a bunch of collected knowledge, help to integrate ANTLR v4 based Lexers into NetBeans. This PR does not include the change of the existing ANTLR v4 based languages. If this one goes through, I'd provide separate PR-s for:

  • ANTLR Language Support
  • TOML Support
  • JSON Support

I could use this on my upcoming projects for:

  • Terraform, for two or more lexers
  • GoLang Lexer
  • Maybe: HTTP Lexer, may create a new Language Support tutorial featuring that simple grammar.

@lkishalmi lkishalmi added the ANTLR label Jan 5, 2023
@lkishalmi lkishalmi added this to the NB17 milestone Jan 5, 2023
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. Although, the last time i wrote a grammar was over a decade ago for the NetBeans GL and CL packs - so I am not going to be able to spot bugs just by looking at it :)

consider adding the test to the CI ide-modules-test job:
https://github.com/apache/netbeans/blob/master/.github/workflows/main.yml#L341
since they won't start running automatically.

@lkishalmi lkishalmi merged commit 89b7a09 into apache:master Jan 8, 2023
@matthiasblaesing
Copy link
Contributor

I know this is already in, but one thing I thought about when looking at this was: are we prepared to make this API yet or should this be a purely internal package (i.e. Friend-only API without external users)?

@lkishalmi
Copy link
Contributor Author

Well, this one does not introduce something big/groundbreaking. It's only 4 classes. Two of them: AbstractAntlrLexerBridge and LexerInputCharStream are actually implementations of an existing API. The AbstractAntlrLexerBridge.LexerState duties and usage is strict and well defined, that leaves AntlrTokenSequence as new here. That one is also simple and straight forward enough.

I could imagine that there could be bugs in the implementation, though I'd not expect the API change without keeping backward compatibility any time soon. (Unless ANTLR forces us to do so...)

@lkishalmi
Copy link
Contributor Author

Hmm. Could make the LexerInputCharStream package private though...

pepness pushed a commit to pepness/incubator-netbeans that referenced this pull request Jan 9, 2023
* Initial implementation of ANTLR4 Lexer Support

* More documentation on AbstractAntlrLexerBridge

* Added lexer.antlr4 test to GH Workflows

* Removed System.out.println from tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants