Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

source-parser.cjs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. const primitives_1 = require("../primitives.cjs");
  6. const util_1 = require("../util.cjs");
  7. function getParser({
  8. startLine = 0
  9. } = {}) {
  10. let block = null;
  11. let num = startLine;
  12. return function parseSource(source) {
  13. let rest = source;
  14. const tokens = util_1.seedTokens();
  15. [tokens.lineEnd, rest] = util_1.splitCR(rest);
  16. [tokens.start, rest] = util_1.splitSpace(rest);
  17. if (block === null && rest.startsWith(primitives_1.Markers.start) && !rest.startsWith(primitives_1.Markers.nostart)) {
  18. block = [];
  19. tokens.delimiter = rest.slice(0, primitives_1.Markers.start.length);
  20. rest = rest.slice(primitives_1.Markers.start.length);
  21. [tokens.postDelimiter, rest] = util_1.splitSpace(rest);
  22. }
  23. if (block === null) {
  24. num++;
  25. return null;
  26. }
  27. const isClosed = rest.trimRight().endsWith(primitives_1.Markers.end);
  28. if (tokens.delimiter === '' && rest.startsWith(primitives_1.Markers.delim) && !rest.startsWith(primitives_1.Markers.end)) {
  29. tokens.delimiter = primitives_1.Markers.delim;
  30. rest = rest.slice(primitives_1.Markers.delim.length);
  31. [tokens.postDelimiter, rest] = util_1.splitSpace(rest);
  32. }
  33. if (isClosed) {
  34. const trimmed = rest.trimRight();
  35. tokens.end = rest.slice(trimmed.length - primitives_1.Markers.end.length);
  36. rest = trimmed.slice(0, -primitives_1.Markers.end.length);
  37. }
  38. tokens.description = rest;
  39. block.push({
  40. number: num,
  41. source,
  42. tokens
  43. });
  44. num++;
  45. if (isClosed) {
  46. const result = block.slice();
  47. block = null;
  48. return result;
  49. }
  50. return null;
  51. };
  52. }
  53. exports.default = getParser;
  54. //# sourceMappingURL=source-parser.cjs.map