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.8-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.8 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.7-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.7 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.6-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.6 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.5-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.5 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.4-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.4 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.3-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.3 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.2-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.2 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.1-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.1 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0 lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.61-java lib/bel_parser/language/syntax/invalid_function.rb
bel_parser-1.0.0.alpha.61 lib/bel_parser/language/syntax/invalid_function.rb