Parser.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
  7. /** @typedef {import("./Compilation")} Compilation */
  8. /** @typedef {import("./NormalModule")} NormalModule */
  9. /** @typedef {Record<string, EXPECTED_ANY>} PreparsedAst */
  10. /**
  11. * Defines the parser state base type used by this module.
  12. * @typedef {object} ParserStateBase
  13. * @property {string | Buffer} source
  14. * @property {NormalModule} current
  15. * @property {NormalModule} module
  16. * @property {Compilation} compilation
  17. * @property {WebpackOptions} options
  18. */
  19. /** @typedef {ParserStateBase & Record<string, EXPECTED_ANY>} ParserState */
  20. class Parser {
  21. /* istanbul ignore next */
  22. /**
  23. * Parses the provided source and updates the parser state.
  24. * @abstract
  25. * @param {string | Buffer | PreparsedAst} source the source to parse
  26. * @param {ParserState} state the parser state
  27. * @returns {ParserState} the parser state
  28. */
  29. parse(source, state) {
  30. const AbstractMethodError = require("./AbstractMethodError");
  31. throw new AbstractMethodError();
  32. }
  33. }
  34. module.exports = Parser;