vxml/blame

Source provenance for VXML trees.

Blame values attach origin information to VXML nodes, attributes, and lines. Source blame can be movable or anchored, which lets parsers and transformation pipelines preserve useful locations while slicing or moving text.

Types

Provenance for a VXML node, attribute, or line.

pub type Blame {
  Src(
    comments: List(String),
    path: String,
    line_no: Int,
    char_no: Int,
    cursor: SourceCursor,
  )
  Des(comments: List(String), name: String, line_no: Int)
  Ext(comments: List(String), name: String)
  NoBlame(comments: List(String))
}

Constructors

  • Src(
      comments: List(String),
      path: String,
      line_no: Int,
      char_no: Int,
      cursor: SourceCursor,
    )
  • Des(comments: List(String), name: String, line_no: Int)
  • Ext(comments: List(String), name: String)
  • NoBlame(comments: List(String))

Minimum and maximum widths for one optional blame-table margin.

pub type BlameTableMarginColumnsMinMax {
  BlameTableMarginColumnsMinMax(min: Int, max: Int)
}

Constructors

  • BlameTableMarginColumnsMinMax(min: Int, max: Int)

    Constrains a table margin column. A maximum of zero suppresses the column entirely.

Whether a source position can move when text is sliced or shifted.

pub type SourceCursor {
  Movable
  Anchored
}

Constructors

  • Movable
  • Anchored

Values

pub fn advance(blame: Blame, by: Int) -> Blame

Advance movable source blame by a character offset.

pub fn append_comment(blame: Blame, comment: String) -> Blame

Adds a comment after existing blame comments.

pub fn blame_digest(blame: Blame) -> String

Render a short human-readable blame label.

pub fn blamed_strings_annotated_table(
  lines: List(#(Blame, String)),
  banner: String,
  blame_digest_margin: BlameTableMarginColumnsMinMax,
  comments_margin: BlameTableMarginColumnsMinMax,
) -> List(String)

Renders blamed strings as lines of a provenance-annotated table.

A margin whose maximum is zero is omitted. banner labels the content column.

pub fn clear_comments(blame: Blame) -> Blame

Remove comments while preserving the main blame identity.

pub fn comments_digest(blame: Blame) -> String

Renders blame comments as a compact bracketed list.

pub const no_blame: Blame

A blame value with no provenance or comments.

pub fn path_contains(blame: Blame, s: String) -> Bool

Returns whether source blame has a path containing the given substring.

pub fn prepend_comment(blame: Blame, comment: String) -> Blame

Add a comment before existing blame comments.

pub fn set_anchored(blame: Blame) -> Blame

Mark source blame as anchored.

Search Document