mail 2.1.5.2 → 2.1.5.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mail might be problematic. Click here for more details.

Files changed (134) hide show
  1. data/CHANGELOG.rdoc +6 -0
  2. data/Rakefile +2 -1
  3. data/lib/mail.rb +0 -1
  4. data/lib/mail/elements.rb +0 -1
  5. data/lib/mail/utilities.rb +1 -1
  6. data/lib/mail/version.rb +1 -1
  7. data/lib/tasks/treetop.rake +4 -4
  8. metadata +17 -129
  9. data/lib/mail/vendor/treetop-1.4.4/History.txt +0 -18
  10. data/lib/mail/vendor/treetop-1.4.4/LICENSE +0 -19
  11. data/lib/mail/vendor/treetop-1.4.4/README.md +0 -164
  12. data/lib/mail/vendor/treetop-1.4.4/Rakefile +0 -28
  13. data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Preferences/Comments.tmPreferences +0 -22
  14. data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Snippets/grammar ___ end.tmSnippet +0 -20
  15. data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Snippets/rule ___ end.tmSnippet +0 -18
  16. data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/designable.nib +0 -1524
  17. data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/keyedobjects.nib +0 -0
  18. data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Support/syntax_tree_viewer.rb +0 -117
  19. data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Syntaxes/Treetop Grammar.tmLanguage +0 -278
  20. data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/info.plist +0 -10
  21. data/lib/mail/vendor/treetop-1.4.4/benchmark/seqpar.gnuplot +0 -15
  22. data/lib/mail/vendor/treetop-1.4.4/benchmark/seqpar.treetop +0 -16
  23. data/lib/mail/vendor/treetop-1.4.4/benchmark/seqpar_benchmark.rb +0 -107
  24. data/lib/mail/vendor/treetop-1.4.4/bin/tt +0 -112
  25. data/lib/mail/vendor/treetop-1.4.4/doc/contributing_and_planned_features.markdown +0 -103
  26. data/lib/mail/vendor/treetop-1.4.4/doc/grammar_composition.markdown +0 -65
  27. data/lib/mail/vendor/treetop-1.4.4/doc/index.markdown +0 -90
  28. data/lib/mail/vendor/treetop-1.4.4/doc/pitfalls_and_advanced_techniques.markdown +0 -51
  29. data/lib/mail/vendor/treetop-1.4.4/doc/semantic_interpretation.markdown +0 -189
  30. data/lib/mail/vendor/treetop-1.4.4/doc/site.rb +0 -112
  31. data/lib/mail/vendor/treetop-1.4.4/doc/sitegen.rb +0 -65
  32. data/lib/mail/vendor/treetop-1.4.4/doc/syntactic_recognition.markdown +0 -100
  33. data/lib/mail/vendor/treetop-1.4.4/doc/using_in_ruby.markdown +0 -28
  34. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/arithmetic.rb +0 -551
  35. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/arithmetic.treetop +0 -97
  36. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/arithmetic_node_classes.rb +0 -7
  37. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/arithmetic_test.rb +0 -54
  38. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus +0 -0
  39. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus.rb +0 -718
  40. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus.treetop +0 -132
  41. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus_node_classes.rb +0 -5
  42. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus_test.rb +0 -89
  43. data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/test_helper.rb +0 -18
  44. data/lib/mail/vendor/treetop-1.4.4/lib/treetop.rb +0 -3
  45. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/bootstrap_gen_1_metagrammar.rb +0 -42
  46. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler.rb +0 -7
  47. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/grammar_compiler.rb +0 -44
  48. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/lexical_address_space.rb +0 -17
  49. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/metagrammar.rb +0 -3366
  50. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/metagrammar.treetop +0 -436
  51. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes.rb +0 -19
  52. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/anything_symbol.rb +0 -18
  53. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/atomic_expression.rb +0 -14
  54. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/character_class.rb +0 -28
  55. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/choice.rb +0 -31
  56. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/declaration_sequence.rb +0 -24
  57. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/grammar.rb +0 -28
  58. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/inline_module.rb +0 -27
  59. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/nonterminal.rb +0 -13
  60. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/optional.rb +0 -19
  61. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/parenthesized_expression.rb +0 -9
  62. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/parsing_expression.rb +0 -146
  63. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/parsing_rule.rb +0 -58
  64. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/predicate.rb +0 -45
  65. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/predicate_block.rb +0 -16
  66. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/repetition.rb +0 -55
  67. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/sequence.rb +0 -71
  68. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/terminal.rb +0 -20
  69. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/transient_prefix.rb +0 -9
  70. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/treetop_file.rb +0 -9
  71. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/ruby_builder.rb +0 -113
  72. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/polyglot.rb +0 -9
  73. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/ruby_extensions.rb +0 -1
  74. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/ruby_extensions/string.rb +0 -42
  75. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime.rb +0 -6
  76. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/compiled_parser.rb +0 -110
  77. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/interval_skip_list.rb +0 -3
  78. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/interval_skip_list/head_node.rb +0 -15
  79. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +0 -200
  80. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/interval_skip_list/node.rb +0 -164
  81. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/syntax_node.rb +0 -114
  82. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/terminal_parse_failure.rb +0 -16
  83. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/terminal_syntax_node.rb +0 -17
  84. data/lib/mail/vendor/treetop-1.4.4/lib/treetop/version.rb +0 -9
  85. data/lib/mail/vendor/treetop-1.4.4/script/generate_metagrammar.rb +0 -13
  86. data/lib/mail/vendor/treetop-1.4.4/script/svnadd +0 -11
  87. data/lib/mail/vendor/treetop-1.4.4/script/svnrm +0 -11
  88. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/and_predicate_spec.rb +0 -36
  89. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/anything_symbol_spec.rb +0 -44
  90. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/character_class_spec.rb +0 -276
  91. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/choice_spec.rb +0 -80
  92. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/circular_compilation_spec.rb +0 -30
  93. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/failure_propagation_functional_spec.rb +0 -21
  94. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/grammar_compiler_spec.rb +0 -84
  95. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/grammar_spec.rb +0 -41
  96. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/multibyte_chars_spec.rb +0 -38
  97. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/nonterminal_symbol_spec.rb +0 -40
  98. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/not_predicate_spec.rb +0 -38
  99. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/one_or_more_spec.rb +0 -35
  100. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/optional_spec.rb +0 -37
  101. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/parenthesized_expression_spec.rb +0 -19
  102. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/parsing_rule_spec.rb +0 -61
  103. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/repeated_subrule_spec.rb +0 -29
  104. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/semantic_predicate_spec.rb +0 -175
  105. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/sequence_spec.rb +0 -115
  106. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/terminal_spec.rb +0 -81
  107. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/terminal_symbol_spec.rb +0 -37
  108. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/test_grammar.treetop +0 -7
  109. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/test_grammar.tt +0 -7
  110. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/test_grammar_do.treetop +0 -7
  111. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/tt_compiler_spec.rb +0 -216
  112. data/lib/mail/vendor/treetop-1.4.4/spec/compiler/zero_or_more_spec.rb +0 -56
  113. data/lib/mail/vendor/treetop-1.4.4/spec/composition/a.treetop +0 -11
  114. data/lib/mail/vendor/treetop-1.4.4/spec/composition/b.treetop +0 -11
  115. data/lib/mail/vendor/treetop-1.4.4/spec/composition/c.treetop +0 -10
  116. data/lib/mail/vendor/treetop-1.4.4/spec/composition/d.treetop +0 -10
  117. data/lib/mail/vendor/treetop-1.4.4/spec/composition/f.treetop +0 -17
  118. data/lib/mail/vendor/treetop-1.4.4/spec/composition/grammar_composition_spec.rb +0 -40
  119. data/lib/mail/vendor/treetop-1.4.4/spec/composition/subfolder/e_includes_c.treetop +0 -15
  120. data/lib/mail/vendor/treetop-1.4.4/spec/ruby_extensions/string_spec.rb +0 -32
  121. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/compiled_parser_spec.rb +0 -101
  122. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/delete_spec.rb +0 -147
  123. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/expire_range_spec.rb +0 -349
  124. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/insert_and_delete_node.rb +0 -385
  125. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/insert_spec.rb +0 -660
  126. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +0 -6175
  127. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +0 -58
  128. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/palindromic_fixture.rb +0 -23
  129. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +0 -163
  130. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/spec_helper.rb +0 -84
  131. data/lib/mail/vendor/treetop-1.4.4/spec/runtime/syntax_node_spec.rb +0 -77
  132. data/lib/mail/vendor/treetop-1.4.4/spec/spec_helper.rb +0 -110
  133. data/lib/mail/vendor/treetop-1.4.4/treetop.gemspec +0 -18
  134. data/lib/mail/vendor/treetop.rb +0 -2
