Module: Treetop

Defined in:
lib/gems/treetop-1.2.4/lib/treetop/runtime/syntax_node.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/metagrammar.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/ruby_builder.rb,
lib/gems/treetop-1.2.4/lib/treetop/runtime/compiled_parser.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/grammar_compiler.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/choice.rb,
lib/gems/treetop-1.2.4/lib/treetop/runtime/terminal_syntax_node.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/grammar.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/lexical_address_space.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/optional.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/sequence.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/terminal.rb,
lib/gems/treetop-1.2.4/lib/treetop/runtime/terminal_parse_failure.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/predicate.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/repetition.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/nonterminal.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/parsing_rule.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/treetop_file.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/inline_module.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/anything_symbol.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/character_class.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/transient_prefix.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/atomic_expression.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/parsing_expression.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/declaration_sequence.rb,
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/parenthesized_expression.rb

Defined Under Namespace

Modules: Compiler, Runtime

Class Method Summary collapse

Class Method Details

.load(path) ⇒ Object

compile a treetop source file and load it



28
29
30
31
32
33
# File 'lib/gems/treetop-1.2.4/lib/treetop/compiler/grammar_compiler.rb', line 28

def self.load(path)
  adjusted_path = path =~ /\.(treetop|tt)\Z/ ? path : path + '.treetop'
  File.open(adjusted_path) do |source_file|
    load_from_string(source_file.read)
  end
end

.load_from_string(s) ⇒ Object

compile a treetop source string and load it



36
37
38
39
# File 'lib/gems/treetop-1.2.4/lib/treetop/compiler/grammar_compiler.rb', line 36

def self.load_from_string(s)
  compiler = Treetop::Compiler::GrammarCompiler.new
  Object.class_eval(compiler.ruby_source_from_string(s))
end