Home Reference Source Repository
import Token from 'perplex/lib/token.js'
public class | source

Token

Direct Subclass:

EOFToken

Represents a token instance

Constructor Summary

Public Constructor
public

constructor(type: T, match: string, groups: string[], start: number, end: number, lexer: Lexer<T>)

Constructs a token

Member Summary

Public Members
public

The string position where this match ends

public

Any RegExp groups that accrued during the match

public

lexer: Lexer<T>

The parent Lexer

public

The string that the lexer consumed to create this token

public

The string position where this match started

public

type: T

The token type

Method Summary

Public Methods
public
public

Returns the bounds of this token, each in {line, column} format

Public Constructors

public constructor(type: T, match: string, groups: string[], start: number, end: number, lexer: Lexer<T>) source

Constructs a token

Params:

NameTypeAttributeDescription
type T

The token type

match string

The string that the lexer consumed to create this token

groups string[]

Any RegExp groups that accrued during the match

start number

The string position where this match started

end number

The string position where this match ends

lexer Lexer<T>

The parent Lexer

Public Members

public end: number source

The string position where this match ends

public groups: string[] source

Any RegExp groups that accrued during the match

public lexer: Lexer<T> source

The parent Lexer

public match: string source

The string that the lexer consumed to create this token

public start: number source

The string position where this match started

public type: T source

The token type

Public Methods

public isEof(): boolean source

Return:

boolean

public strpos(): TokenPosition source

Returns the bounds of this token, each in {line, column} format

Return:

TokenPosition