Module: Treetop

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

Overview

:nodoc:

Defined Under Namespace

Modules: Compiler, Polyglot, Runtime, VERSION

Class Method Summary collapse

Class Method Details

.load(path) ⇒ Object

compile a treetop source file and load it



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/puppet_x/wildfly/gems/treetop-1.6.8/lib/treetop/compiler/grammar_compiler.rb', line 35

def self.load(path)
  unless path =~ Treetop::Polyglot::VALID_GRAMMAR_EXT_REGEXP
    ext = Treetop::Polyglot::VALID_GRAMMAR_EXT.select {|ext| File.exist?(path+".#{ext}")}.shift
    path += ".#{ext}" unless ext.nil?
  end
  File.open(path) do |source_file|
    source = source_file.read
    source.gsub!(/\b__FILE__\b/, %Q{"#{path}"})
    load_from_string(source)
  end
end

.load_from_string(s) ⇒ Object

compile a treetop source string and load it



48
49
50
51
# File 'lib/puppet_x/wildfly/gems/treetop-1.6.8/lib/treetop/compiler/grammar_compiler.rb', line 48

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