-
Notifications
You must be signed in to change notification settings - Fork 12
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
Ruby 1.9.1 + antlr3 1.7.5 - mismatched character "+"; expecting "+"? #6
Comments
Also I forgot to mention that I'm using Ubuntu linux (10.4 Lucid Lynx version). |
Hey there Cadmium -- thanks for the bug report and the thorough details you took the time to include. The good news is that your code is correct, and you are using the correct procedure. However, the bad news is that I have not made ANTLR code function correctly in Ruby 1.9 yet. I targeted the code for 1.8.7 and Ruby implementations that are compatible with that version. I discovered later in the design process that the fact that statements like For straightforward ANTLR rules, the code usually works -- strings are still being compared with strings inside those long methods. The problem is that parser rules which require more complicated decisions use a special state machine object (see the So, inevitably when you run your calculator program, the lexer is calling on a DFA object to choose the best lexer rule the current position in the input text. In Ruby 1.8.7, the input stream is feeding the DFA with integer character values for each character in the string and everything works: integers are being compared against integers. In Ruby 1.9.1, the input stream is feeding the DFA string objects for each character. For some reason, the first few attempts at choosing a token just fail out and those "mismatched character" errors are printed out. Eventually, the DFA tries to check the string against a min and max integer character value by calling the #between? method, and that error is raised. I know that explanation's a bit haphazard, but I hope it gives you some understanding of the error itself. I do plan on making it work with Ruby 1.9 very soon -- it shouldn't be too difficult, though it will probably require a bit of editing to the code generation templates and the runtime library code. I've just been too busy with work and other adult-like demands like that to get around to repairing that. I'll try to work it out this upcoming weekend. Best Regards, |
Hi Kyle, |
Hey Cadmium, Good news -- I fixed the Ruby 1.9 incompatibilities, as promised. I published a new gem (version 1.8.0). If you would like, check it out and see if it works for you. If you come across any bugs that weren't caught by the tests (which all passed with 1.9), let me know. I just figured I'd give you a heads up. Best Regards, |
Thanks Kyle, it works great! Hopefully now more people will try antlr on Ruby! |
Heya Cadmium, Thanks -- I'm glad it did the trick for you. Let me know if anything else comes up along the way. Kyle |
Hi Kyle,
I'm running the 1.7.5 version of the antlr3 gem, and I'm constantly running into the same kind of problem (it might just be because I'm a noob at antlr!)
I tried running your example code.
In file "AddingMachine.g" I put the following grammar:
To test it, I created a file "AddingMachine.rb" which contains:
I ran "antlr4ruby AddingMachine.g" to generate the lexer and parser files. Then when I ran "ruby AddingMachine.rb" however, I got the following error:
I'm at a loss to understand what's going on so I'm hoping it makes sense to you! Did I make a mistake in how to use antlr3?
Thanks very much in advance,
Cadmium.
The text was updated successfully, but these errors were encountered: