module Omnium::Common

Constants

NIL_VALUE_TOKENS
PARAMETERISED_TOKENS
RESERVED_KEYWORDS
TOKENS
VALUE_BASED_TOKENS

Public Class Methods

define_token_predicate_method(type, value = nil) click to toggle source
# File lib/omnium/common.rb, line 53
def define_token_predicate_method(type, value = nil)
  define_method("#{type}?") do
    token_entity == type || (!value.nil? && token_entity == value)
  end
end
define_token_type_method(type) click to toggle source
# File lib/omnium/common.rb, line 59
def define_token_type_method(type)
  define_method("#{type}_token") { type }
end
token_entity() click to toggle source
# File lib/omnium/common.rb, line 43
def token_entity
  if instance_variable_defined?(:@character)
    @character # Lexer#character
  elsif instance_variable_defined?(:@token)
    @token&.type # Parser::Core#token
  elsif instance_variable_defined?(:@type)
    @type # Interpreter#type
  end
end

Private Instance Methods

define_token_predicate_method(type, value = nil) click to toggle source
# File lib/omnium/common.rb, line 53
def define_token_predicate_method(type, value = nil)
  define_method("#{type}?") do
    token_entity == type || (!value.nil? && token_entity == value)
  end
end
define_token_type_method(type) click to toggle source
# File lib/omnium/common.rb, line 59
def define_token_type_method(type)
  define_method("#{type}_token") { type }
end
token_entity() click to toggle source
# File lib/omnium/common.rb, line 43
def token_entity
  if instance_variable_defined?(:@character)
    @character # Lexer#character
  elsif instance_variable_defined?(:@token)
    @token&.type # Parser::Core#token
  elsif instance_variable_defined?(:@type)
    @type # Interpreter#type
  end
end