2017-05-28 21:06:09 -07:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
const createError = require("./parser-create-error");
|
|
|
|
|
|
|
|
|
|
function parse(text) {
|
|
|
|
|
// Inline the require to avoid loading all the JS if we don't use it
|
|
|
|
|
const flowParser = require("flow-parser");
|
|
|
|
|
|
|
|
|
|
const ast = flowParser.parse(text, {
|
|
|
|
|
esproposal_class_instance_fields: true,
|
|
|
|
|
esproposal_class_static_fields: true,
|
|
|
|
|
esproposal_export_star_as: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (ast.errors.length > 0) {
|
|
|
|
|
throw createError(
|
|
|
|
|
ast.errors[0].message,
|
|
|
|
|
ast.errors[0].loc.start.line,
|
2017-05-31 17:50:55 -07:00
|
|
|
ast.errors[0].loc.start.column + 1
|
2017-05-28 21:06:09 -07:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ast;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = parse;
|