class Pione::Lang::ContextError

ContextError is raised when contexts have unacceptable elements or we try to composite different contexts.

Public Class Methods

new(declaration_or_context, context) click to toggle source
# File lib/pione/lang/lang-exception.rb, line 26
def initialize(declaration_or_context, context)
  @obj = declaration_or_context
  @context = context
end

Public Instance Methods

context_type() click to toggle source
# File lib/pione/lang/lang-exception.rb, line 31
def context_type
  case @context
  when ConditionalBranchContext
    "conditional branch context"
  when ParamContext
    "parameter context"
  when RuleConditionContext
    "rule condition contexxt"
  when FlowContext
    "flow context"
  when PackageContext
    "package context"
  when LiteralContext
    "literal context"
  else
    raise ArgumentError.new(self)
  end
end
message() click to toggle source
# File lib/pione/lang/lang-exception.rb, line 50
def message
  name = @obj.class.name
  pos = @obj.pos.format
  "%s is not acceptable for %s%s" % [name, context_type, pos]
end