Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
2d56448eaThis file is pinned to the selected release. Download the original to open it in your design tool.
import CodeLocation from "./CodeLocation";
import CodeSpan from "./CodeSpan";
import { ExtraToken, NewLineExtraToken } from "./extraTokens";
import TokenType from "./TokenType";
export default class Token {
/**
* All the newlines and comments that appear before this token and should be preserved when printing the AST.
*/
public extraTokens: ExtraToken[] = [];
/**
* Start of this token, including all the whitespace before it.
*
* Set externally in the lexer.
*/
public startWithWhitespace!: CodeLocation;
constructor(
public type: TokenType,
public span: CodeSpan,
public lexeme: string
) {}
toString(): string {
return `token ${TokenType[this.type]} ${this.span.toString()}`;
}
hasNewlineInExtraTokens() {
return this.extraTokens.some((t) => t instanceof NewLineExtraToken);
}
}