module Rattler::HelperMethods
Convenience methods for defining parsers
Public Instance Methods
compile(mod, grammar_or_parser, opts={})
click to toggle source
(see Rattler::Compiler::ModuleMethods#compile
)
# File lib/rattler.rb, line 44 def compile(mod, grammar_or_parser, opts={}) Rattler::Compiler.compile(mod, grammar_or_parser, opts) end
compile_parser(*args)
click to toggle source
Define a parser with the given grammar and compile it into a parser class using the given options
@return [Class] a new parser class
# File lib/rattler.rb, line 29 def compile_parser(*args) options = @@defaults.dup grammar = nil for arg in args case arg when Hash then options.merge!(arg) when String then grammar = arg end end base_class = options.delete(:class) || (Rattler::Runtime::const_get @@parser_types[options[:type]]) Rattler::Compiler.compile_parser(base_class, grammar, options) end