Class: Pegarus::Rubinius::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/pegarus/rubinius/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompiler

Returns a new instance of Compiler.



11
12
13
# File 'lib/pegarus/rubinius/compiler.rb', line 11

def initialize
  @g = Generator.new
end

Instance Attribute Details

#gObject (readonly)

Returns the value of attribute g.



9
10
11
# File 'lib/pegarus/rubinius/compiler.rb', line 9

def g
  @g
end

Instance Method Details

#always(pattern) ⇒ Object



46
47
48
# File 'lib/pegarus/rubinius/compiler.rb', line 46

def always(pattern)
  failure
end

#any(pattern) ⇒ Object



50
51
52
# File 'lib/pegarus/rubinius/compiler.rb', line 50

def any(pattern)
  failure
end

#any_range(pattern) ⇒ Object



54
55
56
# File 'lib/pegarus/rubinius/compiler.rb', line 54

def any_range(pattern)
  failure
end

#character(pattern) ⇒ Object



58
59
60
# File 'lib/pegarus/rubinius/compiler.rb', line 58

def character(pattern)
  failure
end

#character_range(pattern) ⇒ Object



62
63
64
# File 'lib/pegarus/rubinius/compiler.rb', line 62

def character_range(pattern)
  failure
end

#choice(pattern) ⇒ Object



66
67
68
# File 'lib/pegarus/rubinius/compiler.rb', line 66

def choice(pattern)
  failure
end

#compile(pattern) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pegarus/rubinius/compiler.rb', line 15

def compile(pattern)
  g.name = :match
  g.file = :"(pegarus)"
  g.set_line 1

  g.required_args = 1
  g.total_args = 1
  g.splat_index = nil

  g.local_count = 2
  g.local_names = [:subject, :index]

  g.push 0
  g.set_index

  pattern.visit self
  g.finish

  g.encode
  cm = g.package ::Rubinius::CompiledMethod
  puts cm.decode if $DEBUG

  ss = ::Rubinius::StaticScope.new Object
  ::Rubinius.attach_method :match, cm, ss, pattern
end

#concatenation(pattern) ⇒ Object



70
71
72
# File 'lib/pegarus/rubinius/compiler.rb', line 70

def concatenation(pattern)
  failure
end

#difference(pattern) ⇒ Object



74
75
76
# File 'lib/pegarus/rubinius/compiler.rb', line 74

def difference(pattern)
  failure
end

#failureObject



41
42
43
44
# File 'lib/pegarus/rubinius/compiler.rb', line 41

def failure
  g.push :nil
  g.goto g.fail
end

#if(pattern) ⇒ Object



78
79
80
# File 'lib/pegarus/rubinius/compiler.rb', line 78

def if(pattern)
  failure
end

#never(pattern) ⇒ Object



82
83
84
# File 'lib/pegarus/rubinius/compiler.rb', line 82

def never(pattern)
  failure
end

#set(pattern) ⇒ Object



86
87
88
# File 'lib/pegarus/rubinius/compiler.rb', line 86

def set(pattern)
  failure
end

#unless(pattern) ⇒ Object



90
91
92
# File 'lib/pegarus/rubinius/compiler.rb', line 90

def unless(pattern)
  failure
end