cloudhead-less 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. data/Rakefile +2 -0
  2. data/VERSION +1 -1
  3. data/bin/lessc +8 -2
  4. data/less.gemspec +8 -92
  5. data/lib/ext.rb +8 -7
  6. data/lib/less/command.rb +12 -15
  7. data/lib/less/engine/grammar/less.tt +7 -3
  8. data/lib/less/engine.rb +3 -2
  9. data/lib/less.rb +2 -2
  10. data/spec/css/css-3.css +1 -0
  11. data/spec/less/css-3.less +4 -0
  12. data/spec/less/import.less +1 -0
  13. metadata +23 -94
  14. data/lib/vendor/treetop/.gitignore +0 -7
  15. data/lib/vendor/treetop/LICENSE +0 -19
  16. data/lib/vendor/treetop/README +0 -164
  17. data/lib/vendor/treetop/Rakefile +0 -19
  18. data/lib/vendor/treetop/benchmark/seqpar.gnuplot +0 -15
  19. data/lib/vendor/treetop/benchmark/seqpar.treetop +0 -16
  20. data/lib/vendor/treetop/benchmark/seqpar_benchmark.rb +0 -107
  21. data/lib/vendor/treetop/bin/tt +0 -28
  22. data/lib/vendor/treetop/lib/treetop/bootstrap_gen_1_metagrammar.rb +0 -45
  23. data/lib/vendor/treetop/lib/treetop/compiler/grammar_compiler.rb +0 -42
  24. data/lib/vendor/treetop/lib/treetop/compiler/lexical_address_space.rb +0 -17
  25. data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.rb +0 -3097
  26. data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.treetop +0 -408
  27. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/anything_symbol.rb +0 -18
  28. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/atomic_expression.rb +0 -14
  29. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/character_class.rb +0 -24
  30. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/choice.rb +0 -31
  31. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/declaration_sequence.rb +0 -24
  32. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/grammar.rb +0 -28
  33. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/inline_module.rb +0 -27
  34. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/nonterminal.rb +0 -13
  35. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/optional.rb +0 -19
  36. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parenthesized_expression.rb +0 -9
  37. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_expression.rb +0 -138
  38. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_rule.rb +0 -55
  39. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/predicate.rb +0 -45
  40. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/repetition.rb +0 -55
  41. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/sequence.rb +0 -68
  42. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/terminal.rb +0 -20
  43. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/transient_prefix.rb +0 -9
  44. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/treetop_file.rb +0 -9
  45. data/lib/vendor/treetop/lib/treetop/compiler/node_classes.rb +0 -19
  46. data/lib/vendor/treetop/lib/treetop/compiler/ruby_builder.rb +0 -113
  47. data/lib/vendor/treetop/lib/treetop/compiler.rb +0 -6
  48. data/lib/vendor/treetop/lib/treetop/ruby_extensions/string.rb +0 -42
  49. data/lib/vendor/treetop/lib/treetop/ruby_extensions.rb +0 -2
  50. data/lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb +0 -105
  51. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/head_node.rb +0 -15
  52. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +0 -200
  53. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/node.rb +0 -164
  54. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list.rb +0 -4
  55. data/lib/vendor/treetop/lib/treetop/runtime/syntax_node.rb +0 -72
  56. data/lib/vendor/treetop/lib/treetop/runtime/terminal_parse_failure.rb +0 -16
  57. data/lib/vendor/treetop/lib/treetop/runtime/terminal_syntax_node.rb +0 -17
  58. data/lib/vendor/treetop/lib/treetop/runtime.rb +0 -5
  59. data/lib/vendor/treetop/lib/treetop/version.rb +0 -9
  60. data/lib/vendor/treetop/lib/treetop.rb +0 -8
  61. data/lib/vendor/treetop/spec/compiler/and_predicate_spec.rb +0 -36
  62. data/lib/vendor/treetop/spec/compiler/anything_symbol_spec.rb +0 -44
  63. data/lib/vendor/treetop/spec/compiler/character_class_spec.rb +0 -182
  64. data/lib/vendor/treetop/spec/compiler/choice_spec.rb +0 -80
  65. data/lib/vendor/treetop/spec/compiler/circular_compilation_spec.rb +0 -28
  66. data/lib/vendor/treetop/spec/compiler/failure_propagation_functional_spec.rb +0 -21
  67. data/lib/vendor/treetop/spec/compiler/grammar_compiler_spec.rb +0 -84
  68. data/lib/vendor/treetop/spec/compiler/grammar_spec.rb +0 -41
  69. data/lib/vendor/treetop/spec/compiler/nonterminal_symbol_spec.rb +0 -40
  70. data/lib/vendor/treetop/spec/compiler/not_predicate_spec.rb +0 -38
  71. data/lib/vendor/treetop/spec/compiler/one_or_more_spec.rb +0 -35
  72. data/lib/vendor/treetop/spec/compiler/optional_spec.rb +0 -37
  73. data/lib/vendor/treetop/spec/compiler/parenthesized_expression_spec.rb +0 -19
  74. data/lib/vendor/treetop/spec/compiler/parsing_rule_spec.rb +0 -32
  75. data/lib/vendor/treetop/spec/compiler/sequence_spec.rb +0 -115
  76. data/lib/vendor/treetop/spec/compiler/terminal_spec.rb +0 -81
  77. data/lib/vendor/treetop/spec/compiler/terminal_symbol_spec.rb +0 -37
  78. data/lib/vendor/treetop/spec/compiler/test_grammar.treetop +0 -7
  79. data/lib/vendor/treetop/spec/compiler/test_grammar.tt +0 -7
  80. data/lib/vendor/treetop/spec/compiler/test_grammar_do.treetop +0 -7
  81. data/lib/vendor/treetop/spec/compiler/zero_or_more_spec.rb +0 -56
  82. data/lib/vendor/treetop/spec/composition/a.treetop +0 -11
  83. data/lib/vendor/treetop/spec/composition/b.treetop +0 -11
  84. data/lib/vendor/treetop/spec/composition/c.treetop +0 -10
  85. data/lib/vendor/treetop/spec/composition/d.treetop +0 -10
  86. data/lib/vendor/treetop/spec/composition/f.treetop +0 -17
  87. data/lib/vendor/treetop/spec/composition/grammar_composition_spec.rb +0 -40
  88. data/lib/vendor/treetop/spec/composition/subfolder/e_includes_c.treetop +0 -15
  89. data/lib/vendor/treetop/spec/ruby_extensions/string_spec.rb +0 -32
  90. data/lib/vendor/treetop/spec/runtime/compiled_parser_spec.rb +0 -101
  91. data/lib/vendor/treetop/spec/runtime/interval_skip_list/delete_spec.rb +0 -147
  92. data/lib/vendor/treetop/spec/runtime/interval_skip_list/expire_range_spec.rb +0 -349
  93. data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_and_delete_node.rb +0 -385
  94. data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_spec.rb +0 -660
  95. data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +0 -6175
  96. data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +0 -58
  97. data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture.rb +0 -23
  98. data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +0 -164
  99. data/lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb +0 -84
  100. data/lib/vendor/treetop/spec/runtime/syntax_node_spec.rb +0 -53
  101. data/lib/vendor/treetop/spec/spec_helper.rb +0 -106
  102. data/lib/vendor/treetop/spec/spec_suite.rb +0 -4
  103. data/lib/vendor/treetop/treetop.gemspec +0 -17
