Class: Walrus::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/walrus/parser.rb

Overview

The parser is currently quite slow, although perfectly usable. The quickest route to optimizing it may be to replace it with a C parser inside a Ruby extension, possibly generated using Ragel

Instance Method Summary collapse

Instance Method Details

#compile(string, options = {}) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/walrus/parser.rb', line 35

def compile string, options = {}
  @@compiler ||= Compiler.new
  parsed = []
  catch :AndPredicateSuccess do # catch here because empty files throw
    parsed = parse string, options
  end
  @@compiler.compile parsed, options
end

#parse(string, options = {}) ⇒ Object



31
32
33
# File 'lib/walrus/parser.rb', line 31

def parse string, options = {}
  Grammar.new.parse string, options
end