@@ -1,16 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class PredicateBlock < ParsingExpression
4
- def compile(index, builder, parent_expression = nil)
5
- super
6
- # REVISIT: This is distinctly dodgey, but since we can only be called from
7
- # two contexts, and it works in both those, I'm going with it for now, as
8
- # opposed to doing the major refactor of providing a proper way of accessing
9
- # the parent's accumulator variable.
10
- p = parent
11
- p = p.parent while p && !p.respond_to?(:accumulator_var)
12
- assign_result "lambda #{text_value}.call(#{p ? p.accumulator_var : ""})"
13
- end
14
- end
15
- end
16
- end
@@ -1,55 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Repetition < ParsingExpression
4
- def compile(address, builder, parent_expression)
5
- super
6
- repeated_expression = parent_expression.atomic
7
- begin_comment(parent_expression)
8
- use_vars :result, :accumulator, :start_index
9
-
10
- builder.loop do
11
- obtain_new_subexpression_address
12
- repeated_expression.compile(subexpression_address, builder)
13
- builder.if__ subexpression_success? do
14
- accumulate_subexpression_result
15
- end
16
- builder.else_ do
17
- builder.break
18
- end
19
- end
20
- end
21
-
22
- def inline_module_name
23
- parent_expression.inline_module_name
24
- end
25
-
26
- def assign_and_extend_result
27
- assign_result "instantiate_node(#{node_class_name},input, #{start_index_var}...index, #{accumulator_var})"
28
- extend_result_with_inline_module
29
- end
30
- end
31
-
32
-
33
- class ZeroOrMore < Repetition
34
- def compile(address, builder, parent_expression)
35
- super
36
- assign_and_extend_result
37
- end_comment(parent_expression)
38
- end
39
- end
40
-
41
- class OneOrMore < Repetition
42
- def compile(address, builder, parent_expression)
43
- super
44
- builder.if__ "#{accumulator_var}.empty?" do
45
- reset_index
46
- assign_failure start_index_var
47
- end
48
- builder.else_ do
49
- assign_and_extend_result
50
- end
51
- end_comment(parent_expression)
52
- end
53
- end
54
- end
55
- end
@@ -1,71 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Sequence < ParsingExpression
4
- def compile(address, builder, parent_expression = nil)
5
- super
6
- begin_comment(self)
7
- use_vars :result, :start_index, :accumulator
8
- compile_sequence_elements(sequence_elements)
9
- builder.if__ "#{accumulator_var}.last" do
10
- assign_result "instantiate_node(#{node_class_name},input, #{start_index_var}...index, #{accumulator_var})"
11
- extend_result sequence_element_accessor_module_name if sequence_element_accessor_module_name
12
- extend_result_with_inline_module
13
- end
14
- builder.else_ do
15
- reset_index
16
- assign_failure start_index_var
17
- end
18
- end_comment(self)
19
- end
20
-
21
- def node_class_name
22
- node_class_declarations.node_class_name || 'SyntaxNode'
23
- end
24
-
25
- def compile_sequence_elements(elements)
26
- obtain_new_subexpression_address
27
- elements.first.compile(subexpression_address, builder)
28
- accumulate_subexpression_result
29
- if elements.size > 1
30
- builder.if_ subexpression_success? do
31
- compile_sequence_elements(elements[1..-1])
32
- end
33
- end
34
- end
35
-
36
- def sequence_element_accessor_module
37
- @sequence_element_accessor_module ||= SequenceElementAccessorModule.new(sequence_elements)
38
- end
39
-
40
- def sequence_element_accessor_module_name
41
- sequence_element_accessor_module.module_name
42
- end
43
- end
44
-
45
- class SequenceElementAccessorModule
46
- include InlineModuleMixin
47
- attr_reader :sequence_elements
48
-
49
- def initialize(sequence_elements)
50
- @sequence_elements = sequence_elements
51
- end
52
-
53
- def compile(index, builder, rule)
54
- super
55
- builder.module_declaration(module_name) do
56
- elements_by_name = sequence_elements.inject({}){|h,e| (h[e.label_name.to_s] ||= []) << e; h}
57
- sequence_elements.each_with_index do |element, index|
58
- if element.label_name
59
- repetitions = elements_by_name[element.label_name.to_s]
60
- label_name = element.label_name + (repetitions.size > 1 ? (repetitions.index(element)+1).to_s : "")
61
- builder.method_declaration(label_name) do
62
- builder << "elements[#{index}]"
63
- end
64
- builder.newline unless index == sequence_elements.size - 1
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,20 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Terminal < AtomicExpression
4
- def compile(address, builder, parent_expression = nil)
5
- super
6
- string_length = eval(text_value).length
7
-
8
- builder.if__ "has_terminal?(#{text_value}, false, index)" do
9
- assign_result "instantiate_node(#{node_class_name},input, index...(index + #{string_length}))"
10
- extend_result_with_inline_module
11
- builder << "@index += #{string_length}"
12
- end
13
- builder.else_ do
14
- builder << "terminal_parse_failure(#{text_value})"
15
- assign_result 'nil'
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,9 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class TransientPrefix < ParsingExpression
4
- def compile(address, builder, parent_expression)
5
- parent_expression.prefixed_expression.compile(address, builder)
6
- end
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class TreetopFile < Runtime::SyntaxNode
4
- def compile
5
- (elements.map {|elt| elt.compile}).join
6
- end
7
- end
8
- end
9
- end
@@ -1,113 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class RubyBuilder
4
-
5
- attr_reader :level, :address_space, :ruby
6
-
7
- def initialize
8
- @level = 0
9
- @address_space = LexicalAddressSpace.new
10
- @ruby = ""
11
- end
12
-
13
- def <<(ruby_line)
14
- return if ruby_line.blank?
15
- ruby << ruby_line.tabto(level) << "\n"
16
- end
17
-
18
- def newline
19
- ruby << "\n"
20
- end
21
-
22
- def indented(depth = 2)
23
- self.in(depth)
24
- yield
25
- self.out(depth)
26
- end
27
-
28
- def class_declaration(name, &block)
29
- self << "class #{name}"
30
- indented(&block)
31
- self << "end"
32
- end
33
-
34
- def module_declaration(name, &block)
35
- self << "module #{name}"
36
- indented(&block)
37
- self << "end"
38
- end
39
-
40
- def method_declaration(name, &block)
41
- self << "def #{name}"
42
- indented(&block)
43
- self << "end"
44
- end
45
-
46
- def assign(left, right)
47
- if left.instance_of? Array
48
- self << "#{left.join(', ')} = #{right.join(', ')}"
49
- else
50
- self << "#{left} = #{right}"
51
- end
52
- end
53
-
54
- def extend(var, module_name)
55
- self << "#{var}.extend(#{module_name})"
56
- end
57
-
58
- def accumulate(left, right)
59
- self << "#{left} << #{right}"
60
- end
61
-
62
- def if__(condition, &block)
63
- self << "if #{condition}"
64
- indented(&block)
65
- end
66
-
67
- def if_(condition, &block)
68
- if__(condition, &block)
69
- self << 'end'
70
- end
71
-
72
- def else_(&block)
73
- self << 'else'
74
- indented(&block)
75
- self << 'end'
76
- end
77
-
78
- def loop(&block)
79
- self << 'loop do'
80
- indented(&block)
81
- self << 'end'
82
- end
83
-
84
- def break
85
- self << 'break'
86
- end
87
-
88
- def in(depth = 2)
89
- @level += depth
90
- self
91
- end
92
-
93
- def out(depth = 2)
94
- @level -= depth
95
- self
96
- end
97
-
98
- def next_address
99
- address_space.next_address
100
- end
101
-
102
- def reset_addresses
103
- address_space.reset_addresses
104
- end
105
-
106
- private
107
-
108
- def indent
109
- " " * level
110
- end
111
- end
112
- end
113
- end
@@ -1,9 +0,0 @@
1
- module Treetop
2
- module Polyglot
3
- VALID_GRAMMAR_EXT = ['treetop', 'tt']
4
- VALID_GRAMMAR_EXT_REGEXP = /\.(#{VALID_GRAMMAR_EXT.join('|')})\Z/o
5
- end
6
- end
7
-
8
- require 'polyglot'
9
- Polyglot.register(Treetop::Polyglot::VALID_GRAMMAR_EXT, Treetop)
@@ -1 +0,0 @@
1
- require 'treetop/ruby_extensions/string'
@@ -1,42 +0,0 @@
1
- class String
2
- def column_of(index)
3
- return 1 if index == 0
4
- newline_index = rindex("\n", index - 1)
5
- if newline_index
6
- index - newline_index
7
- else
8
- index + 1
9
- end
10
- end
11
-
12
- def line_of(index)
13
- self[0...index].count("\n") + 1
14
- end
15
-
16
- unless method_defined?(:blank?)
17
- def blank?
18
- self == ""
19
- end
20
- end
21
-
22
- # The following methods are lifted from Facets 2.0.2
23
- def tabto(n)
24
- if self =~ /^( *)\S/
25
- indent(n - $1.length)
26
- else
27
- self
28
- end
29
- end
30
-
31
- def indent(n)
32
- if n >= 0
33
- gsub(/^/, ' ' * n)
34
- else
35
- gsub(/^ {0,#{-n}}/, "")
36
- end
37
- end
38
-
39
- def treetop_camelize
40
- to_s.gsub(/\/(.?)/){ "::" + $1.upcase }.gsub(/(^|_)(.)/){ $2.upcase }
41
- end
42
- end
@@ -1,6 +0,0 @@
1
- require 'treetop/ruby_extensions'
2
-
3
- require 'treetop/runtime/compiled_parser'
4
- require 'treetop/runtime/syntax_node'
5
- require 'treetop/runtime/terminal_parse_failure'
6
- require 'treetop/runtime/interval_skip_list'
@@ -1,110 +0,0 @@
1
- module Treetop
2
- module Runtime
3
- class CompiledParser
4
- include Treetop::Runtime
5
-
6
- attr_reader :input, :index, :max_terminal_failure_index
7
- attr_writer :root
8
- attr_accessor :consume_all_input
9
- alias :consume_all_input? :consume_all_input
10
-
11
- def initialize
12
- self.consume_all_input = true
13
- end
14
-
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
23
-
24
- def failure_index
25
- max_terminal_failure_index
26
- end
27
-
28
- def failure_line
29
- @terminal_failures && input.line_of(failure_index)
30
- end
31
-
32
- def failure_column
33
- @terminal_failures && input.column_of(failure_index)
34
- end
35
-
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
46
-
47
- def terminal_failures
48
- @terminal_failures.map! {|tf_ary| TerminalParseFailure.new(*tf_ary) }
49
- end
50
-
51
-
52
- protected
53
-
54
- attr_reader :node_cache, :input_length
55
- attr_writer :index
56
-
57
- def prepare_to_parse(input)
58
- @input = input
59
- @input_length = input.length
60
- reset_index
61
- @node_cache = Hash.new {|hash, key| hash[key] = Hash.new}
62
- @regexps = {}
63
- @terminal_failures = []
64
- @max_terminal_failure_index = 0
65
- end
66
-
67
- def reset_index
68
- @index = 0
69
- end
70
-
71
- def parse_anything(node_class = SyntaxNode, inline_module = nil)
72
- if index < input.length
73
- result = instantiate_node(node_class,input, index...(index + 1))
74
- result.extend(inline_module) if inline_module
75
- @index += 1
76
- result
77
- else
78
- terminal_parse_failure("any character")
79
- end
80
- end
81
-
82
- def instantiate_node(node_type,*args)
83
- if node_type.respond_to? :new
84
- node_type.new(*args)
85
- else
86
- SyntaxNode.new(*args).extend(node_type)
87
- end
88
- end
89
-
90
- def has_terminal?(terminal, regex, index)
91
- if regex
92
- rx = @regexps[terminal] ||= Regexp.new(terminal)
93
- input.index(rx, index) == index
94
- else
95
- input[index, terminal.size] == terminal
96
- end
97
- end
98
-
99
- def terminal_parse_failure(expected_string)
100
- return nil if index < max_terminal_failure_index
101
- if index > max_terminal_failure_index
102
- @max_terminal_failure_index = index
103
- @terminal_failures = []
104
- end
105
- @terminal_failures << [index, expected_string]
106
- return nil
107
- end
108
- end
109
- end
110
- end