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: www.cs.queensu.ca/~thurston/ragel/

Instance Method Summary collapse

Instance Method Details

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



29
30
31
32
33
34
35
36
# File 'lib/walrus/parser.rb', line 29

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

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



25
26
27
# File 'lib/walrus/parser.rb', line 25

def parse(string, options = {})
  @@grammar.parse(string, options)
end