Sha256: 118f432dff145da03548b8a99db6b6321f3205b57593543d1790908ce4e81113
Contents?: true
Size: 654 Bytes
Versions: 3
Compression:
Stored size: 654 Bytes
Contents
module Sexpr module Matcher class Terminal include Matcher attr_reader :value def initialize(value) @value = value end def inspect "(terminal #{value.inspect})" end def match?(sexp) terminal_match?(sexp) end def eat(sexp) match?(sexp.first) ? sexp[1..-1] : nil end private def terminal_match?(term) case @value when Regexp @value === term rescue false when TrueClass, FalseClass, NilClass @value == term end end end # class Terminal end # module Matcher end # module Sexpr
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sexpr-0.5.0 | lib/sexpr/matcher/terminal.rb |
sexpr-0.4.0 | lib/sexpr/matcher/terminal.rb |
sexpr-0.3.0 | lib/sexpr/matcher/terminal.rb |