Giter Site home page Giter Site logo

Comments (6)

cadmium-zz avatar cadmium-zz commented on July 21, 2024

Also I forgot to mention that I'm using Ubuntu linux (10.4 Lucid Lynx version).

from antlr3.

ohboyohboyohboy avatar ohboyohboyohboy commented on July 21, 2024

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 ?c and 'string'[ 3 ] produce string objects in 1.9 violates an assumption made in my state machine code design.

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 ANTLR3::DFA class) to run through all possible matching rule patterns before choosing the correct parser or lexer rule to invoke. These state machines use a range of character code integers to decide the next decision to perform based on the current stream character.

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.
Meanwhile, if you have 1.8.7 available, try it out with that -- it should work. Though I know if you're trying to use it for any project that requires 1.9, that solution doesn't help you out much. Let me know if you have any thoughts or suggestions, and feel free to send any other questions you have my way.

Best Regards,
Kyle

from antlr3.

cadmium-zz avatar cadmium-zz commented on July 21, 2024

Hi Kyle,
Thanks so much for such a prompt and detailed reply. Unfortunately I only have Ruby 1.9.1 installed so I'll wait until the updated version is released (don't feel it's urgent to do though, I know how busy life is!) If I have some free time I might check out the source code you mentioned to see how those characters are being processed.
This error report should prove very informative to others who may be having the same problem (I noticed that no other bug report addressed it). I'll close the issue since it's been answered.
Thanks again,
Cadmium.

from antlr3.

ohboyohboyohboy avatar ohboyohboyohboy commented on July 21, 2024

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,
Kyle

from antlr3.

cadmium-zz avatar cadmium-zz commented on July 21, 2024

Thanks Kyle, it works great! Hopefully now more people will try antlr on Ruby!
Cheers Cadmium.

from antlr3.

ohboyohboyohboy avatar ohboyohboyohboy commented on July 21, 2024

Heya Cadmium,

Thanks -- I'm glad it did the trick for you. Let me know if anything else comes up along the way.

Kyle

from antlr3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.