Class: Treetop::Runtime::CompiledParser
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of CompiledParser.
11
12
13
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 11
def initialize
self.consume_all_input = true
end
|
Instance Attribute Details
Returns the value of attribute consume_all_input.
8
9
10
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 8
def consume_all_input
@consume_all_input
end
|
Returns the value of attribute index.
6
7
8
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 6
def index
@index
end
|
Returns the value of attribute input.
6
7
8
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 6
def input
@input
end
|
#max_terminal_failure_index ⇒ Object
Returns the value of attribute max_terminal_failure_index.
6
7
8
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 6
def max_terminal_failure_index
@max_terminal_failure_index
end
|
#root=(value) ⇒ Object
7
8
9
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 7
def root=(value)
@root = value
end
|
Instance Method Details
#failure_column ⇒ Object
31
32
33
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 31
def failure_column
@terminal_failures && input.column_of(failure_index)
end
|
#failure_index ⇒ Object
23
24
25
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 23
def failure_index
max_terminal_failure_index
end
|
#failure_line ⇒ Object
27
28
29
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 27
def failure_line
@terminal_failures && input.line_of(failure_index)
end
|
#failure_message ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/less.rb', line 37
def failure_message
return nil unless (tf = terminal_failures) && tf.size > 0
"on line #{failure_line}: expected " + (
tf.size == 1 ?
tf[0].expected_string :
"one of #{tf.map {|f| f.expected_string }.uniq * ' '}"
) +
" got `#{input[failure_index]}`" +
" after:\n\n#{input[index...failure_index]}\n"
end
|
#failure_reason ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 35
def failure_reason
return nil unless (tf = terminal_failures) && tf.size > 0
"Expected " +
(tf.size == 1 ?
tf[0].expected_string :
"one of #{tf.map{|f| f.expected_string}.uniq*', '}"
) +
" at line #{failure_line}, column #{failure_column} (byte #{failure_index+1})" +
" after #{input[index...failure_index]}"
end
|
#parse(input, options = {}) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 15
def parse(input, options = {})
prepare_to_parse(input)
@index = options[:index] if options[:index]
result = send("_nt_#{root}")
return nil if (consume_all_input? && index != input.size)
return result
end
|
#terminal_failures ⇒ Object
46
47
48
|
# File 'lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb', line 46
def terminal_failures
@terminal_failures.map! {|tf_ary| TerminalParseFailure.new(*tf_ary) }
end
|