Skip to content

Commit

Permalink
Return lazily instantiated syntax nodes in the correct order.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarber committed Aug 2, 2009
1 parent 6cab58a commit 4407c42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/treetop/runtime/syntax_node.rb
Expand Up @@ -25,7 +25,7 @@ def elements
elements << node
end
elements
end
end.sort
end

def terminal?
Expand All @@ -43,6 +43,10 @@ def text_value
def empty?
interval.first == interval.last && interval.exclude_end?
end

def <=>(other)
self.interval.first <=> other.interval.first
end

def extension_modules
local_extensions =
Expand Down
8 changes: 8 additions & 0 deletions spec/compiler/character_class_spec.rb
Expand Up @@ -235,5 +235,13 @@ module ModFoo
result.elements.size.should == 2
end
end

describe "a character class with a label mixed with other expressions" do
testing_expression 'upper:([A-Z]) "b"'
it "returns the correct element for the labeled expression" do
result = parse('Ab')
result.upper.text_value.should == "A"
end
end

end

0 comments on commit 4407c42

Please sign in to comment.