babel/src/parser/base.js
Daniel Tschinder fecdb6feeb Make tokens optional (#563)
Adding tokens to the ast is significant slower and most tools
don't ever use them anyway
2017-06-27 23:26:24 -04:00

31 lines
634 B
JavaScript

// @flow
import type { Options } from "../options";
import { reservedWords } from "../util/identifier";
import type State from "../tokenizer/state";
export default class BaseParser {
// Properties set by constructor in index.js
options: Options;
inModule: boolean;
plugins: { [key: string]: boolean };
filename: ?string;
// Initialized by Tokenizer
state: State;
input: string;
isReservedWord(word: string): boolean {
if (word === "await") {
return this.inModule;
} else {
return reservedWords[6](word);
}
}
hasPlugin(name: string): boolean {
return !!this.plugins[name];
}
}