Parser.js 968 B

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