kaiseki 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/grammar.rb CHANGED
@@ -13,6 +13,10 @@ module Kaiseki
13
13
  instance_eval &block if block_given?
14
14
  end
15
15
 
16
+ def [] rule
17
+ GrammarStub.new @rules[rule], self
18
+ end
19
+
16
20
  def parse stream, options = {}
17
21
  ParseResult.new do
18
22
  parse! stream.to_stream, options
@@ -0,0 +1,20 @@
1
+ module Kaiseki
2
+ class GrammarStub < PackageParser
3
+ attr_reader :grammar
4
+
5
+ def initialize expected, grammar
6
+ super expected
7
+ @grammar = grammar
8
+ end
9
+
10
+ def parse! stream, options = {}
11
+ @expected.parse stream, options.merge(:grammar => @grammar)
12
+ end
13
+
14
+ def eql? other
15
+ other.is_a?(self.class) and other.expected == @expected and other.grammar == @grammar
16
+ end
17
+
18
+ alias :== :eql?
19
+ end
20
+ end
data/lib/kaiseki.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Kaiseki
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  file_path = File.dirname __FILE__
4
4
 
5
5
  #load basic kaiseki classes
@@ -45,6 +45,7 @@ module Kaiseki
45
45
 
46
46
  #load grammar classes
47
47
  require file_path + '/grammar'
48
+ require file_path + '/grammar_stub'
48
49
  require file_path + '/rule'
49
50
  require file_path + '/action'
50
51
 
data/lib/parser_repeat.rb CHANGED
@@ -14,7 +14,7 @@ module Kaiseki
14
14
  stream.lock do
15
15
  result = []
16
16
  count = 0
17
- while max.nil? or count < max
17
+ while max.nil? or count < @max
18
18
  begin
19
19
  catch :SkipSuccess do
20
20
  result << @expected.parse(stream, options)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 4
9
- version: 1.0.4
8
+ - 5
9
+ version: 1.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - William Hamilton-Levi
@@ -49,6 +49,7 @@ files:
49
49
  - lib/action.rb
50
50
  - lib/stream.rb
51
51
  - lib/var_insert.rb
52
+ - lib/grammar_stub.rb
52
53
  - lib/parser_sequence.rb
53
54
  - lib/mod_symbol.rb
54
55
  - lib/parser_eof.rb