osury 0.23.0 → 0.24.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/package.json +1 -1
- package/src/BackendReScript.res.mjs +15 -2
package/package.json
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
import * as Core__Array from "@rescript/core/src/Core__Array.res.mjs";
|
|
4
4
|
import * as Core__Option from "@rescript/core/src/Core__Option.res.mjs";
|
|
5
5
|
|
|
6
|
+
function quoteTag(tag) {
|
|
7
|
+
let needsQuoting = tag.split("").some(c => {
|
|
8
|
+
let code = c.charCodeAt(0);
|
|
9
|
+
return !(code >= 97.0 && code <= 122.0 || code >= 65.0 && code <= 90.0 || code >= 48.0 && code <= 57.0 || code === 95.0);
|
|
10
|
+
});
|
|
11
|
+
if (needsQuoting) {
|
|
12
|
+
return `"` + tag + `"`;
|
|
13
|
+
} else {
|
|
14
|
+
return tag;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
function printPrimitive(p) {
|
|
7
19
|
switch (p) {
|
|
8
20
|
case "PString" :
|
|
@@ -36,7 +48,7 @@ function printType(t) {
|
|
|
36
48
|
case "Named" :
|
|
37
49
|
return t._0;
|
|
38
50
|
case "Enum" :
|
|
39
|
-
let variants = t._0.map(v => `#` + v).join(" | ");
|
|
51
|
+
let variants = t._0.map(v => `#` + quoteTag(v)).join(" | ");
|
|
40
52
|
return `[` + variants + `]`;
|
|
41
53
|
case "InlineRecord" :
|
|
42
54
|
return printRecord(t._0);
|
|
@@ -79,7 +91,7 @@ function printVariantCase(c) {
|
|
|
79
91
|
|
|
80
92
|
function printVariantCases(cases) {
|
|
81
93
|
let caseStrs = cases.map(printVariantCase);
|
|
82
|
-
return `[` + caseStrs.map(c => `#` + c).join(" | ") + `]`;
|
|
94
|
+
return `[` + caseStrs.map(c => `#` + quoteTag(c)).join(" | ") + `]`;
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
function printAnnotation(ann) {
|
|
@@ -130,6 +142,7 @@ function print(module_) {
|
|
|
130
142
|
}
|
|
131
143
|
|
|
132
144
|
export {
|
|
145
|
+
quoteTag,
|
|
133
146
|
printPrimitive,
|
|
134
147
|
printType,
|
|
135
148
|
printField,
|