atproto_sdl/tree

The parser’s intermediate tree: a near-literal shape of Lexicon SDL source, before lowering to atproto_lexicon/ast. It keeps SDL-only notions the target AST doesn’t have a slot for (union aliases, bare ! required markers separate from closed-union markers, the two throws spellings) so that lower can do the semantic work of mapping surface syntax onto the target’s def/property/item universes. parser produces this tree; lower consumes it.

Types

pub type Attr {
  Attr(name: String, args: List(AttrArg), span: token.Span)
}

Constructors

pub type AttrArg {
  Positional(value: AttrValue)
  Named(name: String, value: AttrValue)
}

Constructors

pub type AttrValue {
  AvString(value: String)
  AvInt(value: Int)
  AvBool(value: Bool)
  AvRef(path: RefPath)
}

Constructors

  • AvString(value: String)
  • AvInt(value: Int)
  • AvBool(value: Bool)
  • AvRef(path: RefPath)

An accepts/: <type> body-position type plus its trailing attributes (@encoding(...), @description(...)): the body clause’s own metadata, distinct from the surrounding def’s doc comment (e.g. a procedure’s own description vs. its input body’s description, both present independently in uploadCover.json).

pub type BodyClause {
  BodyClause(ty: SType, attrs: List(Attr))
}

Constructors

pub type Document {
  Document(
    description: option.Option(String),
    revision: option.Option(Int),
    items: List(Item),
  )
}

Constructors

pub type EnumMember {
  EmLiteral(value: String)
  EmRef(path: RefPath)
}

Constructors

  • EmLiteral(value: String)
  • EmRef(path: RefPath)
pub type ErrorMember {
  ErrorMember(docs: option.Option(String), name: String)
}

Constructors

pub type ErrorsClause {
  NoErrors
  ErrorsInline(names: List(String))
  ErrorsBlock(members: List(ErrorMember))
}

Constructors

  • NoErrors
  • ErrorsInline(names: List(String))
  • ErrorsBlock(members: List(ErrorMember))
pub type Field {
  Field(
    docs: option.Option(String),
    name: String,
    ty: SType,
    required: Bool,
    default: option.Option(AttrValue),
    attrs: List(Attr),
    span: token.Span,
  )
}

Constructors

pub type Item {
  IRecord(
    docs: option.Option(String),
    attrs: List(Attr),
    name: String,
    fields: List(Field),
    span: token.Span,
  )
  IObject(
    docs: option.Option(String),
    attrs: List(Attr),
    name: String,
    fields: List(Field),
    span: token.Span,
  )
  IScalarDef(
    docs: option.Option(String),
    attrs: List(Attr),
    name: String,
    ty: SType,
    span: token.Span,
  )
  IEnum(
    docs: option.Option(String),
    attrs: List(Attr),
    name: String,
    members: List(EnumMember),
    span: token.Span,
  )
  IUnionAlias(
    docs: option.Option(String),
    name: String,
    closed: Bool,
    members: List(RefPath),
    span: token.Span,
  )
  IToken(
    docs: option.Option(String),
    attrs: List(Attr),
    name: String,
    span: token.Span,
  )
  IQuery(
    docs: option.Option(String),
    attrs: List(Attr),
    name: String,
    params: List(Field),
    output: option.Option(BodyClause),
    errors: ErrorsClause,
    span: token.Span,
  )
  IProcedure(
    docs: option.Option(String),
    attrs: List(Attr),
    name: String,
    params: List(Field),
    accepts: option.Option(BodyClause),
    output: option.Option(BodyClause),
    errors: ErrorsClause,
    span: token.Span,
  )
  ISubscription(
    docs: option.Option(String),
    attrs: List(Attr),
    name: String,
    params: List(Field),
    message: option.Option(BodyClause),
    errors: ErrorsClause,
    span: token.Span,
  )
}

Constructors

pub type RefPath {
  RpLocal(name: String)
  RpDotted(
    segments: List(String),
    fragment: option.Option(String),
  )
}

Constructors

  • RpLocal(name: String)

    name or #name: resolved against local defs (and, failing that, the built-in scalar/format table) by lower.

  • RpDotted(segments: List(String), fragment: option.Option(String))

    a.b.c or a.b.c#frag: a dotted path, resolved against the compilation tree’s known documents by lower.

A type expression. Position restrictions the AST enforces (no inline objects in field/item position, no nested arrays, union members must be refs) are validated in lower, not here: the parser stays a uniform, permissive recursive-descent grammar.

pub type SType {
  TRef(path: RefPath, span: token.Span)
  TArray(item: SType, item_attrs: List(Attr), span: token.Span)
  TUnion(members: List(SType), closed: Bool, span: token.Span)
  TObject(fields: List(Field), span: token.Span)
}

Constructors

Values

pub fn sty_span(ty: SType) -> token.Span

The span of a type expression’s own leading token, regardless of which SType variant it is: shared by parser (union span propagation) and lower/fields (union-member error spans).

Search Document