UNPKG

968 BJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8/** @typedef {import("./Compilation")} Compilation */
9/** @typedef {import("./NormalModule")} NormalModule */
10
11/** @typedef {Record<string, any>} PreparsedAst */
12
13/**
14 * @typedef {Object} ParserStateBase
15 * @property {string | Buffer} source
16 * @property {NormalModule} current
17 * @property {NormalModule} module
18 * @property {Compilation} compilation
19 * @property {{[k: string]: any}} options
20 */
21
22/** @typedef {Record<string, any> & ParserStateBase} ParserState */
23
24class Parser {
25 /* istanbul ignore next */
26 /**
27 * @abstract
28 * @param {string | Buffer | PreparsedAst} source the source to parse
29 * @param {ParserState} state the parser state
30 * @returns {ParserState} the parser state
31 */
32 parse(source, state) {
33 const AbstractMethodError = require("./AbstractMethodError");
34 throw new AbstractMethodError();
35 }
36}
37
38module.exports = Parser;