Class: Pegarus::Machine::Compiler
- Inherits:
-
Object
- Object
- Pegarus::Machine::Compiler
- Defined in:
- lib/pegarus/machine/compiler.rb
Instance Method Summary collapse
Instance Method Details
#compile(pattern) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/pegarus/machine/compiler.rb', line 4 def compile(pattern) program = [] pattern.instance_variable_set :@program, program class << pattern class_eval <<-eval def match(subject) Pegarus::Machine.execute @program, subject end eval end end |