spec/rley/parser/parsing_spec.rb in rley-0.1.02 vs spec/rley/parser/parsing_spec.rb in rley-0.1.03
- old
+ new
@@ -24,12 +24,12 @@
let(:b_) { Syntax::VerbatimSymbol.new('b') }
let(:c_) { Syntax::VerbatimSymbol.new('c') }
let(:prod_S) { Syntax::Production.new(nt_S, [nt_A]) }
let(:prod_A1) { Syntax::Production.new(nt_A, [a_, nt_A, c_]) }
let(:prod_A2) { Syntax::Production.new(nt_A, [b_]) }
- let(:start_dotted_rule) { DottedItem.new(prod_S, 0) }
+
# Helper method that mimicks the output of a tokenizer
# for the language specified by gramma_abc
let(:grm1_tokens) do
[
Token.new('a', a_),
@@ -38,10 +38,13 @@
Token.new('c', c_),
Token.new('c', c_)
]
end
+
+ let(:start_dotted_rule) { DottedItem.new(prod_S, 0) }
+
# Default instantiation rule
subject { Parsing.new(start_dotted_rule, grm1_tokens) }
context 'Initialization:' do
@@ -126,10 +129,10 @@
%w(a a b c c).map do |letter|
Token.new(letter, sample_grammar1.name2symbol[letter])
end
end
-
+
it 'should build the parse tree for a non-ambiguous grammar' do
parser = EarleyParser.new(sample_grammar1)
instance = parser.parse(token_seq1)
ptree = instance.parse_tree
expect(ptree).to be_kind_of(PTree::ParseTree)