treetop 1.6.6 → 1.6.11

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 (66) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +18 -0
  3. data/History.txt +18 -0
  4. data/README.md +2 -0
  5. data/Rakefile +10 -43
  6. data/Treetop.tmbundle/Preferences/Comments.tmPreferences +28 -0
  7. data/Treetop.tmbundle/Snippets/grammar ___ end.tmSnippet +20 -0
  8. data/Treetop.tmbundle/Snippets/rule ___ end.tmSnippet +18 -0
  9. data/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/designable.nib +1524 -0
  10. data/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/keyedobjects.nib +0 -0
  11. data/Treetop.tmbundle/Support/syntax_tree_viewer.rb +117 -0
  12. data/Treetop.tmbundle/Syntaxes/Treetop Grammar.tmLanguage +358 -0
  13. data/Treetop.tmbundle/info.plist +10 -0
  14. data/doc/pitfalls_and_advanced_techniques.markdown +6 -0
  15. data/doc/syntactic_recognition.markdown +2 -2
  16. data/lib/treetop/compiler/grammar_compiler.rb +6 -3
  17. data/lib/treetop/compiler/metagrammar.rb +97 -77
  18. data/lib/treetop/compiler/metagrammar.treetop +1 -1
  19. data/lib/treetop/compiler/ruby_builder.rb +2 -2
  20. data/lib/treetop/ruby_extensions/string.rb +0 -6
  21. data/lib/treetop/runtime/compiled_parser.rb +15 -2
  22. data/lib/treetop/version.rb +1 -1
  23. data/treetop.gemspec +25 -157
  24. metadata +15 -61
  25. data/doc/site.rb +0 -112
  26. data/doc/sitegen.rb +0 -65
  27. data/spec/compiler/and_predicate_spec.rb +0 -36
  28. data/spec/compiler/anything_symbol_spec.rb +0 -47
  29. data/spec/compiler/character_class_spec.rb +0 -304
  30. data/spec/compiler/choice_spec.rb +0 -89
  31. data/spec/compiler/circular_compilation_spec.rb +0 -30
  32. data/spec/compiler/failure_propagation_functional_spec.rb +0 -21
  33. data/spec/compiler/grammar_compiler_spec.rb +0 -113
  34. data/spec/compiler/grammar_spec.rb +0 -44
  35. data/spec/compiler/multibyte_chars_spec.rb +0 -38
  36. data/spec/compiler/namespace_spec.rb +0 -42
  37. data/spec/compiler/nonterminal_symbol_spec.rb +0 -40
  38. data/spec/compiler/not_predicate_spec.rb +0 -52
  39. data/spec/compiler/occurrence_range_spec.rb +0 -186
  40. data/spec/compiler/one_or_more_spec.rb +0 -35
  41. data/spec/compiler/optional_spec.rb +0 -37
  42. data/spec/compiler/parenthesized_expression_spec.rb +0 -34
  43. data/spec/compiler/parsing_rule_spec.rb +0 -61
  44. data/spec/compiler/repeated_subrule_spec.rb +0 -29
  45. data/spec/compiler/semantic_predicate_spec.rb +0 -176
  46. data/spec/compiler/sequence_spec.rb +0 -129
  47. data/spec/compiler/terminal_spec.rb +0 -177
  48. data/spec/compiler/terminal_symbol_spec.rb +0 -40
  49. data/spec/compiler/test_grammar.treetop +0 -7
  50. data/spec/compiler/test_grammar.tt +0 -7
  51. data/spec/compiler/test_grammar_do.treetop +0 -7
  52. data/spec/compiler/test_grammar_magic_coding.treetop +0 -8
  53. data/spec/compiler/test_grammar_magic_encoding.treetop +0 -8
  54. data/spec/compiler/tt_compiler_spec.rb +0 -224
  55. data/spec/compiler/zero_or_more_spec.rb +0 -58
  56. data/spec/composition/a.treetop +0 -11
  57. data/spec/composition/b.treetop +0 -11
  58. data/spec/composition/c.treetop +0 -10
  59. data/spec/composition/d.treetop +0 -10
  60. data/spec/composition/f.treetop +0 -17
  61. data/spec/composition/grammar_composition_spec.rb +0 -40
  62. data/spec/composition/subfolder/e_includes_c.treetop +0 -15
  63. data/spec/ruby_extensions/string_spec.rb +0 -32
  64. data/spec/runtime/compiled_parser_spec.rb +0 -153
  65. data/spec/runtime/syntax_node_spec.rb +0 -77
  66. data/spec/spec_helper.rb +0 -123
