Flatten TokenType class hierarchy (#8537)
`KeywordTokenType` and `BinopTokenType` were just meant to be factory helpers, there's no reason for a class hierarchy.
This commit is contained in:
parent
5899940156
commit
524d847763
@ -66,18 +66,12 @@ export class TokenType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KeywordTokenType extends TokenType {
|
function KeywordTokenType(keyword: string, options: TokenOptions = {}) {
|
||||||
constructor(name: string, options: TokenOptions = {}) {
|
return new TokenType(keyword, { ...options, keyword });
|
||||||
options.keyword = name;
|
|
||||||
|
|
||||||
super(name, options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BinopTokenType extends TokenType {
|
function BinopTokenType(name: string, binop: number) {
|
||||||
constructor(name: string, prec: number) {
|
return new TokenType(name, { beforeExpr, binop });
|
||||||
super(name, { beforeExpr, binop: prec });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const types: { [name: string]: TokenType } = {
|
export const types: { [name: string]: TokenType } = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user