Sha256: 874596aa19b202ba1a2a484105f10531c44bbb08c2036a2e422966beace076fc

Contents?: true

Size: 1.11 KB

Versions: 105

Compression:

Stored size: 1.11 KB

Contents

require 'bel_parser/parsers/ast/node'

module BELParser
  module Language
    module Syntax
      # InvalidFunction represents a syntax error with invalid function name
      # according to a BEL specification.
      class InvalidFunction
        include SyntaxFunction

        private_class_method :new

        def self.map(func_node, spec, _namespaces)
          return nil unless func_node.is_a?(BELParser::Parsers::AST::Function)

          function_name = func_node.identifier.string_literal
          unless spec.function(function_name.to_sym)
            InvalidFunctionSyntaxError.new(func_node, spec, function_name)
          end
        end
      end

      # InvalidFunctionSyntaxError indicates a function name was invalid.
      class InvalidFunctionSyntaxError < SyntaxError
        # Gets the invalid function literal.
        attr_reader :invalid_function

        def initialize(function, spec, invalid_function)
          super(function, spec)
          @invalid_function = invalid_function
        end

        def msg
          %(Invalid function "#{invalid_function}".)
        end
      end
    end
  end
end

Version data entries

105 entries across 105 versions & 1 rubygems

Version Path
bel_parser-1.0.0.alpha.60-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.60 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.59-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.59 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.58-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.58 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.57-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.57 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.56-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.56 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.55-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.55 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.54-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.54 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.53-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.53 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.52-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.52 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.51-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.51 lib/bel_parser/language/syntax/invalid_function.rb