Permalink
Browse files

Run Grammar variable pattern through Pegarus.pattern.

  • Loading branch information...
1 parent 888bd88 commit d8e10a488c0675cacfabbe4a6c079e6d1bd13d62 @brixen committed Nov 6, 2010
Showing with 9 additions and 3 deletions.
  1. +1 −1 lib/pegarus/ast/grammar.rb
  2. +8 −2 spec/ast/grammar_spec.rb
@@ -27,7 +27,7 @@ def initialize(variable=nil)
def set_variable(name, pattern)
variable = get_variable name
- variable.pattern = pattern
+ variable.pattern = Pegarus.pattern pattern
variable
end
View
@@ -47,8 +47,14 @@
describe "Pegarus::Grammar" do
it "returns a Variable instance with the name of the method invoked" do
grammar = Pegarus.grammar
- variable = grammar.pattern
- variable.name.should == :pattern
+ variable = grammar.start_rule
+ variable.name.should == :start_rule
variable.pattern.should be_nil
end
+
+ it "converts the pattern into a Pegarus pattern" do
+ grammar = Pegarus.grammar
+ grammar.start_rule = ["!&"]
+ grammar.start_rule.pattern.should be_an_instance_of(Pegarus::Set)
+ end
end

0 comments on commit d8e10a4

Please sign in to comment.