test.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (C) 2024 Puter Technologies Inc.
  3. *
  4. * This file is part of Phoenix Shell.
  5. *
  6. * Phoenix Shell is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published
  8. * by the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. import {
  20. StringPStratumImpl,
  21. StrataParser,
  22. ParserFactory,
  23. } from 'strataparse';
  24. import { buildParserFirstHalf } from './src/ansi-shell/parsing/buildParserFirstHalf.js';
  25. import { buildParserSecondHalf } from './src/ansi-shell/parsing/buildParserSecondHalf.js';
  26. const sp = new StrataParser();
  27. const cstParserFac = new ParserFactory()
  28. cstParserFac.concrete = true;
  29. cstParserFac.rememberSource = true;
  30. sp.add(
  31. new StringPStratumImpl(`
  32. ls | tail -n 2 "ab" > "te\\"st"
  33. `)
  34. );
  35. // buildParserFirstHalf(sp, 'syntaxHighlighting');
  36. buildParserFirstHalf(sp, 'interpreting');
  37. buildParserSecondHalf(sp);
  38. const result = sp.parse();
  39. console.log(result && JSON.stringify(result, undefined, ' '));
  40. if ( sp.error ) {
  41. console.log('has error:', sp.error);
  42. }