///|
/// Half-open UTF-16 source offset range `[start_offset, end_offset)`.
pub(all) struct SourceSpan {
  start_offset : Int
  end_offset : Int
} derive(Debug, Eq)

///|
/// Construct a source span. Validation belongs to the lexer/parser that owns
/// the source buffer.
pub fn SourceSpan::new(start_offset : Int, end_offset : Int) -> SourceSpan {
  { start_offset, end_offset }
}

///|
/// Processing phase that produced an XPath diagnostic.
pub(all) enum XPathPhase {
  Lex
  Parse
  Static
  Model
  Xml
  Evaluate
} derive(Debug, Eq)

///|
/// Public checked error shared by the compiler, document model and evaluator.
pub(all) suberror XPathError {
  Lex(span~ : SourceSpan, message~ : String)
  Parse(span~ : SourceSpan, message~ : String)
  Static(span~ : SourceSpan?, message~ : String)
  Model(message~ : String)
  Xml(message~ : String)
  Evaluate(span~ : SourceSpan?, message~ : String)
  LimitExceeded(phase~ : XPathPhase, limit~ : String)
} derive(Debug, Eq)