@@ -1,182 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
-
3
- module CharacterClassSpec
4
- class Foo < Treetop::Runtime::SyntaxNode
5
- end
6
-
7
- describe "a character class followed by a node class declaration and a block" do
8
-
9
- testing_expression "[A-Z] <CharacterClassSpec::Foo> { def a_method; end }"
10
-
11
- it "matches single characters within that range, returning instances of the declared node class that respond to the method defined in the inline module" do
12
- result = parse('A')
13
- result.should be_an_instance_of(Foo)
14
- result.should respond_to(:a_method)
15
- result = parse('N')
16
- result.should be_an_instance_of(Foo)
17
- result.should respond_to(:a_method)
18
- result = parse('Z')
19
- result.should be_an_instance_of(Foo)
20
- result.should respond_to(:a_method)
21
- end
22
-
23
- it "does not match single characters outside of that range" do
24
- parse('8').should be_nil
25
- parse('a').should be_nil
26
- end
27
-
28
- it "matches a single character within that range at index 1" do
29
- parse(' A', :index => 1).should_not be_nil
30
- end
31
-
32
- it "fails to match a single character out of that range at index 1" do
33
- parse(' 1', :index => 1).should be_nil
34
- end
35
- end
36
-
37
- module ModFoo
38
- end
39
-
40
- describe "a character class followed by a node module declaration and a block" do
41
-
42
- testing_expression "[A-Z] <CharacterClassSpec::ModFoo> { def a_method; end }"
43
-
44
- it "matches single characters within that range, returning instances of SyntaxNode extended by the specified module" do
45
- result = parse('A')
46
- result.should be_an_instance_of(Treetop::Runtime::SyntaxNode)
47
- result.should be_a_kind_of(ModFoo)
48
- result.should respond_to(:a_method)
49
- result = parse('N')
50
- result.should be_an_instance_of(Treetop::Runtime::SyntaxNode)
51
- result.should be_a_kind_of(ModFoo)
52
- result.should respond_to(:a_method)
53
- result = parse('Z')
54
- result.should be_an_instance_of(Treetop::Runtime::SyntaxNode)
55
- result.should be_a_kind_of(ModFoo)
56
- result.should respond_to(:a_method)
57
- end
58
-
59
- it "does not match single characters outside of that range" do
60
- parse('8').should be_nil
61
- parse('a').should be_nil
62
- end
63
-
64
- it "matches a single character within that range at index 1" do
65
- parse(' A', :index => 1).should_not be_nil
66
- end
67
-
68
- it "fails to match a single character out of that range at index 1" do
69
- parse(' 1', :index => 1).should be_nil
70
- end
71
- end
72
-
73
- describe "A character class containing quotes" do
74
- testing_expression "[\"']"
75
-
76
- it "matches a quote" do
77
- parse("'").should_not be_nil
78
- end
79
-
80
- it "matches a double-quote" do
81
- parse('"').should_not be_nil
82
- end
83
- end
84
-
85
- describe "A character class containing a special character" do
86
- testing_expression "[\t]"
87
- it "matches that character only" do
88
- parse("\t").should_not be_nil
89
- parse('t').should be_nil
90
- end
91
- end
92
-
93
- describe "A character class containing an escaped backslash" do
94
- slash = "\\" # Make it explicit that there are *two* backslashes here
95
- testing_expression "[#{slash}#{slash}]"
96
- it "matches a backslash only" do
97
- parse("\\").should_not be_nil
98
- parse('t').should be_nil
99
- end
100
- end
101
-
102
- describe "A character class containing a hex escape" do
103
- slash = "\\"
104
- testing_expression "[#{slash}x41]"
105
- it "matches that character only" do
106
- parse('A').should_not be_nil
107
- parse('\\').should be_nil
108
- parse('x').should be_nil
109
- parse('4').should be_nil
110
- parse('1').should be_nil
111
- end
112
- end
113
-
114
- describe "A character class containing an octal escape" do
115
- slash = "\\"
116
- testing_expression "[#{slash}101]"
117
- it "matches that character only" do
118
- parse('A').should_not be_nil
119
- parse('\\').should be_nil
120
- parse('1').should be_nil
121
- parse('0').should be_nil
122
- end
123
- end
124
-
125
- describe "A character class containing a \\c control-char escape" do
126
- slash = "\\"
127
- testing_expression "[#{slash}cC]"
128
- it "matches that character only" do
129
- parse("\003").should_not be_nil
130
- parse('\\').should be_nil
131
- parse('c').should be_nil
132
- parse('C').should be_nil
133
- end
134
- end
135
-
136
- describe "A character class containing a \\C- control-char escape" do
137
- slash = "\\"
138
- testing_expression "[#{slash}C-C]"
139
- it "matches that character only" do
140
- parse("\003").should_not be_nil
141
- parse('\\').should be_nil
142
- parse('C').should be_nil
143
- parse('-').should be_nil
144
- end
145
- end
146
-
147
- describe "A character class containing a \\M- meta-char escape" do
148
- slash = "\\"
149
- testing_expression "[#{slash}M- ]"
150
- it "matches that character only" do
151
- parse("\240").should_not be_nil
152
- parse('\\').should be_nil
153
- parse('M').should be_nil
154
- parse('-').should be_nil
155
- parse(' ').should be_nil
156
- end
157
- end
158
-
159
- describe "A character class containing an escaped non-special character" do
160
- slash = "\\"
161
- testing_expression "[#{slash}y]"
162
- it "matches that character only" do
163
- parse("y").should_not be_nil
164
- parse('\\').should be_nil
165
- end
166
- end
167
-
168
- describe "A character class containing an \#{...} insertion" do
169
- testing_expression "[\#{raise 'error'}]"
170
- it "doesn't evaluate the insertion" do
171
- x = true
172
- lambda{
173
- x = parse("y")
174
- }.should_not raise_error
175
- x.should be_nil
176
- parse('#').should_not be_nil
177
- parse("'").should_not be_nil
178
- parse("0").should be_nil
179
- end
180
- end
181
-
182
- end
@@ -1,80 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
-
3
- module ChoiceSpec
4
- describe "A choice between terminal symbols" do
5
- testing_expression '"foo" { def foo_method; end } / "bar" { def bar_method; end } / "baz" { def baz_method; end }'
6
-
7
- it "successfully parses input matching any of the alternatives, returning a node that responds to methods defined in its respective inline module" do
8
- result = parse('foo')
9
- result.should_not be_nil
10
- result.should respond_to(:foo_method)
11
-
12
- result = parse('bar')
13
- result.should_not be_nil
14
- result.should respond_to(:bar_method)
15
-
16
- result = parse('baz')
17
- result.should_not be_nil
18
- result.should respond_to(:baz_method)
19
- end
20
-
21
- it "upon parsing a string matching the second alternative, records the failure of the first terminal" do
22
- result = parse('bar')
23
- terminal_failures = parser.terminal_failures
24
- terminal_failures.size.should == 1
25
- failure = terminal_failures[0]
26
- failure.expected_string.should == 'foo'
27
- failure.index.should == 0
28
- end
29
-
30
- it "upon parsing a string matching the third alternative, records the failure of the first two terminals" do
31
- result = parse('baz')
32
-
33
- terminal_failures = parser.terminal_failures
34
-
35
- terminal_failures.size.should == 2
36
-
37
- failure_1 = terminal_failures[0]
38
- failure_1.expected_string == 'foo'
39
- failure_1.index.should == 0
40
-
41
- failure_2 = terminal_failures[1]
42
- failure_2.expected_string == 'bar'
43
- failure_2.index.should == 0
44
- end
45
- end
46
-
47
- describe "A choice between sequences" do
48
- testing_expression "'foo' 'bar' 'baz'\n/\n'bing' 'bang' 'boom'"
49
-
50
- it "successfully parses input matching any of the alternatives" do
51
- parse('foobarbaz').should_not be_nil
52
- parse('bingbangboom').should_not be_nil
53
- end
54
- end
55
-
56
- describe "A choice between terminals followed by a block" do
57
- testing_expression "('a'/ 'b' / 'c') { def a_method; end }"
58
-
59
- it "extends a match of any of its subexpressions with a module created from the block" do
60
- ['a', 'b', 'c'].each do |letter|
61
- parse(letter).should respond_to(:a_method)
62
- end
63
- end
64
- end
65
-
66
- module TestModule
67
- def a_method
68
- end
69
- end
70
-
71
- describe "a choice followed by a declared module" do
72
- testing_expression "('a'/ 'b' / 'c') <ChoiceSpec::TestModule>"
73
-
74
- it "extends a match of any of its subexpressions with a module created from the block" do
75
- ['a', 'b', 'c'].each do |letter|
76
- parse(letter).should respond_to(:a_method)
77
- end
78
- end
79
- end
80
- end
@@ -1,28 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
- BENCHMARK = false
3
-
4
- module CircularCompilationSpec
5
- describe "a parser for the metagrammar" do
6
- attr_reader :parser
7
-
8
- before do
9
- @parser = Treetop::Compiler::MetagrammarParser.new
10
- end
11
-
12
- it "can parse the metagrammar.treetop whence it was generated" do
13
- File.open(METAGRAMMAR_PATH, 'r') do |f|
14
- metagrammar_source = f.read
15
- result = parser.parse(metagrammar_source)
16
- result.should_not be_nil
17
-
18
- # generated_parser = result.compile
19
- # Object.class_eval(generated_parser)
20
- # parser_2 = Treetop::Compiler::MetagrammarParser.new
21
- # optionally_benchmark do
22
- # result = parser_2.parse(metagrammar_source)
23
- # result.should_not be_nil
24
- # end
25
- end
26
- end
27
- end
28
- end
@@ -1,21 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../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 File.expand_path("#{File.dirname(__FILE__)}/../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 File.expand_path("#{File.dirname(__FILE__)}/../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,40 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../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 File.expand_path("#{File.dirname(__FILE__)}/../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 File.expand_path("#{File.dirname(__FILE__)}/../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 File.expand_path("#{File.dirname(__FILE__)}/../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 File.expand_path("#{File.dirname(__FILE__)}/../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,32 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../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
- end