Class: Pegarus::Machine::Compiler

Inherits:
Object
  • Object
show all
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 "def match(subject)\nPegarus::Machine.execute @program, subject\nend\n"
  end
end