Sha256: 3ebeb23c86c99f4d0d3788405f6b56390f591b2610d1bc9542c3c70e494fc00f
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
require "rly" require "rly/parse/rule_parser" describe Rly::RuleParser do it "parses a simple rule string" do s = 'expression : expression "+" expression | expression "-" expression | expression "*" expression | expression "/" expression' p = Rly::RuleParser.new productions = p.parse(s) productions.length.should == 4 productions[0].should == [:expression, [:expression, '+', :expression], nil] productions[1].should == [:expression, [:expression, '-', :expression], nil] productions[2].should == [:expression, [:expression, '*', :expression], nil] productions[3].should == [:expression, [:expression, '/', :expression], nil] end it "tokenizes the rule correctly" do s = 'maybe_superclasses : ":" superclasses |' l = Rly::RuleParser.lexer_class.new(s) l.next.type.should == :ID l.next.type.should == ':' l.next.type.should == :LITERAL l.next.type.should == :ID l.next.type.should == '|' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rly-0.2.3 | spec/parse/rule_parser_spec.rb |
rly-0.2.2 | spec/parse/rule_parser_spec.rb |