# Class Lexer

Represents a lexer that tokenizes input text. The Lexer takes the original expression string and returns an array of tokens parsed from that string. For example, the string "a + b" would result in tokens for a, +, and b.

- Defined in core/parser/lexer.js:40

#####
Index

### Constructors

constructor

### Properties

index
options
text
tokens

### Methods

codePointAt
handleUnicodeEscape
is
isExpOperator
isIdentifierContinue
isIdentifierStart
isNumber
isWhitespace
lex
peek
peekMultichar
readIdent
readNumber
readString
throwError

##
Constructors

### constructor

- new Lexer(options): Lexer

- Creates an instance of Lexer.

  #### Parameters

  - options: LexerOptions

    Lexer options.

  #### Returns Lexer

  - Defined in core/parser/lexer.js:45

##
Properties

### index

index: number

- Defined in core/parser/lexer.js:57

### options

options: LexerOptions

- Defined in core/parser/lexer.js:47

### text

text: string

- Defined in core/parser/lexer.js:56

### tokens

tokens: Token[]

- Defined in core/parser/lexer.js:59

##
Methods

### codePointAt

- codePointAt(ch): number

- Converts a character to its Unicode code point.

  #### Parameters

  - ch: string

    Character to convert.

  #### Returns number

  Unicode code point.

  - Defined in core/parser/lexer.js:178

### handleUnicodeEscape

- handleUnicodeEscape(): string

- #### Returns string

  - Defined in core/parser/lexer.js:337

### is

- is(ch, chars): boolean

- Checks if a character is contained in a set of characters.

  #### Parameters

  - ch: string

    Character to check.

  - chars: string

    Set of characters.

  #### Returns boolean

  True if character is in the set, false otherwise.

  - Defined in core/parser/lexer.js:108

### isExpOperator

- isExpOperator(ch): boolean

- Checks if a character is an exponent operator.

  #### Parameters

  - ch: string

    Character to check.

  #### Returns boolean

  True if character is an exponent operator, false otherwise.

  - Defined in core/parser/lexer.js:206

### isIdentifierContinue

- isIdentifierContinue(ch): boolean

- Checks if a character is a valid identifier continuation.

  #### Parameters

  - ch: string

    Character to check.

  #### Returns boolean

  True if character is a valid identifier continuation, false otherwise.

  - Defined in core/parser/lexer.js:163

### isIdentifierStart

- isIdentifierStart(ch): boolean

- Checks if a character is a valid identifier start.

  #### Parameters

  - ch: string

    Character to check.

  #### Returns boolean

  True if character is a valid identifier start, false otherwise.

  - Defined in core/parser/lexer.js:149

### isNumber

- isNumber(ch): boolean

- Checks if a character is a number.

  #### Parameters

  - ch: string

    Character to check.

  #### Returns boolean

  True if character is a number, false otherwise.

  - Defined in core/parser/lexer.js:129

### isWhitespace

- isWhitespace(ch): boolean

- Checks if a character is whitespace.

  #### Parameters

  - ch: string

    Character to check.

  #### Returns boolean

  True if character is whitespace, false otherwise.

  - Defined in core/parser/lexer.js:138

### lex

- lex(text): Token[]

- Tokenizes the input text.

  #### Parameters

  - text: string

    Input text to lex.

  #### Returns Token[]

  Array of tokens.

  - Defined in core/parser/lexer.js:55

### peek

- peek(i?): string | false

- Peeks at the next character in the text.

  #### Parameters

  - `Optional` i: number

    Number of characters to peek.

  #### Returns string | false

  Next character or false if end of text.

  - Defined in core/parser/lexer.js:117

### peekMultichar

- peekMultichar(): string

- Peeks at the next multicharacter sequence in the text.

  #### Returns string

  Next multicharacter sequence.

  - Defined in core/parser/lexer.js:187

### readIdent

- readIdent(): void

- Reads and tokenizes an identifier from the text.

  #### Returns void

  - Defined in core/parser/lexer.js:273

### readNumber

- readNumber(): void

- Reads and tokenizes a number from the text.

  #### Returns void

  - Defined in core/parser/lexer.js:232

### readString

- readString(quote): void

- Reads and tokenizes a string from the text.

  #### Parameters

  - quote: string

    Quote character used for the string.

  #### Returns void

  - Defined in core/parser/lexer.js:294

### throwError

- throwError(error, start?, end?): void

- Throws a lexer error.

  #### Parameters

  - error: string

    Error message.

  - `Optional` start: number

    Start index.

  - `Optional` end: number

    End index.

  #### Returns void

  #### Throws

  Lexer error.

  - Defined in core/parser/lexer.js:217