Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Token

Hierarchy

Index

Constructors

constructor

  • new Token(image: string, offset: number, startLine: number, startColumn: number, endLine?: number, endColumn?: number): Token
  • Parameters

    • image: string

      the textual representation of the Token as it appeared in the text

    • offset: number

      offset of the first character of the Token

    • startLine: number

      line of the first character of the Token

    • startColumn: number

      column of the first character of the Token

    • Default value endLine: number = startLine

      line of the last character of the Token

    • Default value endColumn: number = startColumn + image.length - 1

      column of the last character of the Token

      Things to note:

      • "do" {startColumn : 1, endColumn: 2} --> the range is inclusive to exclusive 1...2 (2 chars long).
      • "\n" {startLine : 1, endLine: 1} --> a lineTerminator as the last character does not effect the Token's line numbering.
      • "'hello\tworld\uBBBB'" {image: "'hello\tworld\uBBBB'"} --> a Token's image is the "literal" text
                                                               (unicode escaping is untouched).
        

    Returns Token

Properties

endColumn

endColumn: number

column of the last character of the Token

Things to note: "do" {startColumn : 1, endColumn: 2} --> the range is inclusive to exclusive 1...2 (2 chars long). "\n" {startLine : 1, endLine: 1} --> a lineTerminator as the last character does not effect the Token's line numbering. "'hello\tworld\uBBBB'" {image: "'hello\tworld\uBBBB'"} --> a Token's image is the "literal" text (unicode escaping is untouched).

endLine

endLine: number

line of the last character of the Token

image

image: string

the textual representation of the Token as it appeared in the text

isInsertedInRecovery

isInsertedInRecovery: boolean

offset

offset: number

offset of the first character of the Token

startColumn

startColumn: number

column of the first character of the Token

startLine

startLine: number

line of the first character of the Token

Static LABEL

LABEL: string

A "human readable" Label for a Token. Subclasses of Token may define their own static LABEL property. This label will be used in error messages and drawing syntax diagrams.

For example a Token constructor may be called LCurly, which is short for LeftCurlyBrackets, These names are either too short or too unwieldy to be used in error messages.

Imagine : "expecting LCurly but found ')'" or "expecting LeftCurlyBrackets but found ')'"

However if a static property LABEL with the value '{' exists on LCurly class, that error message will be: "expecting '{' but found ')'"

Generated using TypeDoc