treetop 1.6.8 → 1.6.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +18 -0
  3. data/History.txt +18 -0
  4. data/Rakefile +3 -28
  5. data/Treetop.tmbundle/Preferences/Comments.tmPreferences +28 -0
  6. data/Treetop.tmbundle/Snippets/grammar ___ end.tmSnippet +20 -0
  7. data/Treetop.tmbundle/Snippets/rule ___ end.tmSnippet +18 -0
  8. data/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/designable.nib +1524 -0
  9. data/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/keyedobjects.nib +0 -0
  10. data/Treetop.tmbundle/Support/syntax_tree_viewer.rb +117 -0
  11. data/Treetop.tmbundle/Syntaxes/Treetop Grammar.tmLanguage +358 -0
  12. data/Treetop.tmbundle/info.plist +10 -0
  13. data/lib/treetop/runtime/compiled_parser.rb +15 -2
  14. data/lib/treetop/version.rb +1 -1
  15. data/treetop.gemspec +25 -157
  16. metadata +12 -56
  17. data/spec/compiler/and_predicate_spec.rb +0 -36
  18. data/spec/compiler/anything_symbol_spec.rb +0 -47
  19. data/spec/compiler/character_class_spec.rb +0 -304
  20. data/spec/compiler/choice_spec.rb +0 -89
  21. data/spec/compiler/circular_compilation_spec.rb +0 -30
  22. data/spec/compiler/failure_propagation_functional_spec.rb +0 -21
  23. data/spec/compiler/grammar_compiler_spec.rb +0 -113
  24. data/spec/compiler/grammar_spec.rb +0 -44
  25. data/spec/compiler/multibyte_chars_spec.rb +0 -38
  26. data/spec/compiler/namespace_spec.rb +0 -42
  27. data/spec/compiler/nonterminal_symbol_spec.rb +0 -40
  28. data/spec/compiler/not_predicate_spec.rb +0 -52
  29. data/spec/compiler/occurrence_range_spec.rb +0 -186
  30. data/spec/compiler/one_or_more_spec.rb +0 -35
  31. data/spec/compiler/optional_spec.rb +0 -37
  32. data/spec/compiler/parenthesized_expression_spec.rb +0 -34
  33. data/spec/compiler/parsing_rule_spec.rb +0 -61
  34. data/spec/compiler/repeated_subrule_spec.rb +0 -29
  35. data/spec/compiler/semantic_predicate_spec.rb +0 -176
  36. data/spec/compiler/sequence_spec.rb +0 -129
  37. data/spec/compiler/terminal_spec.rb +0 -177
  38. data/spec/compiler/terminal_symbol_spec.rb +0 -40
  39. data/spec/compiler/test_grammar.treetop +0 -7
  40. data/spec/compiler/test_grammar.tt +0 -7
  41. data/spec/compiler/test_grammar_do.treetop +0 -7
  42. data/spec/compiler/test_grammar_magic_coding.treetop +0 -8
  43. data/spec/compiler/test_grammar_magic_encoding.treetop +0 -8
  44. data/spec/compiler/tt_compiler_spec.rb +0 -224
  45. data/spec/compiler/zero_or_more_spec.rb +0 -58
  46. data/spec/composition/a.treetop +0 -11
  47. data/spec/composition/b.treetop +0 -11
  48. data/spec/composition/c.treetop +0 -10
  49. data/spec/composition/d.treetop +0 -10
  50. data/spec/composition/f.treetop +0 -17
  51. data/spec/composition/grammar_composition_spec.rb +0 -40
  52. data/spec/composition/subfolder/e_includes_c.treetop +0 -15
  53. data/spec/ruby_extensions/string_spec.rb +0 -32
  54. data/spec/runtime/compiled_parser_spec.rb +0 -153
  55. data/spec/runtime/syntax_node_spec.rb +0 -77
  56. 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