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

Implement ANTLR based TokenMaker #353

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Conversation

tisoft
Copy link

@tisoft tisoft commented Aug 8, 2020

Fixes #221

@coveralls
Copy link

coveralls commented Aug 9, 2020

Coverage Status

Coverage remained the same at 70.747% when pulling d22c991 on tisoft:antlr into 685a7ee on bobbylight:master.

@tisoft tisoft force-pushed the antlr branch 2 times, most recently from 23eb771 to 62cf009 Compare August 10, 2020 16:02
@tisoft
Copy link
Author

tisoft commented Aug 10, 2020

Hi @bobbylight,

What do you think about this? Is this something you would think of as usefull?

My design goal for this was not to recreate the same token output as the existing TokenMakers have, but to use unchanged
Antlr grammars as input. Most Antlr Grammars should be supported, except ones that use lexer modes, since I currently have no way to keep track of the mode stack. Multiline tokens (like Comments or Strings) should be supported, if they are correctly given in the constructor. Some grammars need a bit of extra love, like Python, since they insert dummy tokens, that need to be filtered out. And most grammars need a quick fix to support skipped tokens. All of this can be done by overriding the compiled Lexer classes. No access to the grammar files is needed. So you could still build a Syntax Highlighter for a language where you got the Lexer from a vendor as compiled class.

Next step is creating a bit of documentation on how to use it. I have added some example grammars to the demo application for a quick start.

I see the following possibilities, going forward:

  1. Add it as subproject to this project
    • users would depend on "com.fifesoft:rsyntaxtextarea-antlr4:${version}", which would pull in the antlr4 runtime
    • this PR would lead to something like this
  2. Merge it into the main code base
    • the antlr-runtime would need to be made optional in the pom
      • it is needed for compiling
      • it is only needed at runtime, if the user uses the antlr support
    • users would depend on "com.fifesoft:rsyntaxtextarea:${version}" and explicitly on "org.antlr:antlr4-runtime:${version}"
  3. Create a new project in your namespace
    • maven coordinates would probably be the same as in 1.
  4. Create a new project in my namespace
    • maven coordinates would be in the "de.tisoft" namespace

@tisoft tisoft force-pushed the antlr branch 2 times, most recently from 68b523f to 387d5f6 Compare August 12, 2020 07:15
@tisoft tisoft marked this pull request as ready for review September 14, 2020 16:02
@ice1000
Copy link

ice1000 commented Feb 4, 2021

Can we have the com.fifesoft:rsyntaxtextarea-antlr4:${version} thing as a third-party library?

@tisoft
Copy link
Author

tisoft commented Feb 12, 2021

@bobbylight Would you consider adding this? Otherwise I will create an own project for it.

@tisoft
Copy link
Author

tisoft commented Feb 27, 2021

As it seems, this is not going to get merged, I have created my own project:
https://github.com/tisoft/rsyntaxtextarea-antlr4-extension

It is the same code as in this PR, just moved to my namespace. I have not yet added the examples, but the code is usable. Also documentation is missing, yet.

I'm open for feature requests, bug reports and improvements.

First release is already in Maven Central:
https://search.maven.org/artifact/de.tisoft.rsyntaxtextarea/rsyntaxtextarea-antlr4-extension

I will leave this PR open, if there is interest from @bobbylight to merge this in, I'm more than happy to do so.

@bobbylight
Copy link
Owner

@tisoft Thanks for taking the initiative here, I've been stretched too thin and have neglected RSTA. This is something that's been requested for a while now, as you're aware. I hope to check out this PR soon, though it may be some time in April.

BTW, I saw you made an Antlr 6502 parser - is that out of interest on your part, or did you just grep projects for Antlr implementations for a breadth of test cases? Learning NES Assembly programming is also on my todo list :)

@tisoft
Copy link
Author

tisoft commented Mar 12, 2021

@bobbylight Thanks for the status update!

I'll update this PR with the improvements I made and will keep it current.

I just took some example grammars, to have something for the demo program and for testing. My goal is to match every from your supported languages with an ANTLR based and have some more. 😆

@tisoft
Copy link
Author

tisoft commented Mar 21, 2021

I have rebased against master and also updated the code with the latest changes I did in my fork.

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

Successfully merging this pull request may close these issues.

Generating editors for ANTLR grammar using RSyntaxTextArea
4 participants