Exception: Pione::Lang::ContextError

Inherits:
LangError
  • Object
show all
Defined in:
lib/pione/lang/lang-exception.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(declaration_or_context, context) ⇒ ContextError

Returns a new instance of ContextError.



26
27
28
29
# File 'lib/pione/lang/lang-exception.rb', line 26

def initialize(declaration_or_context, context)
  @obj = declaration_or_context
  @context = context
end

Instance Method Details

#context_typeObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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

#messageObject



50
51
52
53
54
# 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