2019-11-30 03:24:13 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/** @typedef {import("./Compilation")} Compilation */
|
|
|
|
/** @typedef {import("./NormalModule")} NormalModule */
|
|
|
|
|
|
|
|
/** @typedef {Record<string, any>} PreparsedAst */
|
|
|
|
|
|
|
|
/**
|
2019-12-02 05:46:17 +08:00
|
|
|
* @typedef {Object} ParserStateBase
|
2019-11-30 03:24:13 +08:00
|
|
|
* @property {NormalModule} current
|
|
|
|
* @property {NormalModule} module
|
|
|
|
* @property {Compilation} compilation
|
2020-08-03 02:09:36 +08:00
|
|
|
* @property {{[k: string]: any}} options
|
2019-11-30 03:24:13 +08:00
|
|
|
*/
|
|
|
|
|
2019-12-02 05:46:17 +08:00
|
|
|
/** @typedef {Record<string, any> & ParserStateBase} ParserState */
|
|
|
|
|
2019-11-30 03:24:13 +08:00
|
|
|
class Parser {
|
2020-04-16 15:37:11 +08:00
|
|
|
/* istanbul ignore next */
|
2019-11-30 03:24:13 +08:00
|
|
|
/**
|
2020-04-16 15:37:11 +08:00
|
|
|
* @abstract
|
2019-11-30 03:24:13 +08:00
|
|
|
* @param {string | Buffer | PreparsedAst} source the source to parse
|
|
|
|
* @param {ParserState} state the parser state
|
|
|
|
* @returns {ParserState} the parser state
|
|
|
|
*/
|
|
|
|
parse(source, state) {
|
2020-04-16 15:37:11 +08:00
|
|
|
const AbstractMethodError = require("./AbstractMethodError");
|
2019-11-30 03:24:13 +08:00
|
|
|
throw new AbstractMethodError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Parser;
|