Given a Source object, creates a Lexer for that source. A Lexer is a stateful stream generator in that every time it is advanced, it returns the next token in the Source. Assuming the source lexes, the final Token emitted by the lexer will be of kind EOF, after which the lexer will repeatedly return the same EOF token whenever called.

### Hierarchy

- Lexer

## Index

### Constructors

- constructor

### Properties

- lastToken
- line
- lineStart
- source
- token

### Methods

- advance
- lookahead

## Constructors

### constructor

- new Lexer(source: Source): Lexer

- - Defined in src/lexer.ts:38

  #### Parameters

  - ##### source: Source

  #### Returns Lexer

## Properties

### lastToken

lastToken: Token

- Defined in src/lexer.ts:23

The previously focused non-ignored token.

### line

line: number

- Defined in src/lexer.ts:33

The (1-indexed) line containing the current token.

### lineStart

lineStart: number

- Defined in src/lexer.ts:38

The character offset at which the current line begins.

### source

source: Source

- Defined in src/lexer.ts:18

### token

token: Token

- Defined in src/lexer.ts:28

The currently focused non-ignored token.

## Methods

### advance

- advance(): Token

- - Defined in src/lexer.ts:53

  Advances the token stream to the next non-ignored token.

  #### Returns Token

### lookahead

- lookahead(): Token

- - Defined in src/lexer.ts:63

  Looks ahead and returns the next non-ignored token, but does not change the state of Lexer.

  #### Returns Token

Generated using TypeDoc