-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support for combined grammars #3
Comments
Hey, sorry for the delay in replying! Thanks for trying this out, it's kind of rough at the moment and it's been a while since I worked on it, but it should work. So you should be running the following from within the folder that holds your If you're doing that properly and it's still showing errors, then there must be a bug. I don't have the time today to test this out for you but I'll have a go over the weekend and see if I can reproduce your issue. In the meantime, if you try this again could you paste any exceptions you're getting, just so I have them to go through. |
Thanks. Here's what I'm doing: I downloaded grunsharp_0.0.1_windows.zip and unzipped it to a folder. Then I copied the following files to it (attached to this post as well):
I then ran the following command after cd'ing to that location in cmd:
So it looks like the program can't find the following file: PropertyFileParserListener. The problem is, no such file is ever being generated by anltr4 tool. The only other genereated cs files, apart from Lexer and Parser are (also attached for reference): |
Aha! It doesn't look like grunsharp handles combined grammars, just split ones. I guess I didn't realise that the output files are different if you use a combined grammar. I'll fix that this weekend. You should be able to get it working if you split your grammar into parser and lexer, like it mentions here: https://github.com/antlr/antlr4/blob/master/doc/grammars.md |
I tried splitting the file into two parts, but antlr still didn't generate the other required file (PropertyFileParserListener). Is there a special naming convention I should be using for the g4 files? |
I've uploaded a fix so that your combined grammar should work, try out the latest release and let me know if you have any other issues. I'd assumed that the .cs files generated had a certain naming format, but it turns out they're just named based on the name of your grammars. I've changed the executable's name to "grunsharp.exe" also, so you'll need to modify the command you were using (I'm going to update the readme now). Hope that helps! |
Still can't get it to work. No exceptions this time, but nothing would happen. Downloaded source code, and ran from visual studio, setting Debug Command line arguments to the following: I placed attached files inside /bin/Debug folder: The code throws an exception inside Main.cs, line 41:
with the following message: because the following line does not find a lexer type:
|
Hmm, okay. I'll look into that. |
I'm not sure what am I doing wrong. I'm going through the examples in 'Definitive ANTLR 4 Reference' book, and generating my C# parser/lexer files using the following command:
antlr4 -Dlanguage=CSharp PropertyFile.g4
The grammar name is: PropertyFile, and the root rule is 'file'. Here's the grammar file "PropertyFile.g4":
Here's my test file t.properties:
I end up with the following C# generated files:
PropertyFileLexer.cs
PropertyFileParser.cs
I wanted to use your tool to generate the gui tree directly from C# files (instead of having to compile java lexer/parser first, and then using: grun PropertyFile file -tree). The problem is, no matter what combination of input args I try, I end up with exceptions during startup (looks like grunsharp can't find parser file). I tried the following command arguments:
PropertyFile file t.properties --gui
based on readme it should be:
GrunCS.exe <grammar name> <start rule> <input files>... [--gui] [--tokens] [--config=<path>]
What am I doing wrong?
The text was updated successfully, but these errors were encountered: