Skip to content

Commit f36ca25

Browse files
Lexer: remove passthrough options (#2209)
1 parent 5eb7c4d commit f36ca25

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

src/language/lexer.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@ import { type TokenKindEnum, TokenKind } from './tokenKind';
1717
* EOF, after which the lexer will repeatedly return the same EOF token
1818
* whenever called.
1919
*/
20-
export function createLexer<TOptions>(
21-
source: Source,
22-
options: TOptions,
23-
): Lexer<TOptions> {
20+
export function createLexer(source: Source): Lexer {
2421
const startOfFileToken = new Tok(TokenKind.SOF, 0, 0, 0, 0, null);
25-
const lexer: Lexer<TOptions> = {
22+
const lexer: Lexer = {
2623
source,
27-
options,
2824
lastToken: startOfFileToken,
2925
token: startOfFileToken,
3026
line: 1,
@@ -55,9 +51,8 @@ function lookahead() {
5551
/**
5652
* The return type of createLexer.
5753
*/
58-
export type Lexer<TOptions> = {
54+
export type Lexer = {
5955
source: Source,
60-
options: TOptions,
6156

6257
/**
6358
* The previously focused non-ignored token.
@@ -167,7 +162,7 @@ function printCharCode(code) {
167162
* punctuators immediately or calls the appropriate helper function for more
168163
* complicated tokens.
169164
*/
170-
function readToken(lexer: Lexer<mixed>, prev: Token): Token {
165+
function readToken(lexer: Lexer, prev: Token): Token {
171166
const source = lexer.source;
172167
const body = source.body;
173168
const bodyLength = body.length;
@@ -334,7 +329,7 @@ function unexpectedCharacterMessage(code) {
334329
function positionAfterWhitespace(
335330
body: string,
336331
startPosition: number,
337-
lexer: Lexer<mixed>,
332+
lexer: Lexer,
338333
): number {
339334
const bodyLength = body.length;
340335
let position = startPosition;

src/language/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export function parseType(
168168

169169
class Parser {
170170
_options: ParseOptions;
171-
_lexer: Lexer<void>;
171+
_lexer: Lexer;
172172

173173
constructor(source: string | Source, options?: ParseOptions) {
174174
const sourceObj = typeof source === 'string' ? new Source(source) : source;

tstypes/language/lexer.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ import { Source } from './source';
1010
* EOF, after which the lexer will repeatedly return the same EOF token
1111
* whenever called.
1212
*/
13-
export function createLexer<TOptions>(
14-
source: Source,
15-
options: TOptions,
16-
): Lexer<TOptions>;
13+
export function createLexer(source: Source): Lexer;
1714

1815
/**
1916
* The return type of createLexer.
2017
*/
21-
export interface Lexer<TOptions> {
18+
export interface Lexer {
2219
source: Source;
23-
options: TOptions;
2420

2521
/**
2622
* The previously focused non-ignored token.

0 commit comments

Comments
 (0)