Home Reference Source Test
import Lexer from 'botlang/src/Lexer/Lexer.js'
public class | source

Lexer

The botlang lexer takes an instance of Input as a constructor argument and produces a token stream for further processing in the parser.

Test:

Constructor Summary

Public Constructor
public

constructor(input: Input): void

Create a Lexer.

Method Summary

Public Methods
public

Determine whether or not the lexer has reached the input's eof

public

inputError(message: String): void

Throw a new Error.

public

next(): Token | null

Return the next token in from the input stream or null if the end of file has been reached

public

peek(): Token

Return the current token or get the first token if next has not been called yet.

Public Constructors

public constructor(input: Input): void source

Create a Lexer.

Params:

NameTypeAttributeDescription
input Input

Return:

void

Throw:

TypeError

Test:

Public Methods

public eof(): Boolean source

Determine whether or not the lexer has reached the input's eof

Return:

Boolean

public inputError(message: String): void source

Throw a new Error.

Params:

NameTypeAttributeDescription
message String

Return:

void

Throw:

Error

public next(): Token | null source

Return the next token in from the input stream or null if the end of file has been reached

Return:

Token | null

Test:

public peek(): Token source

Return the current token or get the first token if next has not been called yet.

Return:

Token

Test: