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,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- BENCHMARK = false
4
- METAGRAMMAR_PATH = File.expand_path('../../../lib/treetop/compiler/metagrammar.treetop', __FILE__)
5
-
6
- module CircularCompilationSpec
7
- describe "a parser for the metagrammar" do
8
- attr_reader :parser
9
-
10
- before do
11
- @parser = Treetop::Compiler::MetagrammarParser.new
12
- end
13
-
14
- it "can parse the metagrammar.treetop whence it was generated" do
15
- File.open(METAGRAMMAR_PATH, 'r') do |f|
16
- metagrammar_source = f.read
17
- result = parser.parse(metagrammar_source)
18
- result.should_not be_nil
19
-
20
- # generated_parser = result.compile
21
- # Object.class_eval(generated_parser)
22
- # parser_2 = Treetop::Compiler::MetagrammarParser.new
23
- # optionally_benchmark do
24
- # result = parser_2.parse(metagrammar_source)
25
- # result.should_not be_nil
26
- # end
27
- end
28
- end
29
- end
30
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "An expression for braces surrounding zero or more letters followed by semicolons" do
4
- testing_expression "'{' ([a-z] ';')* '}'"
5
-
6
- it "parses matching input successfully" do
7
- parse('{a;b;c;}').should_not be_nil
8
- end
9
-
10
- it "fails to parse input with an expression that is missing a semicolon, reporting the terminal failure occurring at the maximum index" do
11
- parse('{a;b;c}') do |result|
12
- result.should be_nil
13
-
14
- terminal_failures = parser.terminal_failures
15
- terminal_failures.size.should == 1
16
- failure = terminal_failures[0]
17
- failure.index.should == 6
18
- failure.expected_string.should == ';'
19
- end
20
- end
21
- end
@@ -1,84 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Compiler::GrammarCompiler do
4
- attr_reader :compiler, :source_path_with_treetop_extension, :source_path_with_tt_extension, :target_path, :alternate_target_path
5
- before do
6
- @compiler = Compiler::GrammarCompiler.new
7
-
8
- dir = File.dirname(__FILE__)
9
- @source_path_with_treetop_extension = "#{dir}/test_grammar.treetop"
10
- @source_path_with_do = "#{dir}/test_grammar_do.treetop"
11
- @source_path_with_tt_extension = "#{dir}/test_grammar.tt"
12
- @target_path = "#{dir}/test_grammar.rb"
13
- @target_path_with_do = "#{dir}/test_grammar_do.rb"
14
- @alternate_target_path = "#{dir}/test_grammar_alt.rb"
15
- delete_target_files
16
- end
17
-
18
- after do
19
- delete_target_files
20
- Object.class_eval do
21
- remove_const(:Test) if const_defined?(:Test)
22
- end
23
- end
24
-
25
- specify "compilation of a single file to a default file name" do
26
- File.exists?(target_path).should be_false
27
- compiler.compile(source_path_with_treetop_extension)
28
- File.exists?(target_path).should be_true
29
- require target_path
30
- Test::GrammarParser.new.parse('foo').should_not be_nil
31
- end
32
-
33
- specify "compilation of a single file to an explicit file name" do
34
- File.exists?(alternate_target_path).should be_false
35
- compiler.compile(source_path_with_treetop_extension, alternate_target_path)
36
- File.exists?(alternate_target_path).should be_true
37
- require alternate_target_path
38
- Test::GrammarParser.new.parse('foo').should_not be_nil
39
- end
40
-
41
- specify "compilation of a single file without writing it to an output file" do
42
- compiler.ruby_source(source_path_with_treetop_extension).should_not be_nil
43
- end
44
-
45
- specify "ruby_source_from_string compiles a grammar stored in string" do
46
- compiler.ruby_source_from_string(File.read(source_path_with_treetop_extension)).should_not be_nil
47
- end
48
-
49
- specify "Treetop.load_from_string compiles and evaluates a source grammar stored in string" do
50
- Treetop.load_from_string File.read(source_path_with_treetop_extension)
51
- Test::GrammarParser.new.parse('foo').should_not be_nil
52
- end
53
-
54
- specify "Treetop.load compiles and evaluates a source grammar with a .treetop extension" do
55
- Treetop.load source_path_with_treetop_extension
56
- Test::GrammarParser.new.parse('foo').should_not be_nil
57
- end
58
-
59
- specify "Treetop.load compiles and evaluates a source grammar with a .tt extension" do
60
- path_without_extension = source_path_with_tt_extension
61
- Treetop.load path_without_extension
62
- Test::GrammarParser.new.parse('foo').should_not be_nil
63
- end
64
-
65
-
66
- specify "Treetop.load compiles and evaluates source grammar with no extension" do
67
- path_without_extension = source_path_with_treetop_extension.gsub(/\.treetop\Z/, '')
68
- Treetop.load path_without_extension
69
- Test::GrammarParser.new.parse('foo').should_not be_nil
70
- end
71
-
72
- specify "grammars with 'do' compile" do
73
- compiler.compile(@source_path_with_do)
74
- require @target_path_with_do
75
- Test::GrammarParser.new.parse('foo').should_not be_nil
76
- end
77
-
78
- def delete_target_files
79
- File.delete(target_path) if File.exists?(target_path)
80
- File.delete(@target_path_with_do) if File.exists?(@target_path_with_do)
81
- File.delete(alternate_target_path) if File.exists?(alternate_target_path)
82
- end
83
- end
84
-
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module GrammarSpec
4
- module Bar
5
- end
6
-
7
- describe "a grammar" do
8
- testing_grammar %{
9
- grammar Foo
10
- # This comment should not cause a syntax error, nor should the following empty one
11
- #
12
- include GrammarSpec::Bar
13
-
14
- rule foo
15
- bar / baz
16
- end
17
-
18
- rule bar
19
- 'bar' 'bar'
20
- end
21
-
22
- rule baz
23
- 'baz' 'baz'
24
- end
25
- end
26
- }
27
-
28
- it "parses matching input" do
29
- parse('barbar').should_not be_nil
30
- parse('bazbaz').should_not be_nil
31
- end
32
-
33
- it "fails if it does not parse all input" do
34
- parse('barbarbazbaz').should be_nil
35
- end
36
-
37
- it "mixes in included modules" do
38
- self.class.const_get(:Foo).ancestors.should include(GrammarSpec::Bar)
39
- end
40
- end
41
- end
@@ -1,38 +0,0 @@
1
- #!ruby19
2
- # encoding: utf-8
3
-
4
- require 'spec_helper'
5
-
6
- module MultibyteCharsSpec
7
- describe "an anything symbol" do
8
- testing_expression '.'
9
- it "matches an UTF-8 character" do
10
- parse_multibyte("ø").should_not be_nil
11
- end
12
- end
13
-
14
- describe "A character class containing UTF-8 characters" do
15
- testing_expression "[æøå]"
16
- it "recognizes the UTF-8 characters" do
17
- parse_multibyte("ø").should_not be_nil
18
- end
19
- end
20
-
21
- describe "a character class repetition containing UTF-8 characters mixed with other expressions" do
22
- testing_expression '[æøå]+ "a"'
23
- it "lazily instantiates a node for the character" do
24
- result = parse_multibyte('æøåa')
25
- pending "Multibyte support is not supported in Ruby 1.8.6" if RUBY_VERSION =~ /^1\.8.6/
26
- result.elements[0].instance_variable_get("@elements").should include(true)
27
- result.elements[0].elements.should_not include(true)
28
- result.elements[0].elements.size.should == 3
29
- result.elements.size.should == 2
30
- result.elements[0].text_value.should == "æøå"
31
- result.elements[0].elements[0].text_value.should == "æ"
32
- result.elements[0].elements[1].text_value.should == "ø"
33
- result.elements[0].elements[2].text_value.should == "å"
34
- result.elements[1].text_value == "a"
35
- end
36
- end
37
-
38
- end
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module NonterminalSymbolSpec
4
- describe "A nonterminal symbol followed by a block" do
5
- testing_expression 'foo { def a_method; end }'
6
-
7
- parser_class_under_test.class_eval do
8
- def _nt_foo
9
- '_nt_foo called'
10
- end
11
- end
12
-
13
- it "compiles to a method call, extending its results with the anonymous module for the block" do
14
- result = parse('')
15
- result.should == '_nt_foo called'
16
- result.should respond_to(:a_method)
17
- end
18
- end
19
-
20
- module TestModule
21
- def a_method
22
- end
23
- end
24
-
25
- describe "a non-terminal followed by a module declaration" do
26
- testing_expression 'foo <NonterminalSymbolSpec::TestModule>'
27
-
28
- parser_class_under_test.class_eval do
29
- def _nt_foo
30
- '_nt_foo called'
31
- end
32
- end
33
-
34
- it "compiles to a method call, extending its results with the anonymous module for the block" do
35
- result = parse('')
36
- result.should == '_nt_foo called'
37
- result.should respond_to(:a_method)
38
- end
39
- end
40
- end
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module NotPredicateSpec
4
- describe "A !-predicated terminal symbol" do
5
- testing_expression '!"foo"'
6
-
7
- it "fails to parse input matching the terminal symbol" do
8
- parse('foo').should be_nil
9
- end
10
- end
11
-
12
- describe "A sequence of a terminal and an and another !-predicated terminal" do
13
- testing_expression '"foo" !"bar"'
14
-
15
- it "fails to match input matching both terminals" do
16
- parse('foobar').should be_nil
17
- end
18
-
19
- it "successfully parses input matching the first terminal and not the second, reporting the parse failure of the second terminal" do
20
- parse('foo') do |result|
21
- result.should_not be_nil
22
- terminal_failures = parser.terminal_failures
23
- terminal_failures.size.should == 1
24
- failure = terminal_failures.first
25
- failure.index.should == 3
26
- failure.expected_string.should == 'bar'
27
- end
28
- end
29
- end
30
-
31
- describe "A !-predicated sequence" do
32
- testing_expression '!("a" "b" "c")'
33
-
34
- it "fails to parse matching input" do
35
- parse('abc').should be_nil
36
- end
37
- end
38
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module OneOrMoreSpec
4
- class Foo < Treetop::Runtime::SyntaxNode
5
- end
6
-
7
- describe "one or more of a terminal symbol followed by a node class declaration and a block" do
8
- testing_expression '"foo"+ <OneOrMoreSpec::Foo> { def a_method; end }'
9
-
10
- it "fails to parse epsilon, reporting a failure" do
11
- parse('') do |result|
12
- result.should be_nil
13
- terminal_failures = parser.terminal_failures
14
- terminal_failures.size.should == 1
15
- failure = terminal_failures.first
16
- failure.index.should == 0
17
- failure.expected_string.should == 'foo'
18
- end
19
- end
20
-
21
- it "successfully parses two of that terminal in a row, returning an instance of the declared node class and reporting the failure the third parsing attempt" do
22
- parse("foofoo") do |result|
23
- result.should_not be_nil
24
- result.should be_an_instance_of(Foo)
25
- result.should respond_to(:a_method)
26
-
27
- terminal_failures = parser.terminal_failures
28
- terminal_failures.size.should == 1
29
- failure = terminal_failures.first
30
- failure.index.should == 6
31
- failure.expected_string.should == 'foo'
32
- end
33
- end
34
- end
35
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module OptionalSpec
4
- describe "An optional terminal symbol" do
5
- testing_expression '"foo"?'
6
-
7
- it "parses input matching the terminal" do
8
- parse('foo').should_not be_nil
9
- end
10
-
11
- it "parses epsilon, recording a failure" do
12
- parse('') do |result|
13
- result.should_not be_nil
14
- result.interval.should == (0...0)
15
-
16
- terminal_failures = parser.terminal_failures
17
- terminal_failures.size.should == 1
18
- failure = terminal_failures.first
19
- failure.index.should == 0
20
- failure.expected_string.should == 'foo'
21
- end
22
- end
23
-
24
- it "parses input not matching the terminal, returning an epsilon result and recording a failure" do
25
- parse('bar', :consume_all_input => false) do |result|
26
- result.should_not be_nil
27
- result.interval.should == (0...0)
28
-
29
- terminal_failures = parser.terminal_failures
30
- terminal_failures.size.should == 1
31
- failure = terminal_failures.first
32
- failure.index.should == 0
33
- failure.expected_string.should == 'foo'
34
- end
35
- end
36
- end
37
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module ParenthesizedExpressionSpec
4
- describe "An unadorned expression inside of parentheses" do
5
- testing_expression '("foo")'
6
-
7
- it "should behave as normal" do
8
- parse('foo').should_not be_nil
9
- end
10
- end
11
-
12
- describe "A prefixed-expression inside of parentheses" do
13
- testing_expression '(!"foo")'
14
-
15
- it "should behave as normal" do
16
- parse('foo').should be_nil
17
- end
18
- end
19
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module ParsingRuleSpec
4
- describe "a grammar with one parsing rule" do
5
-
6
- testing_grammar %{
7
- grammar Foo
8
- rule bar
9
- "baz"
10
- end
11
- end
12
- }
13
-
14
- it "stores and retrieves nodes in its node cache" do
15
- parser = self.class.const_get(:FooParser).new
16
- parser.send(:prepare_to_parse, 'baz')
17
- node_cache = parser.send(:node_cache)
18
-
19
- node_cache[:bar][0].should be_nil
20
-
21
- parser._nt_bar
22
-
23
- cached_node = node_cache[:bar][0]
24
- cached_node.should be_an_instance_of(Runtime::SyntaxNode)
25
- cached_node.text_value.should == 'baz'
26
-
27
- parser.instance_eval { @index = 0 }
28
- parser._nt_bar.should equal(cached_node)
29
- parser.index.should == cached_node.interval.end
30
- end
31
- end
32
-
33
-
34
- describe "a grammar with choice that uses the cache and has a subsequent expression" do
35
- testing_grammar %{
36
- grammar Logic
37
- rule expression
38
- value_plus
39
- /
40
- value
41
- end
42
-
43
- rule value_plus
44
- value "something else"
45
- end
46
-
47
- rule value
48
- [a-z]
49
- /
50
- "foobar" # the subsequent expression that needs cached.interval.end
51
- end
52
- end
53
- }
54
-
55
- it "parses a single-character value and generates a node from the cache" do
56
- result = parse('a')
57
- result.should be_a(Treetop::Runtime::SyntaxNode)
58
- result.elements.should be_nil
59
- end
60
- end
61
- end