@@ -1,123 +0,0 @@
1
- require 'rubygems'
2
- require 'benchmark'
3
- require 'rspec'
4
- require 'rspec/core/shared_context'
5
- require 'polyglot'
6
-
7
- $LOAD_PATH.unshift File.expand_path('../../lib')
8
- require 'treetop'
9
- include Treetop
10
-
11
- # We're still using the old expect syntax:
12
- RSpec.configure do |c|
13
- c.expect_with(:rspec) { |c| c.syntax = :should }
14
- end
15
-
16
- module Treetop
17
- module ExampleGroupInstanceMethods
18
- module ClassMethods
19
- attr_accessor :parser_class_under_test
20
- attr_accessor :parser_text
21
- attr_accessor :parser_code
22
-
23
- def testing_expression(expression_under_test)
24
- testing_grammar(%{
25
- grammar Test
26
- rule expression_under_test
27
- }+expression_under_test+%{
28
- end
29
- end
30
- }.tabto(0))
31
- end
32
-
33
- def testing_grammar(grammar_under_test)
34
- self.parser_text = grammar_under_test
35
- grammar_node = parse_with_metagrammar(grammar_under_test.strip, :module_or_grammar)
36
- self.parser_code = grammar_node.compile
37
- class_eval(self.parser_code)
38
- self.parser_class_under_test = class_eval(grammar_node.parser_name)
39
- end
40
-
41
- def parse_with_metagrammar(input, root)
42
- parser = Treetop::Compiler::MetagrammarParser.new
43
- parser.root = root
44
- node = parser.parse(input)
45
- raise parser.failure_reason unless node
46
- node
47
- end
48
-
49
- end
50
-
51
- attr_reader :parser
52
-
53
- def parse_with_metagrammar(input, root)
54
- self.class.parse_with_metagrammar(input, root)
55
- end
56
-
57
- def parser_class_under_test
58
- self.class.parser_class_under_test
59
- end
60
-
61
- def parse(input, options = {})
62
- @parser = parser_class_under_test.new
63
- unless options[:consume_all_input].nil?
64
- parser.consume_all_input = options.delete(:consume_all_input)
65
- end
66
- result = parser.parse(input, options)
67
- yield result if block_given?
68
- result
69
- end
70
-
71
- def parse_multibyte(input, options = {})
72
- require 'active_support/all'
73
-
74
- if RUBY_VERSION !~ /^(1\.9|2\.)/ && 'NONE' == $KCODE then $KCODE = 'UTF8' end
75
- # rspec 1.3 used to do something similar (set it to 'u') that we need
76
- # for activerecord multibyte wrapper to kick in (1.8 only? @todo)
77
-
78
- parse(input.mb_chars, options)
79
- end
80
-
81
- def compiling_grammar(grammar_under_test)
82
- lambda {
83
- grammar_node = parse_with_metagrammar(grammar_under_test.strip, :grammar)
84
- parser_code = grammar_node.compile
85
- [grammar_node, parser_code]
86
- }
87
- end
88
-
89
- def compiling_expression(expression_under_test)
90
- compiling_grammar(%{
91
- grammar Test
92
- rule expression_under_test
93
- #{expression_under_test}
94
- end
95
- end
96
- }.tabto(0))
97
- end
98
-
99
- def optionally_benchmark(&block)
100
- if BENCHMARK
101
- Benchmark.bm do |x|
102
- x.report(&block)
103
- end
104
- else
105
- yield
106
- end
107
- end
108
- end
109
- end
110
-
111
- RSpec.configure do |c|
112
- c.mock_with :rr
113
- c.extend Treetop::ExampleGroupInstanceMethods::ClassMethods
114
- c.include Treetop::ExampleGroupInstanceMethods
115
- end
116
-
117
- class Symbol
118
- def to_proc
119
- lambda do |x|
120
- x.send(self)
121
- end
122
- end unless method_defined?(:to_proc)
123
- end