UNPKG

930 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 {NormalModule} current
16 * @property {NormalModule} module
17 * @property {Compilation} compilation
18 * @property {{[k: string]: any}} options
19 */
20
21/** @typedef {Record<string, any> & ParserStateBase} ParserState */
22
23class Parser {
24 /* istanbul ignore next */
25 /**
26 * @abstract
27 * @param {string | Buffer | PreparsedAst} source the source to parse
28 * @param {ParserState} state the parser state
29 * @returns {ParserState} the parser state
30 */
31 parse(source, state) {
32 const AbstractMethodError = require("./AbstractMethodError");
33 throw new AbstractMethodError();
34 }
35}
36
37module.exports = Parser;