Module: Rattler::Compiler::ModuleMethods
Overview
Compiler module methods
Instance Method Summary collapse
-
#compile(mod, grammar_or_parser, opts = {}) ⇒ Object
Compile grammar source or a parser model into match methods in a module.
-
#compile_parser(base, grammar_or_parser, opts = {}) ⇒ Object
Compile grammar source or a parser model into a new parser subclass of
base
.
Instance Method Details
#compile(mod, grammar, opts) ⇒ Module #compile(mod, parser, opts) ⇒ Module
Compile grammar source or a parser model into match methods in a module.
51 52 53 54 55 |
# File 'lib/rattler/compiler.rb', line 51 def compile(mod, grammar_or_parser, opts={}) model = parser_model(grammar_or_parser) mod.module_eval ParserGenerator.code_for(model, opts) mod end |
#compile(base, grammar, opts) ⇒ Class #compile(base, parser, opts) ⇒ Class
Compile grammar source or a parser model into a new parser subclass of base
.
33 34 35 |
# File 'lib/rattler/compiler.rb', line 33 def compile_parser(base, grammar_or_parser, opts={}) compile(Class.new(base), grammar_or_parser, opts) end |