bel_parser 1.0.0.alpha.30-java → 1.0.0.alpha.31-java
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.
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: fa04261c4ab5fb7567aa559b39547ce55587533b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 40cb25e2563b4e0e58c1ab45859c176a4dd7ac2e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 761629499e9952307150811a2f6a3339913c6341f0fd74b52cabde34db19212f06d64ddf18d7e9cec6f55b42864804358699c142ed66373f2f649f1c7cb4df8a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f445020c91a30361c321b8ae470642e77572dfab288b2cfe5697fbb5b1c7fa2ede02dff7cedf4aaf49656a7ad35818b18ca2e195856438b482cb3dc704e70fd2
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            1.0.0.alpha. 
     | 
| 
      
 1 
     | 
    
         
            +
            1.0.0.alpha.31
         
     | 
| 
         @@ -8,7 +8,7 @@ module BELParser 
     | 
|
| 
       8 
8 
     | 
    
         
             
                    include BELParser::Quoting
         
     | 
| 
       9 
9 
     | 
    
         
             
                    include Comparable
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                     
     | 
| 
      
 11 
     | 
    
         
            +
                    attr_reader :namespace, :value
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                    def initialize(namespace, value)
         
     | 
| 
       14 
14 
     | 
    
         
             
                      raise(ArgumentError, 'value is nil') unless value
         
     | 
| 
         @@ -21,6 +21,22 @@ module BELParser 
     | 
|
| 
       21 
21 
     | 
    
         
             
                      @value     = value
         
     | 
| 
       22 
22 
     | 
    
         
             
                    end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
      
 24 
     | 
    
         
            +
                    def namespace=(namespace)
         
     | 
| 
      
 25 
     | 
    
         
            +
                      unless namespace.nil? || namespace.is_a?(Namespace)
         
     | 
| 
      
 26 
     | 
    
         
            +
                        raise(
         
     | 
| 
      
 27 
     | 
    
         
            +
                          ArgumentError,
         
     | 
| 
      
 28 
     | 
    
         
            +
                          "namespace: expected nil or Namespace, actual #{namespace.class}")
         
     | 
| 
      
 29 
     | 
    
         
            +
                      end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                      @namespace = namespace
         
     | 
| 
      
 32 
     | 
    
         
            +
                    end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    def value=(value)
         
     | 
| 
      
 35 
     | 
    
         
            +
                      raise(ArgumentError, 'value is nil') unless value
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                      @value = value
         
     | 
| 
      
 38 
     | 
    
         
            +
                    end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
       24 
40 
     | 
    
         
             
                    def encoding
         
     | 
| 
       25 
41 
     | 
    
         
             
                      nsv = @namespace[@value]
         
     | 
| 
       26 
42 
     | 
    
         
             
                      return nil unless nsv
         
     | 
| 
         @@ -72,7 +88,7 @@ module BELParser 
     | 
|
| 
       72 
88 
     | 
    
         
             
                      namespace =
         
     | 
| 
       73 
89 
     | 
    
         
             
                        if prefix.identifier
         
     | 
| 
       74 
90 
     | 
    
         
             
                          keyword = prefix.identifier.string_literal
         
     | 
| 
       75 
     | 
    
         
            -
                          namespace_hash[keyword]
         
     | 
| 
      
 91 
     | 
    
         
            +
                          Namespace.new(keyword, namespace_hash[keyword])
         
     | 
| 
       76 
92 
     | 
    
         
             
                        else
         
     | 
| 
       77 
93 
     | 
    
         
             
                          nil
         
     | 
| 
       78 
94 
     | 
    
         
             
                        end
         
     | 
| 
         @@ -6,19 +6,36 @@ module BELParser 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  class Term
         
     | 
| 
       7 
7 
     | 
    
         
             
                    include Comparable
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                     
     | 
| 
      
 9 
     | 
    
         
            +
                    attr_reader :function, :arguments
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
                    def initialize(function, *arguments)
         
     | 
| 
      
 12 
     | 
    
         
            +
                      self.function  = function
         
     | 
| 
      
 13 
     | 
    
         
            +
                      self.arguments = arguments
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    def function=(function)
         
     | 
| 
       12 
17 
     | 
    
         
             
                      unless function && function.is_a?(BELParser::Language::Function)
         
     | 
| 
       13 
