forked from nathansobo/treetop
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repeated subrules produce serial-numbered accessor functions
- Loading branch information
Showing
3 changed files
with
41 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper") | ||
|
||
module RepeatedSubruleSpec | ||
describe "a repeated subrule" do | ||
testing_grammar %{ | ||
grammar Foo | ||
rule foo | ||
a:'a' space b:'b' space 'c' | ||
end | ||
rule space | ||
' ' | ||
end | ||
end | ||
} | ||
|
||
it "should produce a parser having sequence-numbered node accessor methods" do | ||
parse("a b c") do |result| | ||
result.should_not be_nil | ||
result.should respond_to(:space1) | ||
result.should respond_to(:space2) | ||
result.should_not respond_to(:space) | ||
result.should respond_to(:a) | ||
result.should respond_to(:b) | ||
result.should_not respond_to(:c) | ||
end | ||
end | ||
end | ||
end |