Aether.Token (Ichor v0.2.0)

Copy Markdown View Source

A single lexical token produced by Aether.Lexer from .aether source text.

This is Ichor's own front-end scanning a grammar-description file, not to be confused with the "tokens" a user's Aether grammar itself declares (ALL_UPPERCASE productions) -- those become Aether.Token{type: :upper_ident} values here, same as any other identifier.

Summary

Types

case_flag()

@type case_flag() :: :default | :insensitive | :sensitive

char_class_value()

@type char_class_value() :: %{negate: boolean(), items: [class_item()]}

class_item()

@type class_item() ::
  {:range, first :: non_neg_integer(), last :: non_neg_integer()}
  | {:char, non_neg_integer()}
  | {:posix, :alpha | :alnum | :digit | :space | :hex}

string_value()

@type string_value() :: %{text: String.t(), case: case_flag()}

t()

@type t() :: %Aether.Token{
  column: pos_integer(),
  line: pos_integer(),
  type: type(),
  value: value()
}

type()

@type type() ::
  :at_grammar
  | :at_root
  | :at_skip
  | :at_noskip
  | :at_case_insensitive
  | :at_indent
  | :at_samecol
  | :at_native
  | :at_hint
  | :at_keywords
  | :at_refine
  | :define
  | :arrow
  | :pipe
  | :star
  | :plus
  | :question
  | :lbrace
  | :rbrace
  | :comma
  | :amp
  | :bang
  | :colon
  | :lparen
  | :rparen
  | :tilde
  | :dot
  | :upper_ident
  | :lower_ident
  | :string
  | :char_class
  | :regex
  | :number
  | :eof

value()

@type value() :: String.t() | integer() | string_value() | char_class_value() | nil