class RegularExpression::Pattern
Attributes
bytecode[R]
Public Class Methods
new(source)
click to toggle source
# File lib/regular_expression/pattern.rb, line 7 def initialize(source) ast = Parser.new.parse(source) @bytecode = Bytecode.compile(ast.to_nfa) end
Public Instance Methods
compile(compiler: Generator::X86)
click to toggle source
# File lib/regular_expression/pattern.rb, line 12 def compile(compiler: Generator::X86) cfg = CFG.build(bytecode) singleton_class.undef_method(:match?) define_singleton_method(:match?, &compiler.compile(cfg)) end
match?(string)
click to toggle source
# File lib/regular_expression/pattern.rb, line 19 def match?(string) Interpreter.new(bytecode).match?(string) end