Skip to main content

Token

Represents a range of characters represented by a lexical token within a Source.

Index

Constructors

constructor

  • new Token(kind: TokenKind, start: number, end: number, line: number, column: number, value?: string): Token
  • Parameters

    • kind: TokenKind
    • start: number
    • end: number
    • line: number
    • column: number
    • optionalvalue: string

    Returns Token

Properties

readonlycolumn

column: number

The 1-indexed column number at which this Token begins.

readonlyend

end: number

The character offset at which this Node ends.

readonlykind

kind: TokenKind

The kind of Token.

readonlyline

line: number

The 1-indexed line number on which this Token appears.

readonlynext

next: null | Token

readonlyprev

prev: null | Token

Tokens exist as nodes in a double-linked-list amongst all tokens including ignored tokens.

<SOF>
is always the first node and
<EOF>
the last.

readonlystart

start: number

The character offset at which this Node begins.

readonlyvalue

value: string

For non-punctuation tokens, represents the interpreted value of the token.

Note: is undefined for punctuation tokens, but typed as string for convenience in the parser.

Accessors

[toStringTag]

  • get [toStringTag](): string
  • Returns string

Methods

toJSON

  • toJSON(): { column: number; kind: TokenKind; line: number; value?: string }
  • Returns { column: number; kind: TokenKind; line: number; value?: string }

    • column: number
    • kind: TokenKind
    • line: number
    • optionalvalue?: string