diff --git a/package-lock.json b/package-lock.json index 2f2e67b6..409032cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/src/parsers/exports.js b/src/parsers/exports.js new file mode 100644 index 00000000..bcda36c0 --- /dev/null +++ b/src/parsers/exports.js @@ -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_; diff --git a/src/parsely/package.json b/src/parsers/package.json similarity index 81% rename from src/parsely/package.json rename to src/parsers/package.json index 7ae60da3..9c3309a5 100644 --- a/src/parsely/package.json +++ b/src/parsers/package.json @@ -1,5 +1,5 @@ { - "name": "@heyputer/parsely", + "name": "@heyputer/parsers", "version": "1.0.0", "author": "Puter Technologies Inc.", "license": "AGPL-3.0-only", diff --git a/src/parsely/exports.js b/src/parsers/parsely/exports.js similarity index 91% rename from src/parsely/exports.js rename to src/parsers/parsely/exports.js index da80f40e..7ee9a04d 100644 --- a/src/parsely/exports.js +++ b/src/parsers/parsely/exports.js @@ -16,10 +16,19 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -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; diff --git a/src/parsely/parser.js b/src/parsers/parsely/parser.js similarity index 100% rename from src/parsely/parser.js rename to src/parsers/parsely/parser.js diff --git a/src/parsely/parsers/combinators.js b/src/parsers/parsely/parsers/combinators.js similarity index 100% rename from src/parsely/parsers/combinators.js rename to src/parsers/parsely/parsers/combinators.js diff --git a/src/parsely/parsers/terminals.js b/src/parsers/parsely/parsers/terminals.js similarity index 100% rename from src/parsely/parsers/terminals.js rename to src/parsers/parsely/parsers/terminals.js diff --git a/src/parsely/streams.js b/src/parsers/parsely/streams.js similarity index 100% rename from src/parsely/streams.js rename to src/parsers/parsely/streams.js diff --git a/src/strataparse/dsl/ParserBuilder.js b/src/parsers/strataparse/dsl/ParserBuilder.js similarity index 100% rename from src/strataparse/dsl/ParserBuilder.js rename to src/parsers/strataparse/dsl/ParserBuilder.js diff --git a/src/strataparse/dsl/ParserRegistry.js b/src/parsers/strataparse/dsl/ParserRegistry.js similarity index 100% rename from src/strataparse/dsl/ParserRegistry.js rename to src/parsers/strataparse/dsl/ParserRegistry.js diff --git a/src/strataparse/exports.js b/src/parsers/strataparse/exports.js similarity index 97% rename from src/strataparse/exports.js rename to src/parsers/strataparse/exports.js index 42c46f02..e5c3e176 100644 --- a/src/strataparse/exports.js +++ b/src/parsers/strataparse/exports.js @@ -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, diff --git a/src/strataparse/package.json b/src/parsers/strataparse/package.json similarity index 100% rename from src/strataparse/package.json rename to src/parsers/strataparse/package.json diff --git a/src/strataparse/parse.js b/src/parsers/strataparse/parse.js similarity index 100% rename from src/strataparse/parse.js rename to src/parsers/strataparse/parse.js diff --git a/src/strataparse/parse_impls/StrUntilParserImpl.js b/src/parsers/strataparse/parse_impls/StrUntilParserImpl.js similarity index 100% rename from src/strataparse/parse_impls/StrUntilParserImpl.js rename to src/parsers/strataparse/parse_impls/StrUntilParserImpl.js diff --git a/src/strataparse/parse_impls/combinators.js b/src/parsers/strataparse/parse_impls/combinators.js similarity index 100% rename from src/strataparse/parse_impls/combinators.js rename to src/parsers/strataparse/parse_impls/combinators.js diff --git a/src/strataparse/parse_impls/literal.js b/src/parsers/strataparse/parse_impls/literal.js similarity index 100% rename from src/strataparse/parse_impls/literal.js rename to src/parsers/strataparse/parse_impls/literal.js diff --git a/src/strataparse/parse_impls/whitespace.js b/src/parsers/strataparse/parse_impls/whitespace.js similarity index 100% rename from src/strataparse/parse_impls/whitespace.js rename to src/parsers/strataparse/parse_impls/whitespace.js diff --git a/src/strataparse/strata.js b/src/parsers/strataparse/strata.js similarity index 100% rename from src/strataparse/strata.js rename to src/parsers/strataparse/strata.js diff --git a/src/strataparse/strata_impls/ContextSwitchingPStratumImpl.js b/src/parsers/strataparse/strata_impls/ContextSwitchingPStratumImpl.js similarity index 100% rename from src/strataparse/strata_impls/ContextSwitchingPStratumImpl.js rename to src/parsers/strataparse/strata_impls/ContextSwitchingPStratumImpl.js diff --git a/src/strataparse/strata_impls/FirstRecognizedPStratumImpl.js b/src/parsers/strataparse/strata_impls/FirstRecognizedPStratumImpl.js similarity index 100% rename from src/strataparse/strata_impls/FirstRecognizedPStratumImpl.js rename to src/parsers/strataparse/strata_impls/FirstRecognizedPStratumImpl.js diff --git a/src/strataparse/strata_impls/MergeWhitespacePStratumImpl.js b/src/parsers/strataparse/strata_impls/MergeWhitespacePStratumImpl.js similarity index 100% rename from src/strataparse/strata_impls/MergeWhitespacePStratumImpl.js rename to src/parsers/strataparse/strata_impls/MergeWhitespacePStratumImpl.js diff --git a/src/strataparse/strata_impls/terminals.js b/src/parsers/strataparse/strata_impls/terminals.js similarity index 100% rename from src/strataparse/strata_impls/terminals.js rename to src/parsers/strataparse/strata_impls/terminals.js diff --git a/src/phoenix/src/ansi-shell/parsing/PuterShellParser.js b/src/phoenix/src/ansi-shell/parsing/PuterShellParser.js index 50eba178..5d20a3e1 100644 --- a/src/phoenix/src/ansi-shell/parsing/PuterShellParser.js +++ b/src/phoenix/src/ansi-shell/parsing/PuterShellParser.js @@ -16,7 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { StrataParser, StringPStratumImpl } from "strataparse"; +import { strataparse } from '@heyputer/parsers'; +const { StrataParser, StringPStratumImpl } = strataparse; import { buildParserFirstHalf } from "./buildParserFirstHalf.js"; import { buildParserSecondHalf } from "./buildParserSecondHalf.js"; diff --git a/src/phoenix/src/ansi-shell/parsing/buildParserFirstHalf.js b/src/phoenix/src/ansi-shell/parsing/buildParserFirstHalf.js index 7666be3a..12b64a06 100644 --- a/src/phoenix/src/ansi-shell/parsing/buildParserFirstHalf.js +++ b/src/phoenix/src/ansi-shell/parsing/buildParserFirstHalf.js @@ -16,11 +16,20 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -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 }, diff --git a/src/phoenix/src/ansi-shell/parsing/buildParserSecondHalf.js b/src/phoenix/src/ansi-shell/parsing/buildParserSecondHalf.js index 02150485..a89ce316 100644 --- a/src/phoenix/src/ansi-shell/parsing/buildParserSecondHalf.js +++ b/src/phoenix/src/ansi-shell/parsing/buildParserSecondHalf.js @@ -16,7 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -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; diff --git a/src/phoenix/src/puter-shell/coreutils/concept-parser.js b/src/phoenix/src/puter-shell/coreutils/concept-parser.js index 1ed2ebd3..894a6f5f 100644 --- a/src/phoenix/src/puter-shell/coreutils/concept-parser.js +++ b/src/phoenix/src/puter-shell/coreutils/concept-parser.js @@ -16,9 +16,10 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -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 = { diff --git a/src/phoenix/src/puter-shell/coreutils/sed/parser.js b/src/phoenix/src/puter-shell/coreutils/sed/parser.js index 68805cf5..e8d7e06a 100644 --- a/src/phoenix/src/puter-shell/coreutils/sed/parser.js +++ b/src/phoenix/src/puter-shell/coreutils/sed/parser.js @@ -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. diff --git a/src/phoenix/test.js b/src/phoenix/test.js index 6c5fded7..f72f90f5 100644 --- a/src/phoenix/test.js +++ b/src/phoenix/test.js @@ -16,11 +16,12 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -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';