lib/hilbert/lexer/base.rb in hilbert-0.0.2700001 vs lib/hilbert/lexer/base.rb in hilbert-0.0.2700100
- old
+ new
@@ -12,9 +12,17 @@
def rule(pattern, &token)
token ||= proc { :NULL }
@token_rule_hash ||= {}
@token_rule_hash[pattern] = token.call
end
+
+ def clear!
+ @token_rule_hash = {}
+ end
+
+ def execute(str)
+ new(str).lexeds
+ end
end
def initialize(str)
ss = StringScanner.new(str)
@lexeds = []