Sha256: 64325c9e2a724802880d6ea4563fd6ebc6f78afcdf264fe8816e297e850199a8
Contents?: true
Size: 606 Bytes
Versions: 4
Compression:
Stored size: 606 Bytes
Contents
module Sexpr module Matcher class Rule include Matcher attr_reader :name attr_reader :defn def initialize(name, defn) @name = name @defn = defn end def match?(sexp) return nil unless sexp.is_a?(Array) return false unless sexp.first && (sexp.first == name) defn.match?(sexp[1..-1]) end def eat(sexp) return nil unless match?(sexp.first) sexp[1..-1] end def inspect "(rule #{name}, #{defn.inspect})" end end # class Rule end # module Matcher end # module Sexpr
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
sexpr-0.5.1 | lib/sexpr/matcher/rule.rb |
sexpr-0.5.0 | lib/sexpr/matcher/rule.rb |
sexpr-0.4.0 | lib/sexpr/matcher/rule.rb |
sexpr-0.3.0 | lib/sexpr/matcher/rule.rb |