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 {
|
||||
constructor(name: string, options: TokenOptions = {}) {
|
||||
options.keyword = name;
|
||||
|
||||
super(name, options);
|
||||
}
|
||||
function KeywordTokenType(keyword: string, options: TokenOptions = {}) {
|
||||
return new TokenType(keyword, { ...options, keyword });
|
||||
}
|
||||
|
||||
export class BinopTokenType extends TokenType {
|
||||
constructor(name: string, prec: number) {
|
||||
super(name, { beforeExpr, binop: prec });
|
||||
}
|
||||
function BinopTokenType(name: string, binop: number) {
|
||||
return new TokenType(name, { beforeExpr, binop });
|
||||
}
|
||||
|
||||
export const types: { [name: string]: TokenType } = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user