atproto_sdl/token

The token vocabulary produced by the lexer, plus a 1-indexed source Span. Structural keywords (record, type, enum, union, token, query, procedure, subscription, throws, accepts) and the boolean literals get their own variant; scalar type names (String, Blob, Cid, …) and def/field names are plain Ident tokens, disambiguated later by lower. Triple-slash /// doc comments become significant DocComment tokens; plain // comments are discarded by the lexer and never appear here.

Types

A source position: 1-indexed line and column, pointing at the first grapheme of the token it is attached to.

pub type Span {
  Span(line: Int, col: Int)
}

Constructors

  • Span(line: Int, col: Int)
pub type Token {
  KwRecord
  KwType
  KwEnum
  KwUnion
  KwToken
  KwQuery
  KwProcedure
  KwSubscription
  KwThrows
  KwAccepts
  KwTrue
  KwFalse
  Ident(name: String)
  StringLit(value: String)
  IntLit(value: Int)
  DocComment(text: String)
  Colon
  Comma
  Dot
  Hash
  Pipe
  Bang
  At
  Equals
  LBrace
  RBrace
  LBracket
  RBracket
  LParen
  RParen
  Eof
}

Constructors

  • KwRecord
  • KwType
  • KwEnum
  • KwUnion
  • KwToken
  • KwQuery
  • KwProcedure
  • KwSubscription
  • KwThrows
  • KwAccepts
  • KwTrue
  • KwFalse
  • Ident(name: String)
  • StringLit(value: String)
  • IntLit(value: Int)
  • DocComment(text: String)
  • Colon
  • Comma
  • Dot
  • Hash
  • Pipe
  • Bang
  • At
  • Equals
  • LBrace
  • RBrace
  • LBracket
  • RBracket
  • LParen
  • RParen
  • Eof

Values

pub fn to_string(token: Token) -> String

A human-readable rendering of a token, used in parse-error messages (the “found X” half). Mirrors the surface syntax the token came from.

Search Document