--- /dev/null
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+ or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+************************************************************************
+
+************************************************************************
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party's negligence to the *
+* extent applicable law prohibits such limitation. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
--- /dev/null
+# ♓️🪡 सूत्र
+
+**X·D·M for Ecmascript.**
+
+♓️🪡 सूत्र is an implementation of the
+[X·Path and X·Query Data Model (X·D·M)][XDM] for Ecmascript. It
+includes an implementation of the
+[X·M·L Schema Definition Language][XSD-1] in the [`xsd`](./xsd)
+directory.
+
+This module depends heavily on [♓️🧩 Piscēs][Pisces].
+
+## Nomenclature
+
+<i lang="sa">सूत्र</i> (<i lang="sa-Latn">sūtra</i>) is a Sanskrit word
+meaning “thread”.
+
+In Ascii, ♓️🪡 सूत्र should be represented as `Sutra`, the Anglicized
+form of the name.
+
+## Current Status
+
+Prospective. The immediate goal is to have a working impelentation of
+the [X·M·L Schema Definition Datatypes][XSD-2]. Other components will
+be added later.
+
+## License
+
+Source files are licensed under the terms of the <cite>Mozilla Public
+License, version 2.0</cite>. For more information, see
+[LICENSE](./LICENSE).
+
+[Pisces]: <https://git.ladys.computer/Pisces>
+[XSD-1]: <https://www.w3.org/TR/xmlschema11-1/>
+[XSD-2]: <https://www.w3.org/TR/xmlschema11-2/>
+[XDM]: <https://www.w3.org/TR/xpath-datamodel/>
--- /dev/null
+{ "fmt": { "lineWidth": 71 } }
--- /dev/null
+{
+ "version": "2",
+ "remote": {
+ "https://deno.land/std@0.192.0/fmt/colors.ts": "d67e3cd9f472535241a8e410d33423980bec45047e343577554d3356e1f0ef4e",
+ "https://deno.land/std@0.192.0/testing/_diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea",
+ "https://deno.land/std@0.192.0/testing/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7",
+ "https://deno.land/std@0.192.0/testing/_test_suite.ts": "30f018feeb3835f12ab198d8a518f9089b1bcb2e8c838a8b615ab10d5005465c",
+ "https://deno.land/std@0.192.0/testing/asserts.ts": "e16d98b4d73ffc4ed498d717307a12500ae4f2cbe668f1a215632d19fcffc22f",
+ "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/binary.js": "4dd2ba7bc3c0d7b31b24fdd8350f3d976ae8c916b283cedc06dd3b768bbcb812",
+ "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/collection.js": "3d9f2f9817273aeffd6735ecf5cd2a00ed7a9327859fb026e729b434ab98c59b",
+ "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/function.js": "0ca111c31ff3694822082e785c52d71c079c0269f3fb3b97c0d145a4a4ca31d1",
+ "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/iri.js": "8dcb861befecff5897c489b73cc077453a857cda899844ebc6f5f3f3cd6c03f2",
+ "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/mod.js": "835746ed65fa23c87235343e88945ee5a6cbb5c7baa74f197ff5f9cd280dd506",
+ "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/numeric.js": "3c46c43c6d15d91d54363320e19f3cb32beaf9779419bd05b8988a030bd68410",
+ "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/object.js": "e611a5aad46ca1525cd6a9e55eb00fee4c62012464b087bd04f38754a6eded84",
+ "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/string.js": "64e6e2ed922b927db720b38cb1c4f781617fbd15fcf0bf285a90c12ff5619a62",
+ "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/value.js": "96d2e2c347ea76f191b78a622e8bf04ac31213184f72a5d1247aa4c381304d88"
+ }
+}
--- /dev/null
+// ♓️🪡 सूत्र ∷ deps.js
+// ====================================================================
+//
+// Copyright © 2023 Lady [@ Lady’s Computer].
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+export {
+ bind,
+ call,
+ floor,
+ getPrototype,
+ isArrayBuffer,
+ isFiniteNumber,
+ isIntegralNumber,
+ ITERATOR,
+ Matcher,
+ NAN,
+ NEGATIVE_INFINITY,
+ NEGATIVE_ZERO,
+ objectCreate,
+ POSITIVE_INFINITY,
+ POSITIVE_ZERO,
+ rawString,
+ sameValue,
+ stringSplit,
+ substring,
+ toFloat32,
+ type,
+ UNDEFINED,
+} from "https://git.ladys.computer/Pisces/blob_plain/0.4.0:/mod.js";
--- /dev/null
+// ♓️🪡 सूत् ∷ dev-deps.js
+// ====================================================================
+//
+// Copyright © 2023 Lady [@ Lady’s Computer].
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+export {
+ assert,
+ assertStrictEquals,
+} from "https://deno.land/std@0.192.0/testing/asserts.ts";
--- /dev/null
+# ♓️🪡 सूत्र ∷ X·S·D
+
+♓️🪡 सूत्र ∷ X·S·D provides an implementation of the
+[X·M·L Schema Definition Language][XSD-1], including the
+[X·M·L Schema Definition Datatypes][XSD-2], for Ecmascript.
+
+## Notes
+
+### Typechecking
+
+All of the functions provided by `./functions.js` will throw an error
+if they are given arguments which do not match the expectations
+established by the X·S·D spec. No type coersion occurs.
+
+### Efficiency
+
+♓️🪡 सूत्र ∷ X·S·D emphasizes algorithm correctness and takes a somewhat
+extreme stance with regards to spec adherence. This means that the
+algorithms used may be somewhat slow, although native platform features
+will be leveraged when possible.
+
+### Numeric values
+
+♓️🪡 सूत्र ∷ X·S·D treats all numeric values as native Ecmascript
+numbers. This may lead to rounding errors for decimals and extreme
+values.
+
+This behaviour may change in the future; see
+<https://github.com/tc39/proposal-decimal> for progress on getting a
+more precise decimal type into Ecmascript.
+
+### Positive and Negative Zero
+
+X·S·D only formally distinguishes positive and negative zero for floats
+and doubles, but it allows them to be represented lexically in all
+other signed numeric types. ♓️🪡 सूत्र ∷ X·S·D silently coerces negative
+zero to positive zero for numeric datatypes in which it is not an
+explicit part of the value space, as well as for numeric components of
+other datatypes (e·g durations).
+
+### Date∕times and Durations
+
+♓️🪡 सूत्र ∷ X·S·D does not provide actual classes for X·S·D
+date/timeSevenPropertyModel values or durations, treatings both as
+simple objects. This approach was taken to maximize compatibility with
+other modules. Formally :—
+
+1. A duration is any object for which getting the `months` property
+ returns an integer, getting the `seconds` property returns a finite
+ number, and these two values have the same sign. (Positive and
+ negative zero are treated as having the same sign for this
+ comparison.)
+
+ Note that `months` and `seconds` **must not** be undefined.
+
+2. A date/timeSevenPropertyModel value is any object for which getting
+ the `year`, `month`, `day`, `hour`, `minute`, `second`, and
+ `timezoneOffset` properties returns values within the bounds
+ specified in the X·S·D specification. Absent values can be
+ represented with undefined, and need not actually be defined on the
+ object).
+
+Functions which return durations or date/timeSevenPropertyModel values
+will always return a plain, extensible object which :—
+
+- Inherits from `%ObjectPrototype%`,
+- Has all of the applicable properties defined as enumerable,
+ configurable, writable own data properties (absent properties will be
+ defined with a value of undefined), and
+- Has no other own properties.
+
+[XSD-1]: <https://www.w3.org/TR/xmlschema11-1/>
+[XSD-2]: <https://www.w3.org/TR/xmlschema11-2/>
--- /dev/null
+// ♓️🪡 सूत्र ∷ xsd/functions.js
+// ====================================================================
+//
+// Copyright © 2023 Lady [@ Lady’s Computer].
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+import {
+ bind,
+ call,
+ getPrototype,
+ isArrayBuffer,
+ isFiniteNumber,
+ isIntegralNumber,
+ ITERATOR,
+ objectCreate,
+ sameValue,
+ toFloat32,
+ type,
+} from "../deps.js";
+import { div, mod } from "./operators.js";
+import {
+ booleanRep,
+ dateLexicalRep,
+ dateTimeLexicalRep,
+ dayFrag,
+ dayTimeDurationLexicalRep,
+ decimalLexicalRep,
+ decimalPtNumeral,
+ digit as lexicalDigit,
+ doubleRep,
+ duDayFrag,
+ duDayTimeFrag,
+ duHourFrag,
+ duMinuteFrag,
+ duMonthFrag,
+ durationLexicalRep,
+ duSecondFrag,
+ duTimeFrag,
+ duYearFrag,
+ duYearMonthFrag,
+ floatRep,
+ fracFrag,
+ gDayLexicalRep,
+ gMonthDayLexicalRep,
+ gMonthLexicalRep,
+ gYearLexicalRep,
+ gYearMonthLexicalRep,
+ hexBinary,
+ hexDigit,
+ hexOctet,
+ hourFrag,
+ minuteFrag,
+ monthFrag,
+ noDecimalPtNumeral,
+ numericalSpecialRep,
+ scientificNotationNumeral,
+ secondFrag,
+ stringRep,
+ timeLexicalRep,
+ timezoneFrag,
+ unsignedDecimalPtNumeral,
+ unsignedNoDecimalPtNumeral,
+ yearFrag,
+ yearMonthDurationLexicalRep,
+} from "./productions.js";
+import {
+ absent,
+ negativeInfinity,
+ negativeZero,
+ notANumber,
+ positiveInfinity,
+ positiveZero,
+} from "./values.js";
+
+const stringToFloat = parseFloat;
+
+/**
+ * Ensures that the provided matcher matches the provided value and
+ * returns it.
+ *
+ * ☡ This function throws if the matcher does not match.
+ *
+ * ※ This function is not exposed.
+ */
+const ensureMatches = (matcher, $) => {
+ if (matcher($)) {
+ return $;
+ } else {
+ throw new TypeError(
+ `सूत्र: Expected a ${matcher.name}, but got: ${$}.`,
+ );
+ }
+};
+
+/**
+ * Ensures that the provided value with the provided name is present or
+ * absent.
+ *
+ * ☡ This function throws if the presence of the value is not correct.
+ *
+ * ※ This function is not exposed.
+ */
+const ensurePresence = (name, value, present = true) => {
+ if ((value !== absent) === !present) {
+ throw new TypeError(
+ `सूत्र: Expected ${name} to be ${
+ present ? "present" : "absent"
+ }, but got: ${value}.`,
+ );
+ } else {
+ return value;
+ }
+};
+
+/**
+ * Ensures that the provided value is a valid, complete duration and
+ * returns an object with its months and seconds.
+ *
+ * ☡ This function throws if the provided value is not a valid,
+ * complete duration.
+ *
+ * ※ This function is not exposed.
+ */
+const duration = ($) => {
+ const { months, seconds } = $;
+ if (!isIntegralNumber(months)) {
+ throw new TypeError(
+ `सूत्र: Expected duration to have an integer for months, but got: ${months}.`,
+ );
+ } else if (!isFiniteNumber(seconds)) {
+ throw new TypeError(
+ `सूत्र: Expected duration to have a finite number for seconds, but got: ${seconds}.`,
+ );
+ } else if (months > 0 && seconds < 0 || months < 0 && seconds > 0) {
+ throw new TypeError(
+ `सूत्र: Expected seconds in duration to match polarity of months, but got: ${seconds}.`,
+ );
+ } else {
+ return { months, seconds };
+ }
+};
+
+/**
+ * Ensures that the provided value is a valid
+ * date/timeSevenPropertyModel value and returns an object with its
+ * year, month, day, hour, minute, second, and timezoneOffset.
+ *
+ * ☡ This function throws if the provided value is not a valid
+ * date/timeSevenPropertyModel value.
+ *
+ * ※ This function is not exposed.
+ */
+const date·timeSevenPropertyModel = ($) => {
+ if (type($) !== "object") {
+ throw new TypeError(
+ `सूत्र: Expected a date/timeSevenPropertyModel value, but got: ${$}.`,
+ );
+ } else {
+ const { year, month, day, hour, minute, second, timezoneOffset } =
+ $;
+ if (year !== absent && !isIntegralNumber(year)) {
+ throw new TypeError(
+ `सूत्र: Expected year to be an optional integer, but got: ${year}.`,
+ );
+ } else if (
+ month !== absent &&
+ !(isIntegralNumber(month) && month >= 1 && month <= 12)
+ ) {
+ throw new TypeError(
+ `सूत्र: Expected month to be an optional integer between 1 and 12 inclusive, but got: ${month}.`,
+ );
+ } else if (
+ day !== absent &&
+ !(isIntegralNumber(day) && day >= 1 && day <= 31)
+ ) {
+ throw new TypeError(
+ `सूत्र: Expected day to be an optional integer between 1 and 31 inclusive, but got: ${day}.`,
+ );
+ } else if (
+ hour !== absent &&
+ !(isIntegralNumber(hour) && hour >= 0 && hour <= 24)
+ ) {
+ throw new TypeError(
+ `सूत्र: Expected hour to be an optional integer between 0 and 24 inclusive, but got: ${hour}.`,
+ );
+ } else if (
+ minute !== absent &&
+ !(isIntegralNumber(minute) && minute >= 0 && minute <= 59)
+ ) {
+ throw new TypeError(
+ `सूत्र: Expected minute to be an optional integer between 0 and 59 inclusive, but got: ${minute}.`,
+ );
+ } else if (
+ second !== absent &&
+ !(isFiniteNumber(second) && second >= 0 && second < 60)
+ ) {
+ throw new TypeError(
+ `सूत्र: Expected second to be an optional finite number greater than or equal to 0 and less than 60, but got: ${second}.`,
+ );
+ } else if (
+ timezoneOffset !== absent &&
+ !(isIntegralNumber(timezoneOffset) && timezoneOffset >= -840 &&
+ timezoneOffset <= 840)
+ ) {
+ throw new TypeError(
+ `सूत्र: Expected timezoneOffset to be an optional integer between -840 and 840 inclusive, but got: ${timezoneOffset}.`,
+ );
+ } else if (
+ month !== absent && day !== absent && !(
+ month === 2 && day === 29
+ ) && day > daysInMonth(year, month)
+ ) {
+ throw new TypeError(
+ `सूत्र: The provided day violates the day‐of‐month constraint for month ${month}: ${day}.`,
+ );
+ } else {
+ return {
+ year,
+ month,
+ day,
+ hour,
+ minute,
+ second,
+ timezoneOffset,
+ };
+ }
+ }
+};
+
+/**
+ * Ensures that the provided value is an integer and returns it.
+ *
+ * ☡ This function throws if the provided value is not an integer.
+ *
+ * ※ This function is not exposed.
+ */
+const integer = ($) => {
+ if (!isIntegralNumber($)) {
+ throw new TypeError(`सूत्र: Expected an integer, but got: ${$}.`);
+ } else {
+ return $;
+ }
+};
+
+/**
+ * Ensures that the provided value is a nonnegative integer and returns
+ * it.
+ *
+ * ☡ This function throws if the provided value is not a nonnegative
+ * integer.
+ *
+ * ※ This function is not exposed.
+ */
+const nonnegativeInteger = ($) => {
+ if (!(isIntegralNumber($) && $ >= 0)) {
+ throw new TypeError(
+ `सूत्र: Expected a nonnegative integer, but got: ${$}.`,
+ );
+ } else {
+ return $;
+ }
+};
+
+/**
+ * Ensures that the provided value is a finite number and returns it.
+ *
+ * ☡ This function throws if the provided value is not a finite number.
+ *
+ * ※ This function is not exposed.
+ */
+const decimalNumber = ($) => {
+ if (!(isFiniteNumber($))) {
+ throw new TypeError(
+ `सूत्र: Expected a finite number, but got: ${$}.`,
+ );
+ } else {
+ return $;
+ }
+};
+
+/**
+ * Ensures that the provided value is a nonnegative finite number and
+ * returns it.
+ *
+ * ☡ This function throws if the provided value is not a nonnegative
+ * finite number.
+ *
+ * ※ This function is not exposed.
+ */
+const nonnegativeDecimalNumber = ($) => {
+ if (!(isFiniteNumber($) && $ >= 0)) {
+ throw new TypeError(
+ `सूत्र: Expected a nonnegative finite number, but got: ${$}.`,
+ );
+ } else {
+ return $;
+ }
+};
+
+/**
+ * Ensures that the provided value is a 32‐bit float and returns it.
+ *
+ * ☡ This function throws if the provided value is not a 32‐bit float.
+ *
+ * ※ This function is not exposed.
+ */
+const float = ($) => {
+ if (typeof $ !== "number" || !sameValue(toFloat32($), $)) {
+ throw new TypeError(
+ `सूत्र: Expected a float value, but got: ${$}.`,
+ );
+ } else {
+ return $;
+ }
+};
+
+/**
+ * Ensures that the provided value is a number and returns it.
+ *
+ * ☡ This function throws if the provided value is not a number.
+ *
+ * ※ This function is not exposed.
+ */
+const double = ($) => {
+ if (typeof $ !== "number") {
+ throw new TypeError(
+ `सूत्र: Expected a double value, but got: ${$}.`,
+ );
+ } else {
+ return $;
+ }
+};
+
+/**
+ * Ensures that the provided value is a hexBinary value, i·e a sequence
+ * of binary octets.
+ *
+ * ☡ This function throws if the provided value is not an array buffer.
+ *
+ * ※ This function is not exposed.
+ */
+const hexBinaryValue = ($) => {
+ if (!isArrayBuffer($)) {
+ throw new TypeError(
+ `सूत्र: Expected a hexBinary value, but got: ${$}.`,
+ );
+ } else {
+ return $;
+ }
+};
+
+const {
+ /**
+ * Converts a string of 0’s and 1’s into a sequence of binary digits.
+ *
+ * ※ This function is not exposed.
+ */
+ binaryDigitSequence,
+
+ /**
+ * Converts a generator iterator into a sequence of values.
+ *
+ * ※ This function is not exposed.
+ */
+ generatorSequence,
+
+ /**
+ * Converts a string into a sequence of characters.
+ *
+ * ※ This function is not exposed.
+ */
+ literalSequence,
+} = (() => {
+ const {
+ next: generatorIteratorNext,
+ } = getPrototype(function* () {}.prototype);
+ const { [ITERATOR]: stringIterator } = String.prototype;
+ const {
+ next: stringIteratorNext,
+ } = getPrototype(""[ITERATOR]());
+ const binaryDigitIterator = function* () {
+ for (const digit of literalSequence(this)) {
+ yield digit === "0" ? 0 : 1;
+ }
+ };
+ const binaryDigitSequenceIterablePrototype = {
+ [ITERATOR]() {
+ return {
+ next: bind(
+ generatorIteratorNext,
+ call(binaryDigitIterator, this.binaryDigits, []),
+ [],
+ ),
+ };
+ },
+ };
+ const generatorSequenceIterablePrototype = {
+ [ITERATOR]() {
+ return {
+ next: bind(
+ generatorIteratorNext,
+ this.generator(),
+ [],
+ ),
+ };
+ },
+ };
+ const literalSequenceIterablePrototype = {
+ [ITERATOR]() {
+ return {
+ next: bind(
+ stringIteratorNext,
+ call(stringIterator, this.literal, []),
+ [],
+ ),
+ };
+ },
+ };
+
+ return {
+ binaryDigitSequence: (digits) =>
+ objectCreate(
+ binaryDigitSequenceIterablePrototype,
+ { binaryDigits: { value: digits } },
+ ),
+ generatorSequence: (generator) =>
+ objectCreate(
+ generatorSequenceIterablePrototype,
+ { generator: { value: generator } },
+ ),
+ literalSequence: (literal) =>
+ objectCreate(
+ literalSequenceIterablePrototype,
+ { literal: { value: literal } },
+ ),
+ };
+})();
--- /dev/null
+// ♓️🪡 सूत्र ∷ xsd/mod.js
+// ====================================================================
+//
+// Copyright © 2023 Lady [@ Lady’s Computer].
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+export * from "./functions.js";
+export * from "./operators.js";
+export * from "./productions.js";
+export * from "./values.js";
--- /dev/null
+// ♓️🪡 सूत्र ∷ xsd/operators.js
+// ====================================================================
+//
+// Copyright © 2023 Lady [@ Lady’s Computer].
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+import { floor } from "../deps.js";
+
+/**
+ * For the provided arguments m & n, the greatest integer less than or
+ * equal to m ∕ n.
+ *
+ * See <https://www.w3.org/TR/xmlschema11-2/#dt-div>.
+ */
+export const div = (m, n) => floor(m / n);
+
+/**
+ * For the provided arguments m & n, m − n × (m ·div· n).
+ *
+ * See <https://www.w3.org/TR/xmlschema11-2/#dt-mod>.
+ *
+ * ☡ This function may suffer from floating‐point rounding errors if
+ * the provided arguments are not integers.
+ */
+export const mod = (m, n) => m - n * div(m, n);
--- /dev/null
+// ♓️🪡 सूत्र ∷ xsd/productions.js
+// ====================================================================
+//
+// Copyright © 2023 Lady [@ Lady’s Computer].
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+import {
+ Matcher,
+ objectCreate,
+ rawString,
+ stringSplit,
+ substring,
+} from "../deps.js";
+
+const dayOfMonthValuesConstraint = (day, month, year = "1972") => {
+ const d = +day;
+ const m = +month;
+ const y = +year;
+ return m === 4 || m === 6 || m === 9 || m === 11
+ ? d <= 30
+ : m === 2 && (y % 4 || !(y % 100) && y % 400)
+ ? d <= 28
+ : m === 2 && (!(y % 400) || !(y % 4) && y % 100)
+ ? d <= 29
+ : true;
+};
+
+export const {
+ /** `[1] stringRep ::= Char*` */
+ stringRep,
+
+ /** `[2] booleanRep ::= 'true' | 'false' | '1' | '0'` */
+ booleanRep,
+
+ /** `[3] decimalLexicalRep ::= decimalPtNumeral | noDecimalPtNumeral` */
+ decimalLexicalRep,
+
+ /** `[4] floatRep ::= noDecimalPtNumeral | decimalPtNumeral | scientificNotationNumeral | numericalSpecialRep` */
+ floatRep,
+
+ /** `[5] doubleRep ::= noDecimalPtNumeral | decimalPtNumeral | scientificNotationNumeral | numericalSpecialRep` */
+ doubleRep,
+
+ /** `[6] duYearFrag ::= unsignedNoDecimalPtNumeral 'Y'` */
+ duYearFrag,
+
+ /** `[7] duMonthFrag ::= unsignedNoDecimalPtNumeral 'M'` */
+ duMonthFrag,
+
+ /** `[8] duDayFrag ::= unsignedNoDecimalPtNumeral 'D'` */
+ duDayFrag,
+
+ /** `[9] duHourFrag ::= unsignedNoDecimalPtNumeral 'H'` */
+ duHourFrag,
+
+ /** `[10] duMinuteFrag ::= unsignedNoDecimalPtNumeral 'M'` */
+ duMinuteFrag,
+
+ /**
+ * `[11] duSecondFrag ::= (unsignedNoDecimalPtNumeral | unsignedFullDecimalPtNumeral) 'S'`
+ *
+ * ※ The X·S·D specification specifies unsignedDecimalPtNumeral, not
+ * unsignedFullDecimalPtNumeral, but the specification text and
+ * provided regular expressions imply that the latter was intended.
+ */
+ duSecondFrag,
+
+ /** `[12] duYearMonthFrag ::= (duYearFrag duMonthFrag?) | duMonthFrag` */
+ duYearMonthFrag,
+
+ /** `[13] duTimeFrag ::= 'T' ((duHourFrag duMinuteFrag? duSecondFrag?) | (duMinuteFrag duSecondFrag?) | duSecondFrag)` */
+ duTimeFrag,
+
+ /** `[14] duDayTimeFrag ::= (duDayFrag duTimeFrag?) | duTimeFrag` */
+ duDayTimeFrag,
+
+ /** `[15] durationLexicalRep ::= '-'? 'P' ((duYearMonthFrag duDayTimeFrag?) | duDayTimeFrag)` */
+ durationLexicalRep,
+
+ /**
+ * `[16] dateTimeLexicalRep ::= yearFrag '-' monthFrag '-' dayFrag 'T' ((hourFrag ':' minuteFrag ':' secondFrag) | endOfDayFrag) timezoneFrag?`
+ *
+ * **Constraint: Day-of-month Values**
+ *
+ * The ·day· value must be no more than 30 if ·month· is one of 4, 6,
+ * 9, or 11; no more than 28 if ·month· is 2 and ·year· is not
+ * divisible by 4, or is divisible by 100 but not by 400; and no more
+ * than 29 if ·month· is 2 and ·year· is divisible by 400, or by 4
+ * but not by 100.
+ *
+ * **Constraint: Day-of-month Representations**
+ *
+ * Within a dateTimeLexicalRep, a dayFrag must not begin with the
+ * digit '3' or be '29' unless the value to which it would map would
+ * satisfy the value constraint on ·day· values ("Constraint:
+ * Day-of-month Values") given above.
+ */
+ dateTimeLexicalRep,
+
+ /** `[17] timeLexicalRep ::= ((hourFrag ':' minuteFrag ':' secondFrag) | endOfDayFrag) timezoneFrag?` */
+ timeLexicalRep,
+
+ /**
+ * `[18] dateLexicalRep ::= yearFrag '-' monthFrag '-' dayFrag timezoneFrag?`
+ *
+ * **Constraint: Day-of-month Values**
+ *
+ * The ·day· value must be no more than 30 if ·month· is one of 4, 6,
+ * 9, or 11; no more than 28 if ·month· is 2 and ·year· is not
+ * divisible by 4, or is divisible by 100 but not by 400; and no more
+ * than 29 if ·month· is 2 and ·year· is divisible by 400, or by 4
+ * but not by 100.
+ *
+ * **Constraint: Day-of-month Representations**
+ *
+ * Within a dateLexicalRep, a dayFrag must not begin with the digit
+ * '3' or be '29' unless the value to which it would map would
+ * satisfy the value constraint on ·day· values ("Constraint:
+ * Day-of-month Values") given above.
+ */
+ dateLexicalRep,
+
+ /** `[19] gYearMonthLexicalRep ::= yearFrag '-' monthFrag timezoneFrag?` */
+ gYearMonthLexicalRep,
+
+ /** `[20] gYearLexicalRep ::= yearFrag timezoneFrag?` */
+ gYearLexicalRep,
+
+ /**
+ * `[21] gMonthDayLexicalRep ::= '--' monthFrag '-' dayFrag timezoneFrag?`
+ *
+ * **Constraint: Day-of-month Values**
+ *
+ * The ·day· value must be no more than 30 if ·month· is one of 4, 6,
+ * 9, or 11, and no more than 29 if ·month· is 2.
+ *
+ * **Constraint: Day-of-month Representations**
+ *
+ * Within a gMonthDayLexicalRep, a dayFrag must not begin with the
+ * digit '3' or be '29' unless the value to which it would map would
+ * satisfy the value constraint on ·day· values ("Constraint:
+ * Day-of-month Values") given above.
+ */
+ gMonthDayLexicalRep,
+
+ /** `[22] gDayLexicalRep ::= '---' dayFrag timezoneFrag?` */
+ gDayLexicalRep,
+
+ /** `[23] gMonthLexicalRep ::= '--' monthFrag timezoneFrag?` */
+ gMonthLexicalRep,
+
+ /** `[24] hexDigit ::= [0-9a-fA-F]` */
+ hexDigit,
+
+ /** `[25] hexOctet ::= hexDigit hexDigit` */
+ hexOctet,
+
+ /** `[26] hexBinary ::= hexOctet*` */
+ hexBinary,
+
+ /** `[27] Base64Binary ::= (B64quad* B64final)?` */
+ Base64Binary,
+
+ /** `[28] B64quad ::= (B64 B64 B64 B64)` */
+ B64quad,
+
+ /** `[29] B64final ::= B64finalquad | Padded16 | Padded8` */
+ B64final,
+
+ /** `[30] B64finalquad ::= (B64 B64 B64 B64char)` */
+ B64finalquad,
+
+ /** `[31] Padded16 ::= B64 B64 B16 '='` */
+ Padded16,
+
+ /** `[32] Padded8 ::= B64 B04 '=' #x20? '='` */
+ Padded8,
+
+ /** `[33] B64 ::= B64char #x20?` */
+ B64,
+
+ /** `[34] B64char ::= [A-Za-z0-9+/]` */
+ B64char,
+
+ /** `[35] B16 ::= B16char #x20?` */
+ B16,
+
+ /** `[36] B16char ::= [AEIMQUYcgkosw048]` */
+ B16char,
+
+ /** `[37] B04 ::= B04char #x20?` */
+ B04,
+
+ /** `[38] B04char ::= [AQgw]` */
+ B04char,
+
+ /** `[39] Canonical-base64Binary ::= CanonicalQuad* CanonicalPadded?` */
+ Canonical·base64Binary,
+
+ /** `[40] CanonicalQuad ::= B64char B64char B64char B64char` */
+ CanonicalQuad,
+
+ /** `[41] CanonicalPadded ::= B64char B64char B16char '=' | B64char B04char '=='` */
+ CanonicalPadded,
+
+ /** `[42] yearMonthDurationLexicalRep ::= '-'? 'P' duYearMonthFrag` */
+ yearMonthDurationLexicalRep,
+
+ /** `[43] dayTimeDurationLexicalRep ::= '-'? 'P' duDayTimeFrag` */
+ dayTimeDurationLexicalRep,
+
+ /**
+ * `[44] dateTimeStampLexicalRep ::= yearFrag '-' monthFrag '-' dayFrag 'T' ((hourFrag ':' minuteFrag ':' secondFrag) | endOfDayFrag) timezoneFrag`
+ *
+ * **Constraint: Day-of-month Values**
+ *
+ * The ·day· value must be no more than 30 if ·month· is one of 4, 6,
+ * 9, or 11; no more than 28 if ·month· is 2 and ·year· is not
+ * divisible by 4, or is divisible by 100 but not by 400; and no more
+ * than 29 if ·month· is 2 and ·year· is divisible by 400, or by 4
+ * but not by 100.
+ *
+ * **Constraint: Day-of-month Representations**
+ *
+ * Within a dateTimeStampLexicalRep, a dayFrag must not begin with
+ * the digit '3' or be '29' unless the value to which it would map
+ * would satisfy the value constraint on ·day· values ("Constraint:
+ * Day-of-month Values") given above.
+ */
+ dateTimeStampLexicalRep,
+
+ /** `[45] digit ::= [0-9]` */
+ digit,
+
+ /** `[46] unsignedNoDecimalPtNumeral ::= digit+` */
+ unsignedNoDecimalPtNumeral,
+
+ /** `[47] noDecimalPtNumeral ::= ('+' | '-')? unsignedNoDecimalPtNumeral` */
+ noDecimalPtNumeral,
+
+ /** `[48] fracFrag ::= digit+` */
+ fracFrag,
+
+ /** `[49] unsignedDecimalPtNumeral ::= (unsignedNoDecimalPtNumeral '.' fracFrag?) | ('.' fracFrag)` */
+ unsignedDecimalPtNumeral,
+
+ /** `[50] unsignedFullDecimalPtNumeral ::= unsignedNoDecimalPtNumeral '.' fracFrag` */
+ unsignedFullDecimalPtNumeral,
+
+ /** `[51] decimalPtNumeral ::= ('+' | '-')? unsignedDecimalPtNumeral` */
+ decimalPtNumeral,
+
+ /** `[52] unsignedScientificNotationNumeral ::= (unsignedNoDecimalPtNumeral | unsignedDecimalPtNumeral) ('e' | 'E') noDecimalPtNumeral` */
+ unsignedScientificNotationNumeral,
+
+ /** `[53] scientificNotationNumeral ::= ('+' | '-')? unsignedScientificNotationNumeral` */
+ scientificNotationNumeral,
+
+ /** `[54] minimalNumericalSpecialRep ::= 'INF' | '-INF' | 'NaN'` */
+ minimalNumericalSpecialRep,
+
+ /** `[55] numericalSpecialRep ::= ('+' | '-')? unsignedScientificNotationNumeral` */
+ numericalSpecialRep,
+
+ /** `[56] yearFrag ::= '-'? (([1-9] digit digit digit+)) | ('0' digit digit digit))` */
+ yearFrag,
+
+ /** `[57] monthFrag ::= ('0' [1-9]) | ('1' [0-2])` */
+ monthFrag,
+
+ /** `[58] dayFrag ::= ('0' [1-9]) | ([12] digit) | ('3' [01])` */
+ dayFrag,
+
+ /** `[59] hourFrag ::= ([01] digit) | ('2' [0-3])` */
+ hourFrag,
+
+ /** `[60] minuteFrag ::= [0-5] digit` */
+ minuteFrag,
+
+ /** `[61] secondFrag ::= ([0-5] digit) ('.' digit+)?` */
+ secondFrag,
+
+ /** `[62] endOfDayFrag ::= '24:00:00' ('.' '0'+)?` */
+ endOfDayFrag,
+
+ /** `[63] timezoneFrag ::= 'Z' | ('+' | '-') (('0' digit | '1' [0-3]) ':' minuteFrag | '14:00')` */
+ timezoneFrag,
+} = (() => {
+ const matchers = objectCreate(null);
+ const match =
+ (name, constraint = null) => (strings, ...substitutions) => {
+ const source = `(?:${rawString(strings, ...substitutions)})`;
+ matchers[name] = new Matcher(`^${source}$`, name, constraint);
+ return source;
+ };
+
+ const stringRep = match(
+ "stringRep",
+ )`[^\u{0}\u{D800}-\u{DFFF}\u{FFFE}\u{FFFF}]*`;
+ const booleanRep = match("booleanRep")`true|false|1|0`;
+ const digit = match("digit")`[0-9]`;
+ const unsignedNoDecimalPtNumeral = match(
+ "unsignedNoDecimalPtNumeral",
+ )`${digit}+`;
+ const noDecimalPtNumeral = match(
+ "noDecimalPtNumeral",
+ )`[+-]?${unsignedNoDecimalPtNumeral}`;
+ const fracFrag = match("fracFrag")`${digit}+`;
+ const unsignedDecimalPtNumeral = match(
+ "unsignedDecimalPtNumeral",
+ )`${unsignedNoDecimalPtNumeral}\.${fracFrag}?|\.${fracFrag}`;
+ const unsignedFullDecimalPtNumeral = match(
+ "unsignedFullDecimalPtNumeral",
+ )`${unsignedNoDecimalPtNumeral}\.${fracFrag}`;
+ const decimalPtNumeral = match(
+ "decimalPtNumeral",
+ )`[+-]?${unsignedDecimalPtNumeral}`;
+ const unsignedScientificNotationNumeral = match(
+ "unsignedScientificNotationNumeral",
+ )`(?:${unsignedNoDecimalPtNumeral}|${unsignedDecimalPtNumeral})[eE]${noDecimalPtNumeral}`;
+ const scientificNotationNumeral = match(
+ "scientificNotationNumeral",
+ )`[+-]?${unsignedScientificNotationNumeral}`;
+ const minimalNumericalSpecialRep = match(
+ "minimalNumericalSpecialRep",
+ )`INF|-INF|NaN`;
+ const numericalSpecialRep = match(
+ "numericalSpecialRep",
+ )`\+INF|${minimalNumericalSpecialRep}`;
+ const decimalLexicalRep = match(
+ "decimalLexicalRep",
+ )`${decimalPtNumeral}|${noDecimalPtNumeral}`;
+ const floatRep = match(
+ "floatRep",
+ )`${noDecimalPtNumeral}|${decimalPtNumeral}|${scientificNotationNumeral}|${numericalSpecialRep}`;
+ const doubleRep = match(
+ "doubleRep",
+ )`${noDecimalPtNumeral}|${decimalPtNumeral}|${scientificNotationNumeral}|${numericalSpecialRep}`;
+ const duYearFrag = match(
+ "duYearFrag",
+ )`${unsignedNoDecimalPtNumeral}Y`;
+ const duMonthFrag = match(
+ "duMonthFrag",
+ )`${unsignedNoDecimalPtNumeral}M`;
+ const duDayFrag = match("duDayFrag")`${unsignedNoDecimalPtNumeral}D`;
+ const duHourFrag = match(
+ "duHourFrag",
+ )`${unsignedNoDecimalPtNumeral}H`;
+ const duMinuteFrag = match(
+ "duMinuteFrag",
+ )`${unsignedNoDecimalPtNumeral}M`;
+ const duSecondFrag = match(
+ "duSecondFrag",
+ )`(?:${unsignedNoDecimalPtNumeral}|${unsignedFullDecimalPtNumeral})S`;
+ const duYearMonthFrag = match(
+ "duYearMonthFrag",
+ )`${duYearFrag}${duMonthFrag}?|${duMonthFrag}`;
+ const duTimeFrag = match(
+ "duTimeFrag",
+ )`T(?:${duHourFrag}${duMinuteFrag}?${duSecondFrag}?|${duMinuteFrag}${duSecondFrag}?|${duSecondFrag})`;
+ const duDayTimeFrag = match(
+ "duDayTimeFrag",
+ )`${duDayFrag}${duTimeFrag}?|${duTimeFrag}`;
+ const durationLexicalRep = match(
+ "durationLexicalRep",
+ )`-?P(?:${duYearMonthFrag}${duDayTimeFrag}?|${duDayTimeFrag})`;
+ const yearFrag = match(
+ "yearFrag",
+ )`-?(?:[1-9]${digit}{3,}|0${digit}{3})`;
+ const monthFrag = match("monthFrag")`0[1-9]|1[0-2]`;
+ const dayFrag = match("dayFrag")`0[1-9]|[12]${digit}|3[01]`;
+ const hourFrag = match("hourFrag")`[01]${digit}|2[0-3]`;
+ const minuteFrag = match("minuteFrag")`[0-5]${digit}`;
+ const secondFrag = match(
+ "secondFrag",
+ )`[0-5]${digit}(?:\.${digit}+)?`;
+ const endOfDayFrag = match("endOfDayFrag")`24:00:00(?:\.0+)?`;
+ const timezoneFrag = match(
+ "timezoneFrag",
+ )`Z|[+-](?:(?:0${digit}|1[0-3]):${minuteFrag}|14:00)`;
+ const dateTimeLexicalRep = match("dateTimeLexicalRep", ($) => {
+ const components = stringSplit($, "-");
+ return components[0] === ""
+ ? dayOfMonthValuesConstraint(
+ substring(components[3], 0, 2),
+ components[2],
+ `-${components[1]}`,
+ )
+ : dayOfMonthValuesConstraint(
+ substring(components[2], 0, 2),
+ components[1],
+ components[0],
+ );
+ })`${yearFrag}-${monthFrag}-${dayFrag}T(?:${hourFrag}:${minuteFrag}:${secondFrag}|${endOfDayFrag})${timezoneFrag}?`;
+ const timeLexicalRep = match(
+ "timeLexicalRep",
+ )`(?:${hourFrag}:${minuteFrag}:${secondFrag}|${endOfDayFrag})${timezoneFrag}?`;
+ const dateLexicalRep = match("dateLexicalRep", ($) => {
+ const components = stringSplit($, "-");
+ return components[0] === ""
+ ? dayOfMonthValuesConstraint(
+ substring(components[3], 0, 2),
+ components[2],
+ `-${components[1]}`,
+ )
+ : dayOfMonthValuesConstraint(
+ substring(components[2], 0, 2),
+ components[1],
+ components[0],
+ );
+ })`${yearFrag}-${monthFrag}-${dayFrag}${timezoneFrag}?`;
+ const gYearMonthLexicalRep = match(
+ "gYearMonthLexicalRep",
+ )`${yearFrag}-${monthFrag}${timezoneFrag}?`;
+ const gYearLexicalRep = match(
+ "gYearLexicalRep",
+ )`${yearFrag}${timezoneFrag}?`;
+ const gMonthDayLexicalRep = match("gMonthDayLexicalRep", ($) => {
+ const components = stringSplit(substring($, 2), "-");
+ return dayOfMonthValuesConstraint(
+ substring(components[1], 0, 2),
+ components[0],
+ );
+ })`--${monthFrag}-${dayFrag}${timezoneFrag}?`;
+ const gDayLexicalRep = match(
+ "gDayLexicalRep",
+ )`---${dayFrag}${timezoneFrag}?`;
+ const gMonthLexicalRep = match(
+ "gMonthLexicalRep",
+ )`--${monthFrag}${timezoneFrag}?`;
+ const hexDigit = match("hexDigit")`[0-9a-fA-F]`;
+ const hexOctet = match("hexOctet")`${hexDigit}{2}`;
+ const hexBinary = match("hexBinary")`${hexOctet}*`;
+ const B04char = match("B04char")`[AQgw]`;
+ const B04 = match("B04")`${B04char}\u{20}?`;
+ const B16char = match("B16char")`[AEIMQUYcgkosw048]`;
+ const B16 = match("B16")`${B16char}\u{20}?`;
+ const B64char = match("B64char")`[A-Za-z0-9+/]`;
+ const B64 = match("B64")`${B64char}\u{20}?`;
+ const Padded8 = match("Padded8")`${B64}${B04}=\u{20}?=`;
+ const Padded16 = match("Padded16")`${B64}{2}${B16}=`;
+ const B64finalquad = match("B64finalquad")`${B64}{3}${B64char}`;
+ const B64final = match(
+ "B64final",
+ )`${B64finalquad}|${Padded16}|${Padded8}`;
+ const B64quad = match("B64quad")`${B64}{4}`;
+ const Base64Binary = match(
+ "Base64Binary",
+ )`(?:${B64quad}*${B64final})?`;
+ const CanonicalPadded = match(
+ "CanonicalPadded",
+ )`${B64char}{2}${B16char}=|${B64char}${B04char}==`;
+ const CanonicalQuad = match("CanonicalQuad")`${B64char}{4}`;
+ const Canonical·base64Binary = match(
+ "Canonical·base64Binary",
+ )`${CanonicalQuad}*${CanonicalPadded}?`;
+ const yearMonthDurationLexicalRep = match(
+ "yearMonthDurationLexicalRep",
+ )`-?P${duYearMonthFrag}`;
+ const dayTimeDurationLexicalRep = match(
+ "dayTimeDurationLexicalRep",
+ )`-?P${duDayTimeFrag}`;
+ const dateTimeStampLexicalRep = match(
+ "dateTimeStampLexicalRep",
+ ($) => {
+ const components = stringSplit($, "-");
+ return components[0] === ""
+ ? dayOfMonthValuesConstraint(
+ substring(components[3], 0, 2),
+ components[2],
+ `-${components[1]}`,
+ )
+ : dayOfMonthValuesConstraint(
+ substring(components[2], 0, 2),
+ components[1],
+ components[0],
+ );
+ },
+ )`${yearFrag}-${monthFrag}-${dayFrag}T(?:${hourFrag}:${minuteFrag}:${secondFrag}|${endOfDayFrag})${timezoneFrag}`;
+
+ return matchers;
+})();
--- /dev/null
+// ♓️🪡 सूत्र ∷ xsd/productions.test.js
+// ====================================================================
+//
+// Copyright © 2023 Lady [@ Lady’s Computer].
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+import { assert, assertStrictEquals } from "../dev-deps.js";
+import * as productions from "./productions.js";
+
+Deno.test("Exports a correctly‐named value for each production", () => {
+ for (const [name, matcher] of Object.entries(productions)) {
+ assert(matcher != null, name);
+ assertStrictEquals(matcher.name, name);
+ }
+});
--- /dev/null
+// ♓️🪡 सूत्र ∷ xsd/values.js
+// ====================================================================
+//
+// Copyright © 2023 Lady [@ Lady’s Computer].
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+export {
+ NAN as notANumber,
+ NEGATIVE_INFINITY as negativeInfinity,
+ NEGATIVE_ZERO as negativeZero,
+ POSITIVE_INFINITY as positiveInfinity,
+ POSITIVE_ZERO as positiveZero,
+ UNDEFINED as absent,
+} from "../deps.js";