Custom language support with handbuilt lexer and parser
Hi. I have extracted .bnf and .flex files to learn about parsing API. I think I get it now and will try to integrate an ANTLR grammar. Attaching handbuilt version of Custom language support
Attachment(s):
SimplePluginHandbuiltLexerParser.zip
Please sign in to leave a comment.
Super, thank you, it what i looking for long time!
Hello! I just try to play with your code. I did post it to github for easy changing it. https://github.com/brizjin/simple_language_plugin
I understand that this just example how to impliment own parser. But it brokes on this Simple language. I did try to imrove it by starting write test to it, and i stuck with Parser test. This ParsingTestCase class needs to all test data have to be saved on disk before test. And when i run test it get an exception:
ERROR: Language Language: Simple doesn't participate in view provider SingleRootFileViewProvider{myVirtualFile=LightVirtualFile: \ParsingTestData.simple, content=VirtualFileContent{size=433}}: [Language: ANY]
It seems like i have to install my plugin before testing. But tests runnig in current IDEA not in IDEA which starts for debugging.
I try to find way how to run parse.parse just to send text and lexer to it and I didn't find. Is there way how i can run test for Paser?
Thank you!
Hello Ivan,
are you trying to implement own lexer and parser from 0?
Yes. And parser and lexer already works. And I wonna to write tests for it. Is there way to just pass Text of my lang and it lexer to Parser and compare results? In Idea tutorial example i should use ParsingTestCase class, which constract idea ide object then read data files and after test it. When i use it i get error:
ERROR: Language Language: Simple doesn't participate in view provider SingleRootFileViewProvider{myVirtualFile=LightVirtualFile: \ParsingTestData.simple, content=VirtualFileContent{size=433}}: [Language: ANY]
How can I solve it? But better I prefer even not save files and just pass text from strings in tests.
> parser and lexer already works.
well done! I thought this was the stumbling block.
> And I wonna to write tests for it. Is there way to just pass Text of my lang and it lexer to Parser and compare results?
sorry, I did not try this. can't help.