caffeine_lang/frontend/ast

Types

A comment attached to an AST node.

pub type Comment {
  LineComment(text: String)
  SectionComment(text: String)
  DocComment(text: String)
}

Constructors

  • LineComment(text: String)
  • SectionComment(text: String)
  • DocComment(text: String)

    A ###-prefixed doc comment. When attached to an ExpectItem’s leading_comments, the text becomes the SLO description in the Datadog Terraform output.

A single expectation item with name, extends, and provides.

pub type ExpectItem {
  ExpectItem(
    name: String,
    extends: List(String),
    provides: Struct,
    leading_comments: List(Comment),
  )
}

Constructors

  • ExpectItem(
      name: String,
      extends: List(String),
      provides: Struct,
      leading_comments: List(Comment),
    )

A block of expectations for a measurement.

pub type ExpectsBlock {
  ExpectsBlock(
    measurement: option.Option(String),
    items: List(ExpectItem),
    leading_comments: List(Comment),
  )
}

Constructors

An expects file containing extendables and expects blocks. The phantom phase parameter tracks whether the file has been validated.

pub type ExpectsFile(phase) {
  ExpectsFile(
    extendables: List(Extendable),
    blocks: List(ExpectsBlock),
    trailing_comments: List(Comment),
  )
}

Constructors

An extendable block that can be inherited by measurements or expectations.

pub type Extendable {
  Extendable(
    name: String,
    kind: ExtendableKind,
    body: Struct,
    leading_comments: List(Comment),
  )
}

Constructors

The kind of extendable (Requires for types, Provides for values).

pub type ExtendableKind {
  ExtendableRequires
  ExtendableProvides
}

Constructors

  • ExtendableRequires
  • ExtendableProvides

A field with a name and value (either a type or a literal).

pub type Field {
  Field(
    name: String,
    value: Value,
    leading_comments: List(Comment),
  )
}

Constructors

  • Field(
      name: String,
      value: Value,
      leading_comments: List(Comment),
    )

Literal values.

pub type Literal {
  LiteralString(value: String)
  LiteralInteger(value: Int)
  LiteralFloat(value: Float)
  LiteralPercentage(value: Float)
  LiteralTrue
  LiteralFalse
  LiteralList(elements: List(Literal))
  LiteralStruct(
    fields: List(Field),
    trailing_comments: List(Comment),
  )
}

Constructors

  • LiteralString(value: String)
  • LiteralInteger(value: Int)
  • LiteralFloat(value: Float)
  • LiteralPercentage(value: Float)
  • LiteralTrue
  • LiteralFalse
  • LiteralList(elements: List(Literal))
  • LiteralStruct(
      fields: List(Field),
      trailing_comments: List(Comment),
    )

A single measurement item with name, extends, requires, and provides.

pub type MeasurementItem {
  MeasurementItem(
    name: String,
    extends: List(String),
    requires: Struct,
    provides: Struct,
    leading_comments: List(Comment),
  )
}

Constructors

  • MeasurementItem(
      name: String,
      extends: List(String),
      requires: Struct,
      provides: Struct,
      leading_comments: List(Comment),
    )

A measurements file containing type aliases, extendables, and measurement items. Type aliases must come before extendables, which must come before items. The phantom phase parameter tracks whether the file has been validated.

pub type MeasurementsFile(phase) {
  MeasurementsFile(
    type_aliases: List(TypeAlias),
    extendables: List(Extendable),
    items: List(MeasurementItem),
    trailing_comments: List(Comment),
  )
}

Constructors

Marker type for parsed (not yet validated) AST.

pub type Parsed

A struct containing a list of fields.

pub type Struct {
  Struct(fields: List(Field), trailing_comments: List(Comment))
}

Constructors

  • Struct(fields: List(Field), trailing_comments: List(Comment))

A type alias that defines a named, reusable refined type. Example: _env (Type): String { x | x in { prod, staging, dev } }

pub type TypeAlias {
  TypeAlias(
    name: String,
    type_: types.ParsedType,
    leading_comments: List(Comment),
  )
}

Constructors

Marker type for validated AST.

pub type Validated

A value in a field - either a type (in Requires) or a literal (in Provides).

pub type Value {
  TypeValue(type_: types.ParsedType)
  LiteralValue(literal: Literal)
}

Constructors

Search Document