Class: Jade::Parsing::UnexpectedTokenError

Inherits:
Error
  • Object
show all
Defined in:
lib/jade/parsing/error.rb

Instance Attribute Summary

Attributes inherited from Error

#actual, #context, #expected

Attributes inherited from Error

#entry, #span

Instance Method Summary collapse

Methods inherited from Error

#commit, #committed?, #with_context

Methods inherited from Error

#candidates, #notes, #queried_name, #to_diagnostic

Constructor Details

#initialize(entry:, span:, actual:, expected:, committed: false, context: []) ⇒ UnexpectedTokenError

Returns a new instance of UnexpectedTokenError.



57
58
59
# File 'lib/jade/parsing/error.rb', line 57

def initialize(entry:, span:, actual:, expected:, committed: false, context: [])
  super
end

Instance Method Details

#hintObject



61
62
63
64
65
66
67
# File 'lib/jade/parsing/error.rb', line 61

def hint
  return leading_pipe_hint if leading_pipe_in_type_decl?
  return reserved_keyword_hint if reserved_keyword_as_name?
  return colon_not_eq_hint if eq_where_colon_expected?
  return record_eq_hint if eq_where_record_pipe_expected?
  nil
end

#labelObject



73
74
75
# File 'lib/jade/parsing/error.rb', line 73

def label
  "unexpected #{@actual.value.inspect}"
end

#messageObject



69
70
71
# File 'lib/jade/parsing/error.rb', line 69

def message
  "#{context_prefix}Unexpected token #{actual.value.inspect}, expected #{expected}#{" #{hint}" if hint}"
end