Object
# File lib/treetop/runtime/compiled_parser.rb, line 32 32: def failure_column 33: @terminal_failures && input.column_of(failure_index) 34: end
# File lib/treetop/runtime/compiled_parser.rb, line 24 24: def failure_index 25: max_terminal_failure_index 26: end
# File lib/treetop/runtime/compiled_parser.rb, line 28 28: def failure_line 29: @terminal_failures && input.line_of(failure_index) 30: end
# File lib/treetop/runtime/compiled_parser.rb, line 36 36: def failure_reason 37: return nil unless (tf = terminal_failures) && tf.size > 0 38: "Expected " + 39: (tf.size == 1 ? 40: tf[0].expected_string : 41: "one of #{tf.map{|f| f.expected_string}.uniq*', '}" 42: ) + 43: " at line #{failure_line}, column #{failure_column} (byte #{failure_index+1})" + 44: " after #{input[index...failure_index]}" 45: end
# File lib/treetop/runtime/compiled_parser.rb, line 15 15: def parse(input, options = {}) 16: prepare_to_parse(input) 17: @index = options[:index] if options[:index] 18: result = send("_nt_#{root}") 19: return nil if (consume_all_input? && index != input.size) 20: return SyntaxNode.new(input, index...(index + 1)) if result == true 21: return result 22: end
# File lib/treetop/runtime/compiled_parser.rb, line 47 47: def terminal_failures 48: if @terminal_failures.empty? || @terminal_failures[0].is_a?(TerminalParseFailure) 49: @terminal_failures 50: else 51: @terminal_failures.map! {|tf_ary| TerminalParseFailure.new(*tf_ary) } 52: end 53: end
# File lib/treetop/runtime/compiled_parser.rb, line 94 94: def has_terminal?(terminal, regex, index) 95: if regex 96: rx = @regexps[terminal] ||= Regexp.new(terminal) 97: input.index(rx, index) == index 98: else 99: input[index, terminal.size] == terminal 100: end 101: end
# File lib/treetop/runtime/compiled_parser.rb, line 86 86: def instantiate_node(node_type,*args) 87: if node_type.respond_to? :new 88: node_type.new(*args) 89: else 90: SyntaxNode.new(*args).extend(node_type) 91: end 92: end
# File lib/treetop/runtime/compiled_parser.rb, line 75 75: def parse_anything(node_class = SyntaxNode, inline_module = nil) 76: if index < input.length 77: result = instantiate_node(node_class,input, index...(index + 1)) 78: result.extend(inline_module) if inline_module 79: @index += 1 80: result 81: else 82: terminal_parse_failure("any character") 83: end 84: end
# File lib/treetop/runtime/compiled_parser.rb, line 61 61: def prepare_to_parse(input) 62: @input = input 63: @input_length = input.length 64: reset_index 65: @node_cache = Hash.new {|hash, key| hash[key] = Hash.new} 66: @regexps = {} 67: @terminal_failures = [] 68: @max_terminal_failure_index = 0 69: end
# File lib/treetop/runtime/compiled_parser.rb, line 71 71: def reset_index 72: @index = 0 73: end
# File lib/treetop/runtime/compiled_parser.rb, line 103 103: def terminal_parse_failure(expected_string) 104: return nil if index < max_terminal_failure_index 105: if index > max_terminal_failure_index 106: @max_terminal_failure_index = index 107: @terminal_failures = [] 108: end 109: @terminal_failures << [index, expected_string] 110: return nil 111: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.