refactor: combine parsely and strataparse into @heyputer/parsers

This commit is contained in:
KernelDeimos 2024-12-06 15:08:23 -05:00
parent 62a010b1b2
commit c87db23faa
28 changed files with 57 additions and 22 deletions

15
package-lock.json generated
View File

@ -2487,8 +2487,8 @@
"form-data": "^4.0.0"
}
},
"node_modules/@heyputer/parsely": {
"resolved": "src/parsely",
"node_modules/@heyputer/parsers": {
"resolved": "src/parsers",
"link": true
},
"node_modules/@heyputer/phoenix": {
@ -15512,10 +15512,6 @@
"node": ">= 0.8"
}
},
"node_modules/strataparse": {
"resolved": "src/strataparse",
"link": true
},
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
@ -17389,6 +17385,12 @@
"src/parsely": {
"name": "@heyputer/parsely",
"version": "1.0.0",
"extraneous": true,
"license": "AGPL-3.0-only"
},
"src/parsers": {
"name": "@heyputer/parsers",
"version": "1.0.0",
"license": "AGPL-3.0-only"
},
"src/phoenix": {
@ -17494,6 +17496,7 @@
},
"src/strataparse": {
"version": "0.0.0",
"extraneous": true,
"license": "AGPL-3.0-only"
},
"src/terminal": {

5
src/parsers/exports.js Normal file
View File

@ -0,0 +1,5 @@
import * as strataparse_ from './strataparse/exports.js';
import * as parsely_ from './parsely/exports.js';
export const strataparse = strataparse_;
export const parsely = parsely_;

View File

@ -1,5 +1,5 @@
{
"name": "@heyputer/parsely",
"name": "@heyputer/parsers",
"version": "1.0.0",
"author": "Puter Technologies Inc.",
"license": "AGPL-3.0-only",

View File

@ -16,10 +16,19 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { adapt_parser, VALUE } from './parser.js';
import * as parserjs from './parser.js';
import * as streamsjs from './streams.js';
import { Discard, FirstMatch, Optional, Repeat, Sequence } from './parsers/combinators.js';
import { Fail, Literal, None, StringOf, StringUntil, Symbol } from './parsers/terminals.js';
export const adapt_parser = parserjs.adapt_parser;
export const Parser = parserjs.Parser;
export const UNRECOGNIZED = parserjs.UNRECOGNIZED;
export const INVALID = parserjs.INVALID;
export const VALUE = parserjs.VALUE;
export const streams = streamsjs;
class ParserWithAction {
#parser;
#action;

View File

@ -29,6 +29,10 @@ import WhitespaceParserImpl from './parse_impls/whitespace.js';
import LiteralParserImpl from './parse_impls/literal.js';
import StrUntilParserImpl from './parse_impls/StrUntilParserImpl.js';
export {
MergeWhitespacePStratumImpl,
} from './strata_impls/MergeWhitespacePStratumImpl.js'
import {
SequenceParserImpl,
ChoiceParserImpl,

View File

@ -16,7 +16,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { StrataParser, StringPStratumImpl } from "strataparse";
import { strataparse } from '@heyputer/parsers';
const { StrataParser, StringPStratumImpl } = strataparse;
import { buildParserFirstHalf } from "./buildParserFirstHalf.js";
import { buildParserSecondHalf } from "./buildParserSecondHalf.js";

View File

@ -16,11 +16,20 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { FirstRecognizedPStratumImpl, ParserBuilder, ParserFactory, StrUntilParserImpl, StrataParseFacade, WhitespaceParserImpl } from "strataparse";
import { UnquotedTokenParserImpl } from "./UnquotedTokenParserImpl.js";
import { strataparse } from '@heyputer/parsers';
const {
ParserBuilder,
ParserFactory,
StrUntilParserImpl,
StrataParseFacade,
WhitespaceParserImpl
} = strataparse;
import { PARSE_CONSTANTS } from "./PARSE_CONSTANTS.js";
import { MergeWhitespacePStratumImpl } from "strataparse/strata_impls/MergeWhitespacePStratumImpl.js";
import ContextSwitchingPStratumImpl from "strataparse/strata_impls/ContextSwitchingPStratumImpl.js";
const {
ContextSwitchingPStratumImpl,
MergeWhitespacePStratumImpl,
} = strataparse;
const parserConfigProfiles = {
syntaxHighlighting: { cst: true },

View File

@ -16,7 +16,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { ParserBuilder, ParserFactory, StrataParseFacade } from "strataparse"
import { strataparse } from '@heyputer/parsers'
const { ParserBuilder, ParserFactory, StrataParseFacade } = strataparse;
import { PARSE_CONSTANTS } from "./PARSE_CONSTANTS.js";
const escapeSubstitutions = PARSE_CONSTANTS.escapeSubstitutions;

View File

@ -16,9 +16,10 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { GrammarContext, standard_parsers } from '@heyputer/parsely/exports.js';
import { Parser, UNRECOGNIZED, VALUE } from '@heyputer/parsely/parser.js';
import { StringStream } from '@heyputer/parsely/streams.js';
import { parsely } from '@heyputer/parsers';
const { GrammarContext, standard_parsers } = parsely;
const { Parser, UNRECOGNIZED, VALUE } = parsely;
const { StringStream } = parsely.streams;
class NumberParser extends Parser {
static data = {

View File

@ -39,9 +39,10 @@ import {
ZapCommand,
} from './command.js';
import { Script } from './script.js';
import { GrammarContext, standard_parsers } from '@heyputer/parsely/exports.js';
import { StringStream } from '@heyputer/parsely/streams.js';
import { Parser, UNRECOGNIZED, VALUE } from '@heyputer/parsely/parser.js';
import { parsely } from '@heyputer/parsers';
const { GrammarContext, standard_parsers } = parsely;
const { StringStream } = parsely.streams;
const { Parser, UNRECOGNIZED, VALUE } = parsely;
/**
* A slight hack: Parsely doesn't yet have an equivalent of backreferences.

View File

@ -16,11 +16,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {
import { strataparse } from '@heyputer/parsers'
const {
StringPStratumImpl,
StrataParser,
ParserFactory,
} from 'strataparse';
} = strataparse;
import { buildParserFirstHalf } from './src/ansi-shell/parsing/buildParserFirstHalf.js';
import { buildParserSecondHalf } from './src/ansi-shell/parsing/buildParserSecondHalf.js';