personify 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/.gitignore +2 -1
  2. data/.rvmrc +1 -0
  3. data/Rakefile +1 -0
  4. data/VERSION +1 -1
  5. data/lib/personify/parser/personify.rb +178 -122
  6. data/lib/personify.rb +1 -1
  7. data/test/context_test.rb +3 -3
  8. data/test/parse_runner.rb +1 -2
  9. data/test/parser_test.rb +3 -3
  10. metadata +42 -120
  11. data/vendor/treetop/.gitignore +0 -5
  12. data/vendor/treetop/History.txt +0 -9
  13. data/vendor/treetop/README +0 -164
  14. data/vendor/treetop/Rakefile +0 -20
  15. data/vendor/treetop/Treetop.tmbundle/Snippets/grammar ___ end.tmSnippet +0 -20
  16. data/vendor/treetop/Treetop.tmbundle/Snippets/rule ___ end.tmSnippet +0 -18
  17. data/vendor/treetop/Treetop.tmbundle/Syntaxes/Treetop Grammar.tmLanguage +0 -251
  18. data/vendor/treetop/Treetop.tmbundle/info.plist +0 -10
  19. data/vendor/treetop/bin/tt +0 -28
  20. data/vendor/treetop/doc/contributing_and_planned_features.markdown +0 -103
  21. data/vendor/treetop/doc/grammar_composition.markdown +0 -65
  22. data/vendor/treetop/doc/index.markdown +0 -90
  23. data/vendor/treetop/doc/pitfalls_and_advanced_techniques.markdown +0 -51
  24. data/vendor/treetop/doc/semantic_interpretation.markdown +0 -189
  25. data/vendor/treetop/doc/site.rb +0 -110
  26. data/vendor/treetop/doc/sitegen.rb +0 -60
  27. data/vendor/treetop/doc/syntactic_recognition.markdown +0 -100
  28. data/vendor/treetop/doc/using_in_ruby.markdown +0 -21
  29. data/vendor/treetop/examples/lambda_calculus/arithmetic.rb +0 -551
  30. data/vendor/treetop/examples/lambda_calculus/arithmetic.treetop +0 -97
  31. data/vendor/treetop/examples/lambda_calculus/arithmetic_node_classes.rb +0 -7
  32. data/vendor/treetop/examples/lambda_calculus/arithmetic_test.rb +0 -54
  33. data/vendor/treetop/examples/lambda_calculus/lambda_calculus +0 -0
  34. data/vendor/treetop/examples/lambda_calculus/lambda_calculus.rb +0 -718
  35. data/vendor/treetop/examples/lambda_calculus/lambda_calculus.treetop +0 -132
  36. data/vendor/treetop/examples/lambda_calculus/lambda_calculus_node_classes.rb +0 -5
  37. data/vendor/treetop/examples/lambda_calculus/lambda_calculus_test.rb +0 -89
  38. data/vendor/treetop/examples/lambda_calculus/test_helper.rb +0 -18
  39. data/vendor/treetop/lib/treetop/bootstrap_gen_1_metagrammar.rb +0 -45
  40. data/vendor/treetop/lib/treetop/compiler/grammar_compiler.rb +0 -40
  41. data/vendor/treetop/lib/treetop/compiler/lexical_address_space.rb +0 -17
  42. data/vendor/treetop/lib/treetop/compiler/metagrammar.rb +0 -2955
  43. data/vendor/treetop/lib/treetop/compiler/metagrammar.treetop +0 -404
  44. data/vendor/treetop/lib/treetop/compiler/node_classes/anything_symbol.rb +0 -20
  45. data/vendor/treetop/lib/treetop/compiler/node_classes/atomic_expression.rb +0 -14
  46. data/vendor/treetop/lib/treetop/compiler/node_classes/character_class.rb +0 -22
  47. data/vendor/treetop/lib/treetop/compiler/node_classes/choice.rb +0 -31
  48. data/vendor/treetop/lib/treetop/compiler/node_classes/declaration_sequence.rb +0 -24
  49. data/vendor/treetop/lib/treetop/compiler/node_classes/grammar.rb +0 -28
  50. data/vendor/treetop/lib/treetop/compiler/node_classes/inline_module.rb +0 -27
  51. data/vendor/treetop/lib/treetop/compiler/node_classes/nonterminal.rb +0 -13
  52. data/vendor/treetop/lib/treetop/compiler/node_classes/optional.rb +0 -19
  53. data/vendor/treetop/lib/treetop/compiler/node_classes/parenthesized_expression.rb +0 -9
  54. data/vendor/treetop/lib/treetop/compiler/node_classes/parsing_expression.rb +0 -138
  55. data/vendor/treetop/lib/treetop/compiler/node_classes/parsing_rule.rb +0 -55
  56. data/vendor/treetop/lib/treetop/compiler/node_classes/predicate.rb +0 -45
  57. data/vendor/treetop/lib/treetop/compiler/node_classes/repetition.rb +0 -55
  58. data/vendor/treetop/lib/treetop/compiler/node_classes/sequence.rb +0 -68
  59. data/vendor/treetop/lib/treetop/compiler/node_classes/terminal.rb +0 -20
  60. data/vendor/treetop/lib/treetop/compiler/node_classes/transient_prefix.rb +0 -9
  61. data/vendor/treetop/lib/treetop/compiler/node_classes/treetop_file.rb +0 -9
  62. data/vendor/treetop/lib/treetop/compiler/node_classes.rb +0 -19
  63. data/vendor/treetop/lib/treetop/compiler/ruby_builder.rb +0 -113
  64. data/vendor/treetop/lib/treetop/compiler.rb +0 -6
  65. data/vendor/treetop/lib/treetop/ruby_extensions/string.rb +0 -42
  66. data/vendor/treetop/lib/treetop/ruby_extensions.rb +0 -2
  67. data/vendor/treetop/lib/treetop/runtime/compiled_parser.rb +0 -95
  68. data/vendor/treetop/lib/treetop/runtime/interval_skip_list/head_node.rb +0 -15
  69. data/vendor/treetop/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +0 -200
  70. data/vendor/treetop/lib/treetop/runtime/interval_skip_list/node.rb +0 -164
  71. data/vendor/treetop/lib/treetop/runtime/interval_skip_list.rb +0 -4
  72. data/vendor/treetop/lib/treetop/runtime/syntax_node.rb +0 -72
  73. data/vendor/treetop/lib/treetop/runtime/terminal_parse_failure.rb +0 -16
  74. data/vendor/treetop/lib/treetop/runtime/terminal_syntax_node.rb +0 -17
  75. data/vendor/treetop/lib/treetop/runtime.rb +0 -5
  76. data/vendor/treetop/lib/treetop/version.rb +0 -9
  77. data/vendor/treetop/lib/treetop.rb +0 -11
  78. data/vendor/treetop/script/generate_metagrammar.rb +0 -14
  79. data/vendor/treetop/script/svnadd +0 -11
  80. data/vendor/treetop/script/svnrm +0 -11
  81. data/vendor/treetop/spec/compiler/and_predicate_spec.rb +0 -36
  82. data/vendor/treetop/spec/compiler/anything_symbol_spec.rb +0 -52
  83. data/vendor/treetop/spec/compiler/character_class_spec.rb +0 -188
  84. data/vendor/treetop/spec/compiler/choice_spec.rb +0 -80
  85. data/vendor/treetop/spec/compiler/circular_compilation_spec.rb +0 -28
  86. data/vendor/treetop/spec/compiler/failure_propagation_functional_spec.rb +0 -21
  87. data/vendor/treetop/spec/compiler/grammar_compiler_spec.rb +0 -84
  88. data/vendor/treetop/spec/compiler/grammar_spec.rb +0 -41
  89. data/vendor/treetop/spec/compiler/nonterminal_symbol_spec.rb +0 -40
  90. data/vendor/treetop/spec/compiler/not_predicate_spec.rb +0 -38
  91. data/vendor/treetop/spec/compiler/one_or_more_spec.rb +0 -35
  92. data/vendor/treetop/spec/compiler/optional_spec.rb +0 -37
  93. data/vendor/treetop/spec/compiler/parenthesized_expression_spec.rb +0 -19
  94. data/vendor/treetop/spec/compiler/parsing_rule_spec.rb +0 -32
  95. data/vendor/treetop/spec/compiler/sequence_spec.rb +0 -115
  96. data/vendor/treetop/spec/compiler/terminal_spec.rb +0 -81
  97. data/vendor/treetop/spec/compiler/terminal_symbol_spec.rb +0 -37
  98. data/vendor/treetop/spec/compiler/test_grammar.treetop +0 -7
  99. data/vendor/treetop/spec/compiler/test_grammar.tt +0 -7
  100. data/vendor/treetop/spec/compiler/test_grammar_do.treetop +0 -7
  101. data/vendor/treetop/spec/compiler/zero_or_more_spec.rb +0 -56
  102. data/vendor/treetop/spec/composition/a.treetop +0 -11
  103. data/vendor/treetop/spec/composition/b.treetop +0 -11
  104. data/vendor/treetop/spec/composition/c.treetop +0 -10
  105. data/vendor/treetop/spec/composition/d.treetop +0 -10
  106. data/vendor/treetop/spec/composition/grammar_composition_spec.rb +0 -26
  107. data/vendor/treetop/spec/ruby_extensions/string_spec.rb +0 -32
  108. data/vendor/treetop/spec/runtime/compiled_parser_spec.rb +0 -101
  109. data/vendor/treetop/spec/runtime/interval_skip_list/delete_spec.rb +0 -147
  110. data/vendor/treetop/spec/runtime/interval_skip_list/expire_range_spec.rb +0 -349
  111. data/vendor/treetop/spec/runtime/interval_skip_list/insert_and_delete_node.rb +0 -385
  112. data/vendor/treetop/spec/runtime/interval_skip_list/insert_spec.rb +0 -660
  113. data/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +0 -6175
  114. data/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +0 -58
  115. data/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture.rb +0 -23
  116. data/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +0 -164
  117. data/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb +0 -84
  118. data/vendor/treetop/spec/runtime/syntax_node_spec.rb +0 -53
  119. data/vendor/treetop/spec/spec_helper.rb +0 -106
  120. data/vendor/treetop/spec/spec_suite.rb +0 -4
  121. data/vendor/treetop/treetop.gemspec +0 -18
