Sha256: 81b16ceca0fc4ea85c7be830ef826b32437eb4a3fe8233dc89a85f5a138a5935

Contents?: true

Size: 1.62 KB

Versions: 21

Compression:

Stored size: 1.62 KB

Contents

module ActiveFacts
  module CQL
    class Parser
      class TermNode < Treetop::Runtime::SyntaxNode
        def ast quantifier = nil, function_call = nil, role_name = nil, value_constraint = nil, literal = nil, nested_clauses = nil
          t = x.context[:term]
          gt = x.context[:global_term]
          if t.size > gt.size and t[-gt.size..-1] == gt
            leading_adjective = t[0...-gt.size-1]
            leading_adjective.sub!(/ /, '-') if !tail.elements[0].dbl.empty?
          end
          if t.size > gt.size and t[0...gt.size] == gt
            trailing_adjective = t[gt.size+1..-1]
            trailing_adjective.sub!(/ (\S*)\Z/, '-\1') if !tail.elements[-1].dbl.empty?
          end
          Compiler::Reference.new(gt, leading_adjective, trailing_adjective, quantifier, function_call, role_name, value_constraint, literal, nested_clauses)
        end

        def value             # Sometimes we just want the full term name
          x.context[:term]
        end

        def node_type
          :term
        end
      end

      class TermLANode < TermNode
        def ast quantifier = nil, function_call = nil, role_name = nil, value_constraint = nil, literal = nil, nested_clauses = nil
          ast = term.ast(quantifier, function_call, role_name, value_constraint, literal, nested_clauses)
          ast.leading_adjective = head.text_value
          ast
        end
      end

      class TermDefinitionNameNode < TermNode
        def value
          t.elements.inject([
            id.value
          ]){|a, e| a << e.id.value}*' '
        end

        def node_type
          :term
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
activefacts-cql-1.9.3 lib/activefacts/cql/parser/nodes.rb
activefacts-cql-1.9.2 lib/activefacts/cql/parser/nodes.rb
activefacts-cql-1.9.1 lib/activefacts/cql/parser/nodes.rb
activefacts-cql-1.8.3 lib/activefacts/cql/parser/nodes.rb
activefacts-cql-1.8.2 lib/activefacts/cql/parser/nodes.rb
activefacts-cql-1.8.1 lib/activefacts/cql/parser/nodes.rb
activefacts-cql-1.8.0 lib/activefacts/cql/parser/nodes.rb
activefacts-cql-1.7.1 lib/activefacts/cql/parser/nodes.rb
activefacts-1.6.0 lib/activefacts/cql/nodes.rb
activefacts-1.5.3 lib/activefacts/cql/nodes.rb
activefacts-1.5.2 lib/activefacts/cql/nodes.rb
activefacts-1.5.1 lib/activefacts/cql/nodes.rb
activefacts-1.5.0 lib/activefacts/cql/nodes.rb
activefacts-1.3.0 lib/activefacts/cql/nodes.rb
activefacts-1.2.1 lib/activefacts/cql/nodes.rb
activefacts-1.2.0 lib/activefacts/cql/nodes.rb
activefacts-1.1.0 lib/activefacts/cql/nodes.rb
activefacts-1.0.2 lib/activefacts/cql/nodes.rb
activefacts-1.0.1 lib/activefacts/cql/nodes.rb
activefacts-1.0.0 lib/activefacts/cql/nodes.rb