18 
     | 
    
         
             
                        raise(
         
     | 
| 
       14 
19 
     | 
    
         
             
                          ArgumentError,
         
     | 
| 
       15 
20 
     | 
    
         
             
                          %(function: expected Function, actual #{function.class}))
         
     | 
| 
       16 
21 
     | 
    
         
             
                      end
         
     | 
| 
       17 
22 
     | 
    
         
             
                      @function  = function
         
     | 
| 
       18 
     | 
    
         
            -
                      @arguments = (arguments ||= []).flatten
         
     | 
| 
       19 
23 
     | 
    
         
             
                    end
         
     | 
| 
       20 
24 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                    def  
     | 
| 
      
 25 
     | 
    
         
            +
                    def arguments=(*args)
         
     | 
| 
      
 26 
     | 
    
         
            +
                      args    = (args ||= []).flatten
         
     | 
| 
      
 27 
     | 
    
         
            +
                      invalid = args.any?(&method(:invalid_argument?))
         
     | 
| 
      
 28 
     | 
    
         
            +
                      raise(
         
     | 
| 
      
 29 
     | 
    
         
            +
                        ArgumentError,
         
     | 
| 
      
 30 
     | 
    
         
            +
                        'args must be Parameter or Term objects') if invalid
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                      @arguments = args
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    def <<(arg)
         
     | 
| 
      
 36 
     | 
    
         
            +
                        raise(
         
     | 
| 
      
 37 
     | 
    
         
            +
                          ArgumentError,
         
     | 
| 
      
 38 
     | 
    
         
            +
                          'argument must be Parameter or Term') if invalid_argument?(arg)
         
     | 
| 
       22 
39 
     | 
    
         
             
                      @arguments << item
         
     | 
| 
       23 
40 
     | 
    
         
             
                    end
         
     | 
| 
       24 
41 
     | 
    
         | 
| 
         @@ -47,6 +64,13 @@ module BELParser 
     | 
|
| 
       47 
64 
     | 
    
         
             
                        nil
         
     | 
| 
       48 
65 
     | 
    
         
             
                      end
         
     | 
| 
       49 
66 
     | 
    
         
             
                    end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                    private
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                    def invalid_argument?(arg)
         
     | 
| 
      
 71 
     | 
    
         
            +
                      !arg.is_a?(BELParser::Expression::Model::Parameter) &&
         
     | 
| 
      
 72 
     | 
    
         
            +
                        !arg.is_a?(BELParser::Expression::Model::Term)
         
     | 
| 
      
 73 
     | 
    
         
            +
                    end
         
     | 
| 
       50 
74 
     | 
    
         
             
                  end
         
     | 
| 
       51 
75 
     | 
    
         | 
| 
       52 
76 
     | 
    
         
             
                  module Converters
         
     | 
| 
         @@ -90,4 +114,3 @@ module BELParser 
     | 
|
| 
       90 
114 
     | 
    
         
             
                end
         
     | 
| 
       91 
115 
     | 
    
         
             
              end
         
     | 
| 
       92 
116 
     | 
    
         
             
            end
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
         @@ -65,10 +65,12 @@ module BELParser 
     | 
|
| 
       65 
65 
     | 
    
         
             
                  def parse
         
     | 
| 
       66 
66 
     | 
    
         
             
                    case @input
         
     | 
| 
       67 
67 
     | 
    
         
             
                    when ::String # conflicts with ...AST::String
         
     | 
| 
      
 68 
     | 
    
         
            +
                      results = parse_string(@input, @filter)
         
     | 
| 
      
 69 
     | 
    
         
            +
                      return nil if results.nil?
         
     | 
| 
       68 
70 
     | 
    
         
             
                      convert_ast(
         
     | 
| 
       69 
71 
     | 
    
         
             
                        @spec,
         
     | 
| 
       70 
72 
     | 
    
         
             
                        @namespaces,
         
     | 
| 
       71 
     | 
    
         
            -
                         
     | 
| 
      
 73 
     | 
    
         
            +
                        results.first)
         
     | 
| 
       72 
74 
     | 
    
         
             
                    when Array
         
     | 
| 
       73 
75 
     | 
    
         
             
                      convert_multiple(
         
     | 
| 
       74 
76 
     | 
    
         
             
                        parse_array(@input, @filter),
         
     |