@@ -1,115 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
-
3
- module SequenceSpec
4
- class Foo < Treetop::Runtime::SyntaxNode
5
- end
6
-
7
- describe "a sequence of labeled terminal symbols followed by a node class declaration and a block" do
8
- testing_expression 'foo:"foo" bar:"bar" baz:"baz" <SequenceSpec::Foo> { def a_method; end }'
9
-
10
- it "upon successfully matching input, instantiates an instance of the declared node class with element accessor methods and the method from the inline module" do
11
- parse('foobarbaz') do |result|
12
- result.should_not be_nil
13
- result.should be_an_instance_of(Foo)
14
- result.should respond_to(:a_method)
15
- result.foo.text_value.should == 'foo'
16
- result.bar.text_value.should == 'bar'
17
- result.baz.text_value.should == 'baz'
18
- end
19
- end
20
-
21
- it "successfully matches at a non-zero index" do
22
- parse('---foobarbaz', :index => 3) do |result|
23
- result.should_not be_nil
24
- result.should be_nonterminal
25
- (result.elements.map {|elt| elt.text_value}).join.should == 'foobarbaz'
26
- end
27
- end
28
-
29
- it "fails to match non-matching input, recording the parse failure of first non-matching terminal" do
30
- parse('---foobazbaz', :index => 3) do |result|
31
- result.should be_nil
32
- parser.index.should == 3
33
- terminal_failures = parser.terminal_failures
34
- terminal_failures.size.should == 1
35
- failure = terminal_failures.first
36
- failure.index.should == 6
37
- failure.expected_string.should == 'bar'
38
- end
39
- end
40
- end
41
-
42
- module ModFoo
43
- def mod_method; end
44
- end
45
-
46
- describe "a sequence of labeled terminal symbols followed by a node module declaration and a block" do
47
- testing_expression 'foo:"foo" bar:"bar" baz:"baz" <SequenceSpec::ModFoo> { def a_method; end }'
48
-
49
- it "upon successfully matching input, instantiates a syntax node and extends it with the declared module, element accessor methods, and the method from the inline module" do
50
- parse('foobarbaz') do |result|
51
- result.should_not be_nil
52
- result.should respond_to(:mod_method)
53
- result.should be_an_instance_of(Treetop::Runtime::SyntaxNode)
54
- result.should be_a_kind_of(ModFoo)
55
- result.should respond_to(:a_method)
56
- result.foo.text_value.should == 'foo'
57
- result.bar.text_value.should == 'bar'
58
- result.baz.text_value.should == 'baz'
59
- end
60
- end
61
- end
62
-
63
- describe "a sequence of non-terminals" do
64
- testing_grammar %{
65
- grammar TestGrammar
66
- rule sequence
67
- foo bar baz {
68
- def baz
69
- 'override' + super.text_value
70
- end
71
- }
72
- end
73
-
74
- rule foo 'foo' end
75
- rule bar 'bar' end
76
- rule baz 'baz' end
77
- end
78
- }
79
-
80
- it "defines accessors for non-terminals automatically that can be overridden in the inline block" do
81
- parse('foobarbaz') do |result|
82
- result.foo.text_value.should == 'foo'
83
- result.bar.text_value.should == 'bar'
84
- result.baz.should == 'overridebaz'
85
- end
86
- end
87
- end
88
-
89
- describe "Compiling a sequence containing various white-space errors" do
90
- it "should succeed on a valid sequence" do
91
- compiling_expression('foo:"foo" "bar" <SequenceSpec::Foo> { def a_method; end }').should_not raise_error
92
- end
93
-
94
- it "rejects space after a label" do
95
- compiling_expression('foo :"foo" "bar"').should raise_error(RuntimeError)
96
- end
97
-
98
- it "rejects space after label's colon" do
99
- compiling_expression('foo: "foo" "bar"').should raise_error(RuntimeError)
100
- end
101
-
102
- it "rejects missing space after a primary" do
103
- compiling_expression('foo:"foo""bar"').should raise_error(RuntimeError)
104
- end
105
-
106
- it "rejects missing space before node class declaration" do
107
- compiling_expression('foo:"foo" "bar"<SequenceSpec::Foo>').should raise_error(RuntimeError)
108
- end
109
-
110
- it "rejects missing space before inline module" do
111
- compiling_expression('foo:"foo" "bar" <SequenceSpec::Foo>{def a_method; end}').should raise_error(RuntimeError)
112
- end
113
- end
114
-
115
- end
@@ -1,81 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
-
3
- module TerminalSymbolSpec
4
- class Foo < Treetop::Runtime::SyntaxNode
5
- end
6
-
7
- describe "a terminal symbol followed by a node class declaration and a block" do
8
- testing_expression "'foo' <TerminalSymbolSpec::Foo> { def a_method; end }"
9
-
10
- it "correctly parses matching input prefixes at various indices, returning an instance of the declared class that can respond to methods defined in the inline module" do
11
- parse "foo", :index => 0 do |result|
12
- result.should be_an_instance_of(Foo)
13
- result.should respond_to(:a_method)
14
- result.interval.should == (0...3)
15
- result.text_value.should == 'foo'
16
- end
17
-
18
- parse "xfoo", :index => 1 do |result|
19
- result.should be_an_instance_of(Foo)
20
- result.should respond_to(:a_method)
21
- result.interval.should == (1...4)
22
- result.text_value.should == 'foo'
23
- end
24
-
25
- parse "---foo", :index => 3 do |result|
26
- result.should be_an_instance_of(Foo)
27
- result.should respond_to(:a_method)
28
- result.interval.should == (3...6)
29
- result.text_value.should == 'foo'
30
- end
31
- end
32
-
33
- it "fails to parse nonmatching input at the index even if a match occurs later" do
34
- parse(" foo", :index => 0).should be_nil
35
- end
36
- end
37
-
38
- module ModFoo
39
- end
40
-
41
- describe "a terminal symbol followed by a node class declaration and a block" do
42
- testing_expression "'foo' <TerminalSymbolSpec::ModFoo> { def a_method; end }"
43
-
44
- it "correctly parses matching input prefixes at various indices, returning an instance of SyntaxNode extended with the declared module that can respond to methods defined in the inline module" do
45
- parse "foo", :index => 0 do |result|
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.interval.should == (0...3)
50
- result.text_value.should == 'foo'
51
- end
52
-
53
- parse "xfoo", :index => 1 do |result|
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
- result.interval.should == (1...4)
58
- result.text_value.should == 'foo'
59
- end
60
-
61
- parse "---foo", :index => 3 do |result|
62
- result.should be_an_instance_of(Treetop::Runtime::SyntaxNode)
63
- result.should be_a_kind_of(ModFoo)
64
- result.should respond_to(:a_method)
65
- result.interval.should == (3...6)
66
- result.text_value.should == 'foo'
67
- end
68
- end
69
- end
70
-
71
- describe "a transient terminal symbol" do
72
- testing_expression "~'foo'"
73
-
74
- it "returns true upon parsing matching input prefixes at various indices" do
75
- pending "transient terminal expressions"
76
- parse("foo", :index => 0).should be_true
77
- parse("-foo", :index => 1).should be_true
78
- parse("---foo", :index => 3).should be_true
79
- end
80
- end
81
- end
@@ -1,37 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
-
3
- module TerminalSymbolSpec
4
- class Foo < Treetop::Runtime::SyntaxNode
5
- end
6
-
7
- describe "a terminal symbol followed by a node class declaration and a block" do
8
- testing_expression "'foo' <TerminalSymbolSpec::Foo> { def a_method; end }"
9
-
10
- it "correctly parses matching input prefixes at various indices, returning an instance of the declared class that can respond to methods defined in the inline module" do
11
- parse "foo", :index => 0 do |result|
12
- result.should be_an_instance_of(Foo)
13
- result.should respond_to(:a_method)
14
- result.interval.should == (0...3)
15
- result.text_value.should == 'foo'
16
- end
17
-
18
- parse "xfoo", :index => 1 do |result|
19
- result.should be_an_instance_of(Foo)
20
- result.should respond_to(:a_method)
21
- result.interval.should == (1...4)
22
- result.text_value.should == 'foo'
23
- end
24
-
25
- parse "---foo", :index => 3 do |result|
26
- result.should be_an_instance_of(Foo)
27
- result.should respond_to(:a_method)
28
- result.interval.should == (3...6)
29
- result.text_value.should == 'foo'
30
- end
31
- end
32
-
33
- it "fails to parse nonmatching input at the index even if a match occurs later" do
34
- parse(" foo", :index => 0).should be_nil
35
- end
36
- end
37
- end
@@ -1,7 +0,0 @@
1
- module Test
2
- grammar Grammar
3
- rule foo
4
- 'foo'
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module Test
2
- grammar Grammar
3
- rule foo
4
- 'foo'
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module Test
2
- grammar Grammar do
3
- rule foo do
4
- 'foo'
5
- end
6
- end
7
- end
@@ -1,56 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
-
3
- module ZeroOrMoreSpec
4
- class Foo < Treetop::Runtime::SyntaxNode
5
- end
6
-
7
- describe "zero or more of a terminal symbol followed by a node class declaration and a block" do
8
- testing_expression '"foo"* <ZeroOrMoreSpec::Foo> { def a_method; end }'
9
-
10
- it "successfully parses epsilon, returning an instance declared node class and recording a terminal failure" do
11
- parse('') do |result|
12
- result.should_not be_nil
13
- result.should be_an_instance_of(Foo)
14
- result.should respond_to(:a_method)
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 "successfully parses two of that terminal in a row, returning an instance of the declared node class and recording a failure representing the third attempt " do
25
- parse("foofoo") do |result|
26
- result.should_not be_nil
27
- result.should be_an_instance_of(Foo)
28
-
29
- terminal_failures = parser.terminal_failures
30
- terminal_failures.size.should == 1
31
- failure = terminal_failures.first
32
- failure.index.should == 6
33
- failure.expected_string.should == 'foo'
34
- end
35
- end
36
- end
37
-
38
- describe "Zero or more of a sequence" do
39
- testing_expression '("foo" "bar")*'
40
-
41
- it "resets the index appropriately following partially matcing input" do
42
- parse('foobarfoo', :consume_all_input => false) do |result|
43
- result.should_not be_nil
44
- result.interval.should == (0...6)
45
- end
46
- end
47
- end
48
-
49
- describe "Zero or more of a choice" do
50
- testing_expression '("a" / "b")*'
51
-
52
- it "successfully parses matching input" do
53
- parse('abba').should_not be_nil
54
- end
55
- end
56
- end
@@ -1,11 +0,0 @@
1
- module Test
2
- grammar A
3
- rule a
4
- 'a'
5
- end
6
-
7
- rule inherit
8
- 'super'
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Test
2
- grammar B
3
- rule b
4
- 'b'
5
- end
6
-
7
- rule inherit
8
- super 'keyword'
9
- end
10
- end
11
- end
@@ -1,10 +0,0 @@
1
- module Test
2
- grammar C
3
- include A
4
- include B
5
-
6
- rule c
7
- a b 'c'
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- module Test
2
- grammar D
3
- include A
4
- include B
5
-
6
- rule inherit
7
- super 'works'
8
- end
9
- end
10
- end
@@ -1,26 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
-
3
- module GrammarCompositionSpec
4
- describe "several composed grammars" do
5
- before do
6
- dir = File.dirname(__FILE__)
7
- Treetop.load File.join(dir, 'a')
8
- Treetop.load File.join(dir, 'b')
9
- Treetop.load File.join(dir, 'c')
10
- # Check that polyglot finds d.treetop and loads it:
11
- $: << dir
12
- require 'd'
13
-
14
- @c = ::Test::CParser.new
15
- @d = ::Test::DParser.new
16
- end
17
-
18
- specify "rules in C have access to rules defined in A and B" do
19
- @c.parse('abc').should_not be_nil
20
- end
21
-
22
- specify "rules in C can override rules in A and B with super semantics" do
23
- @d.parse('superkeywordworks').should_not be_nil
24
- end
25
- end
26
- end
@@ -1,32 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
-
3
- describe String do
4
- before do
5
- @string = %{
6
- 0123456789
7
- 012345
8
- 01234567
9
- 0123
10
- }.tabto(0).strip
11
- end
12
-
13
- it "can translate indices to column numbers" do
14
- @string.column_of(0).should == 1
15
- @string.column_of(5).should == 6
16
- @string.column_of(10).should == 11
17
- @string.column_of(11).should == 1
18
- @string.column_of(17).should == 7
19
- @string.column_of(18).should == 1
20
- @string.column_of(24).should == 7
21
- end
22
-
23
- it "can translate indices to line numbers" do
24
- @string.line_of(0).should == 1
25
- @string.line_of(5).should == 1
26
- @string.line_of(10).should == 1
27
- @string.line_of(11).should == 2
28
- @string.line_of(17).should == 2
29
- @string.line_of(18).should == 3
30
- @string.line_of(24).should == 3
31
- end
32
- end
@@ -1,101 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
-
3
- module CompiledParserSpec
4
- describe Runtime::CompiledParser, "for a grammar with two rules" do
5
- attr_reader :parser
6
-
7
- testing_grammar %{
8
- grammar TwoRules
9
- rule a
10
- 'a'
11
- end
12
-
13
- rule b
14
- 'b'
15
- end
16
- end
17
- }
18
-
19
- before do
20
- @parser = parser_class_under_test.new
21
- end
22
-
23
- it "allows its root to be specified" do
24
- parser.parse('a').should_not be_nil
25
- parser.parse('b').should be_nil
26
-
27
- parser.root = :b
28
- parser.parse('b').should_not be_nil
29
- parser.parse('a').should be_nil
30
- end
31
-
32
- it "allows the requirement that all input be consumed to be disabled" do
33
- parser.parse('ab').should be_nil
34
- parser.consume_all_input = false
35
- result = parser.parse('ab')
36
- result.should_not be_nil
37
- result.interval.should == (0...1)
38
- end
39
-
40
- it "allows input to be parsed at a given index" do
41
- parser.parse('ba').should be_nil
42
- parser.parse('ba', :index => 1).should_not be_nil
43
- end
44
-
45
- end
46
-
47
- describe Runtime::CompiledParser, "for a grammar with a choice between terminals" do
48
- attr_reader :parser
49
-
50
- testing_grammar %{
51
- grammar Choice
52
- rule choice
53
- 'a' / 'b' / 'c'
54
- end
55
- end
56
- }
57
-
58
- before do
59
- @parser = parser_class_under_test.new
60
- end
61
-
62
- it "provides #failure_reason, #failure_column, and #failure_line when there is a parse failure" do
63
- parser.parse('z').should be_nil
64
- parser.failure_reason.should == "Expected one of a, b, c at line 1, column 1 (byte 1) after "
65
- parser.failure_line.should == 1
66
- parser.failure_column.should == 1
67
- end
68
- end
69
-
70
- describe Runtime::CompiledParser, "#terminal_failures" do
71
- attr_reader:parser
72
-
73
- testing_grammar %{
74
- grammar SequenceOfTerminals
75
- rule foo
76
- 'a' 'b' 'c'
77
- end
78
- end
79
- }
80
-
81
- before do
82
- @parser = parser_class_under_test.new
83
- end
84
-
85
- it "is reset between parses" do
86
- parser.parse('ac')
87
- terminal_failures = parser.terminal_failures
88
- terminal_failures.size.should == 1
89
- failure = terminal_failures.first
90
- failure.index.should == 1
91
- failure.expected_string.should == 'b'
92
-
93
- parser.parse('b')
94
- terminal_failures = parser.terminal_failures
95
- terminal_failures.size.should == 1
96
- failure = terminal_failures.first
97
- failure.index.should == 0
98
- failure.expected_string.should == 'a'
99
- end
100
- end
101
- end
@@ -1,147 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
-
3
- class IntervalSkipList
4
- public :insert_node, :delete_node, :head, :nodes
5
- end
6
-
7
- describe IntervalSkipList do
8
- it_should_behave_like "the palindromic fixture"
9
-
10
- describe " when :c is deleted" do
11
- before do
12
- list.delete(:c)
13
- end
14
-
15
- describe "[0]" do
16
- before do
17
- @node = list.nodes[0]
18
- end
19
-
20
- it "has a key of 1 and a height of 3" do
21
- node.key.should == 1
22
- node.height.should == 3
23
- end
24
-
25
- it "has :f as its only forward marker at level 2" do
26
- node.forward_markers[2].should have_markers(:f)
27
- end
28
-
29
- it "has :a, :b, :d, and :e as its only forward markers at level 1" do
30
- node.forward_markers[1].should have_markers(:a, :b, :d, :e)
31
- end
32
-
33
- it "has no forward markers at level 0" do
34
- node.forward_markers[0].should be_empty
35
- end
36
-
37
- it "has no markers" do
38
- node.markers.should be_empty
39
- end
40
- end
41
-
42
- describe "[1]" do
43
- before do
44
- @node = list.nodes[1]
45
- end
46
-
47
- it "has a key of 3 and a height of 2" do
48
- node.key.should == 3
49
- node.height.should == 2
50
- end
51
-
52
- it "has :e as its only forward marker at level 1" do
53
- node.forward_markers[1].should have_markers(:e)
54
- end
55
-
56
- it "has :b and :d as its only forward markers at level 0" do
57
- node.forward_markers[0].should have_markers(:b, :d)
58
- end
59
-
60
- it "has :a, :b, :d, and :e as its only markers" do
61
- node.markers.should have_markers(:a, :b, :d, :e)
62
- end
63
- end
64
-
65
- describe "[2]" do
66
- before do
67
- @node = list.nodes[2]
68
- end
69
-
70
- it "has a key of 5 and a height of 1" do
71
- node.key.should == 5
72
- node.height.should == 1
73
- end
74
-
75
- it "has :d and :g as its only forward markers at level 0" do
76
- node.forward_markers[0].should have_markers(:d, :g)
77
- end
78
-
79
- it "has :b and :d as its only markers" do
80
- node.markers.should have_markers(:b, :d)
81
- end
82
- end
83
-
84
- describe "[3]" do
85
- before do
86
- @node = list.nodes[3]
87
- end
88
-
89
- it "has a key of 9 and a height of 1" do
90
- node.key.should == 9
91
- node.height.should == 1
92
- end
93
-
94
- it "has :g as its only forward marker at level 0" do
95
- node.forward_markers[0].should have_markers(:g)
96
- end
97
-
98
- it "has :d and :g as its only markers" do
99
- node.markers.should have_markers(:d, :g)
100
- end
101
- end
102
-
103
- describe "[4]" do
104
- before do
105
- @node = list.nodes[4]
106
- end
107
-
108
- it "has a key of 11 and a height of 2" do
109
- node.key.should == 11
110
- node.height.should == 2
111
- end
112
-
113
- it "has :g as its only forward marker at level 1" do
114
- node.forward_markers[1].should have_markers(:g)
115
- end
116
-
117
- it "has no forward markers at level 0" do
118
- node.forward_markers[0].should be_empty
119
- end
120
-
121
- it "has :e and :g as its only markers" do
122
- node.markers.should have_markers(:e, :g)
123
- end
124
- end
125
-
126
- describe "[5]" do
127
- before do
128
- @node = list.nodes[5]
129
- end
130
-
131
- it "has a key of 13 and a height of 3" do
132
- node.key.should == 13
133
- node.height.should == 3
134
- end
135
-
136
- it "has no forward markers at any level" do
137
- node.forward_markers[0].should be_empty
138
- node.forward_markers[1].should be_empty
139
- node.forward_markers[2].should be_empty
140
- end
141
-
142
- it "has :f and :g as its only markers" do
143
- node.markers.should have_markers(:f, :g)
144
- end
145
- end
146
- end
147
- end