UNPKG

624 BJavaScriptView Raw
1
2
3import {augmentError, initParser, state} from "./traverser/base";
4import {parseFile} from "./traverser/index";
5
6export class File {
7
8
9
10 constructor(tokens, scopes) {
11 this.tokens = tokens;
12 this.scopes = scopes;
13 }
14}
15
16export function parse(
17 input,
18 isJSXEnabled,
19 isTypeScriptEnabled,
20 isFlowEnabled,
21) {
22 if (isFlowEnabled && isTypeScriptEnabled) {
23 throw new Error("Cannot combine flow and typescript plugins.");
24 }
25 initParser(input, isJSXEnabled, isTypeScriptEnabled, isFlowEnabled);
26 const result = parseFile();
27 if (state.error) {
28 throw augmentError(state.error);
29 }
30 return result;
31}