@bablr/language-en-cstml-json 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Conrad Buck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @bablr/language-en-cstml-json
2
+
3
+ Defines CSTML-flavored JSON. Includes `NaN` as an expression type and forbids unpaired surrogates.
package/lib/grammar.js ADDED
@@ -0,0 +1,45 @@
1
+ /* @macrome
2
+ * @generatedby @bablr/macrome-generator-bablr
3
+ * @generatedfrom ./grammar.macro.js#0a642a38394d3786460fc65bbdb11a747007cd42
4
+ * This file is autogenerated. Please do not edit it directly.
5
+ * When editing run `npx macrome watch` then change the file this is generated from.
6
+ */
7
+ import _applyDecs from "@babel/runtime/helpers/applyDecs2305";
8
+ var _JSON$grammar;
9
+ let _initProto, _NaNDecs;
10
+ import { re, spam as m } from '@bablr/boot';
11
+ import { extendLanguage, o, eat, match } from '@bablr/helpers/grammar';
12
+ import { CoveredBy, Node, InjectFrom } from '@bablr/helpers/decorators';
13
+ import * as JSON from '@bablr/language-en-json';
14
+ import * as productions from '@bablr/helpers/productions';
15
+ import { buildString } from '@bablr/helpers/builders';
16
+ export const canonicalURL = 'https://bablr.org/languages/core/en/cstml-json';
17
+ export const {
18
+ dependencies
19
+ } = JSON;
20
+ export const getCooked = (escapeNode, span, ctx) => {
21
+ let cooked = JSON.getCooked(escapeNode, span, ctx);
22
+ if (cooked >= '\uD800' && cooked <= '\uDFFF') {
23
+ throw new Error('unpaired surrogates are invalid in CSTML JSON');
24
+ }
25
+ return cooked;
26
+ };
27
+ export const grammar = class BABLRVMInstructionGrammar extends (_JSON$grammar = JSON.grammar) {
28
+ static {
29
+ [_initProto] = _applyDecs(this, [[_NaNDecs, 2, "NaN"]], [], 0, void 0, _JSON$grammar).e;
30
+ }
31
+ constructor(...args) {
32
+ super(...args);
33
+ _initProto(this);
34
+ }
35
+ *[(_NaNDecs = [CoveredBy('Expression'), Node], "Expression")](props) {
36
+ if (yield match('NaN')) {
37
+ yield eat(m`<NaN />`);
38
+ } else {
39
+ yield* super.Expression(props);
40
+ }
41
+ }
42
+ *NaN() {
43
+ yield eat(m`sigilToken: <*Keyword 'NaN' />`);
44
+ }
45
+ };
@@ -0,0 +1,36 @@
1
+ import { re, spam as m } from '@bablr/boot';
2
+ import { extendLanguage, o, eat, match } from '@bablr/helpers/grammar';
3
+ import { CoveredBy, Node, InjectFrom } from '@bablr/helpers/decorators';
4
+ import * as JSON from '@bablr/language-en-json';
5
+ import * as productions from '@bablr/helpers/productions';
6
+ import { buildString } from '@bablr/helpers/builders';
7
+
8
+ export const canonicalURL = 'https://bablr.org/languages/core/en/cstml-json';
9
+
10
+ export const { dependencies } = JSON;
11
+
12
+ export const getCooked = (escapeNode, span, ctx) => {
13
+ let cooked = JSON.getCooked(escapeNode, span, ctx);
14
+
15
+ if (cooked >= '\uD800' && cooked <= '\uDFFF') {
16
+ throw new Error('unpaired surrogates are invalid in CSTML JSON');
17
+ }
18
+
19
+ return cooked;
20
+ };
21
+
22
+ export const grammar = class BABLRVMInstructionGrammar extends JSON.grammar {
23
+ *Expression(props) {
24
+ if (yield match('NaN')) {
25
+ yield eat(m`<NaN />`);
26
+ } else {
27
+ yield* super.Expression(props);
28
+ }
29
+ }
30
+
31
+ @CoveredBy('Expression')
32
+ @Node
33
+ *NaN() {
34
+ yield eat(m`sigilToken: <*Keyword 'NaN' />`);
35
+ }
36
+ };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@bablr/language-en-cstml-json",
3
+ "version": "0.1.0",
4
+ "description": "A BABLR language for CSTML-style JSON",
5
+ "engines": {
6
+ "node": ">=12.0.0"
7
+ },
8
+ "type": "module",
9
+ "exports": {
10
+ ".": "./lib/grammar.js",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": [
14
+ "lib/**/*.js"
15
+ ],
16
+ "sideEffects": false,
17
+ "scripts": {
18
+ "build": "macrome build",
19
+ "watch": "macrome watch",
20
+ "clean": "macrome clean"
21
+ },
22
+ "dependencies": {
23
+ "@babel/runtime": "^7.22.15",
24
+ "@bablr/agast-helpers": "0.6.0",
25
+ "@bablr/agast-vm-helpers": "0.6.0",
26
+ "@bablr/helpers": "0.21.1",
27
+ "@bablr/language-en-json": "0.9.0"
28
+ },
29
+ "devDependencies": {
30
+ "@bablr/macrome": "^0.1.3",
31
+ "@bablr/macrome-generator-bablr": "^0.3.2",
32
+ "@bablr/boot": "^0.7.0",
33
+ "@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#49f5952efed27f94ee9b94340eb1563c440bf64e",
34
+ "enhanced-resolve": "^5.12.0",
35
+ "eslint": "^8.47.0",
36
+ "eslint-import-resolver-enhanced-resolve": "^1.0.5",
37
+ "eslint-plugin-import": "^2.27.5",
38
+ "prettier": "^2.0.5"
39
+ },
40
+ "keywords": [
41
+ "bablr-language",
42
+ "grammar",
43
+ "english",
44
+ "comment",
45
+ "c"
46
+ ],
47
+ "repository": "git@github.com:bablr-lang/language-en-cstml-json.git",
48
+ "homepage": "https://github.com/bablr-lang/language-en-cstml-json",
49
+ "author": "Conrad Buck <conartist6@gmail.com>",
50
+ "license": "MIT"
51
+ }