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

bug in CommonTreeNodeStream #21

Open
ohm314 opened this issue Apr 3, 2012 · 0 comments
Open

bug in CommonTreeNodeStream #21

ohm314 opened this issue Apr 3, 2012 · 0 comments

Comments

@ohm314
Copy link

ohm314 commented Apr 3, 2012

Dear Kyle,

First of all, thanks for writing this great code!

I think I've stumbled across a little bug in your target code though. I believe that the CommonTreeNodeStream should expose the @last_marker instance variable via an attr_reader. This is needed when tree grammars generate DFAs. The initialize_dfas method calls @input.rewind(@input.last_marker, false) which can only work if last_marker is accessible for CommonTreeNodeStream.

example, taken from generated tree parser ruby code:

      @dfa1 = DFA1.new( self, 1 ) do |s| 
        case s
        when 0
          look_1_2 = @input.peek
          index_1_2 = @input.index
          @input.rewind( @input.last_marker, false )
          s = -1

Another possibility is to fix the the generated parser code to call @input.rewind without arguments, since last_marker is the default argument of this method.

Thanks,

omar

PS. here is a patch, I don't know how to attach a file (or what is the proper github way)

--- a/orig/tree.rb
+++ b/fixed/tree.rb
@@ -1107,6 +1107,8 @@ class CommonTreeNodeStream
     return @last_marker
   end

+  attr_reader :last_marker
+  
   def release( marker = nil )
     # do nothing?
   end
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

No branches or pull requests

1 participant