Sha256: 4813e6ac0f3369952c7b1fd11802ec16457aef0323c1ae16df3e9f37cf6ccae5

Contents?: true

Size: 1.43 KB

Versions: 262

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

module ParsingRuleSpec
  describe "a grammar with one parsing rule" do

    testing_grammar %{
      grammar Foo
        rule bar
          "baz"
        end
      end
    }

    it "stores and retrieves nodes in its node cache" do
      parser = self.class.const_get(:FooParser).new
      parser.send(:prepare_to_parse, 'baz')
      node_cache = parser.send(:node_cache)
    
      node_cache[:bar][0].should be_nil
    
      parser._nt_bar
    
      cached_node = node_cache[:bar][0]        
      cached_node.should be_an_instance_of(Runtime::SyntaxNode)
      cached_node.text_value.should == 'baz'
    
      parser.instance_eval { @index = 0 }
      parser._nt_bar.should equal(cached_node)
      parser.index.should == cached_node.interval.end
    end
  end
  
  
  describe "a grammar with choice that uses the cache and has a subsequent expression" do    
    testing_grammar %{
      grammar Logic
        rule expression
          value_plus
          /
          value
        end

        rule value_plus
          value "something else"
        end

        rule value
          [a-z]
          /
          "foobar" # the subsequent expression that needs cached.interval.end
        end
      end
    }
    
    it "parses a single-character value and generates a node from the cache" do
      result = parse('a')
      result.should be_a(Treetop::Runtime::SyntaxNode)
      result.elements.should be_nil
    end
  end
end

Version data entries

262 entries across 217 versions & 32 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/spec/compiler/parsing_rule_spec.rb