@fraczak/k 5.0.2 → 5.1.1
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/Code-derivation-tests/built-in.mjs +7 -7
- package/Code-derivation-tests/dot.mjs +3 -3
- package/Code-derivation-tests/vector.mjs +4 -4
- package/TODO.md +36 -1
- package/codes.mjs +6 -2
- package/hash.mjs +1 -1
- package/package.json +2 -2
- package/parser.jison +4 -1
- package/parser.mjs +66 -58
- package/patterns.mjs +11 -11
- package/run.mjs +3 -3
- package/test-fingerprint.mjs +2 -2
- package/test.mjs +1 -1
- package/tests.sh +6 -0
- package/typing.mjs +13 -13
|
@@ -9,11 +9,11 @@ function is_result_code(code) {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
t('true', is_result_code('bool'));
|
|
13
|
-
t('false
|
|
14
|
-
t('1', is_result_code('int'));
|
|
15
|
-
t('12
|
|
16
|
-
t('"ala"', is_result_code('string'));
|
|
17
|
-
t('"a"
|
|
12
|
+
t('true', is_result_code('@bool'));
|
|
13
|
+
t('false $@bool', is_result_code('@bool'));
|
|
14
|
+
t('1', is_result_code('@int'));
|
|
15
|
+
t('12 $@int', is_result_code('@int'));
|
|
16
|
+
t('"ala"', is_result_code('@string'));
|
|
17
|
+
t('"a" $@string', is_result_code('@string'));
|
|
18
18
|
|
|
19
|
-
t('${} true
|
|
19
|
+
t('${} true $@bool 1 $@int "a" $@string', is_result_code('@string'));
|
|
@@ -11,12 +11,12 @@ $b {1 one, () two, () c} .one
|
|
|
11
11
|
const {input,output} = in_out(annotated);
|
|
12
12
|
// console.log({input,output});
|
|
13
13
|
assert.equal(input.type, annotated.representatives["b"]);
|
|
14
|
-
assert.equal(output.type, "int");
|
|
14
|
+
assert.equal(output.type, "@int");
|
|
15
15
|
console.log("OK");
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
t(`
|
|
19
|
-
$a = < int true, bool false > ;
|
|
19
|
+
$a = < @int true, @bool false > ;
|
|
20
20
|
$a .true
|
|
21
21
|
`, (annotated) => {
|
|
22
22
|
const {input,output} = in_out(annotated);
|
|
@@ -35,6 +35,6 @@ t(`
|
|
|
35
35
|
const {input,output} = in_out(annotated);
|
|
36
36
|
console.log({input,output});
|
|
37
37
|
assert.equal(input.pattern, '(...)');
|
|
38
|
-
assert.equal(output.type, "bool");
|
|
38
|
+
assert.equal(output.type, "@bool");
|
|
39
39
|
console.log("OK");
|
|
40
40
|
});
|
|
@@ -8,12 +8,12 @@ t('[]', (annotated) => {
|
|
|
8
8
|
console.log("OK");
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
t("
|
|
11
|
+
t("$@int [ $@int true, false ] .0", (annotated) => {
|
|
12
12
|
const {input,output} = in_out(annotated);
|
|
13
|
-
assert.equal(input.type, "int");
|
|
14
|
-
assert.equal(output.type, "bool");
|
|
13
|
+
assert.equal(input.type, "@int");
|
|
14
|
+
assert.equal(output.type, "@bool");
|
|
15
15
|
console.log("OK");
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
assert.throws(() => t(
|
|
18
|
+
assert.throws(() => t(`$@int [ $@int true, 12 ]`), /Error/);
|
|
19
19
|
console.log("OK");
|
package/TODO.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# To do list for canonical names
|
|
2
2
|
|
|
3
3
|
- [ ] Write a script to search for conflicting names
|
|
4
|
-
- [
|
|
4
|
+
- [*] Export a relation. i.e., rewrite it as a list of all
|
|
5
5
|
dependency definitions using canonical names
|
|
6
6
|
- [ ] Find a way of adding 'comments' or some way of 'tagging' the definitions
|
|
7
7
|
- [X] The definitions should be simplied by removing useless filters
|
|
@@ -16,3 +16,38 @@ filters corresponding to the patterns. [DONE]
|
|
|
16
16
|
|
|
17
17
|
The filer variables have to be renamed for normalization if they take part of
|
|
18
18
|
the canonical name calculation. [DONE]
|
|
19
|
+
|
|
20
|
+
## DESER
|
|
21
|
+
|
|
22
|
+
Serialization and deserialization of values.
|
|
23
|
+
|
|
24
|
+
### Can we define byte-array via prefix-free codes?
|
|
25
|
+
|
|
26
|
+
### Non prefix-free de/serialization
|
|
27
|
+
|
|
28
|
+
How programatically change encoding of a value? Is it possible to add some
|
|
29
|
+
annotations on the type graph?
|
|
30
|
+
|
|
31
|
+
Maybe it belongs to "execution environment", e.g., `k --deser JSON`,
|
|
32
|
+
`k --deser AVRO/UTF8`, where `JSON`, `AVRO`, `UTF8` are provided
|
|
33
|
+
by some external spec?
|
|
34
|
+
|
|
35
|
+
E.g.:
|
|
36
|
+
|
|
37
|
+
```DESER:
|
|
38
|
+
$ BsAqRMv = < BsAqRMv 0, BsAqRMv 1, KL _ >; -- $C0=<C0"0",C0"1",C1"_">;$C1={};
|
|
39
|
+
|
|
40
|
+
$ bnat = < {} _ @as '', bnat 0 @as '0' , bnat 1 >;
|
|
41
|
+
::UTF8::
|
|
42
|
+
{{} _} => ()
|
|
43
|
+
{$bnat 0} => \u2602
|
|
44
|
+
|
|
45
|
+
Ok, it looks for me like what we need is the "Monad", i.e., a set of
|
|
46
|
+
functions with side-effects (like `_log!`).
|
|
47
|
+
Get straight, we have `write_0!`, `write_1!`, `read_0!`, and `read_1!`,
|
|
48
|
+
or whatever is supported by the target.
|
|
49
|
+
|
|
50
|
+
#### How to implement `JSON`?
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
package/codes.mjs
CHANGED
|
@@ -9,7 +9,7 @@ const unitCode = function() {
|
|
|
9
9
|
}();
|
|
10
10
|
|
|
11
11
|
function isBuiltIn(code) {
|
|
12
|
-
return code.match(
|
|
12
|
+
return code.match(/^@(int|string|bool)$/);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function encodeCodeToString(code, codes = theRepository.codes) {
|
|
@@ -103,6 +103,7 @@ function minimize(codes) {
|
|
|
103
103
|
for (const name1 in classes) {
|
|
104
104
|
const [eq_names, dif_names] = classes[name1].reduce(
|
|
105
105
|
([eq_names, dif_names], name2) => {
|
|
106
|
+
// console.log(JSON.stringify({classes,codes,representatives,name1,name2},null,2));
|
|
106
107
|
if (are_different(classes, representatives, name1, name2, codes)) {
|
|
107
108
|
dif_names.push(name2);
|
|
108
109
|
} else {
|
|
@@ -152,6 +153,9 @@ function normalizeAll(codes, representatives) {
|
|
|
152
153
|
...code,
|
|
153
154
|
vector: representatives[code.vector] || code.vector,
|
|
154
155
|
};
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
throw new Error(`Unexpected code ${code.code}`);
|
|
155
159
|
}
|
|
156
160
|
}
|
|
157
161
|
|
|
@@ -190,7 +194,7 @@ function finalize(codes) {
|
|
|
190
194
|
}
|
|
191
195
|
|
|
192
196
|
function register(newCodes) {
|
|
193
|
-
const { codes, representatives } = finalize( {...
|
|
197
|
+
const { codes, representatives } = finalize( {...theRepository.codes,...newCodes});
|
|
194
198
|
const reps = Object.values(representatives).reduce((reps,rep) =>
|
|
195
199
|
({...reps, [rep]:rep})
|
|
196
200
|
, {});
|
package/hash.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fraczak/k",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "k-language for JSON-like data transformation",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepare": "jiwson -m es6 parser.jison -o parser.mjs",
|
|
8
|
-
"test": "node test.mjs; for f in Code-derivation-tests/*.mjs; do echo $f; node $f; done; node test-fingerprint.mjs"
|
|
8
|
+
"test": "node test.mjs; for f in Code-derivation-tests/*.mjs; do echo $f; node $f; done; node test-fingerprint.mjs; ./tests.sh"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
package/parser.jison
CHANGED
|
@@ -63,6 +63,7 @@ function fromEscString(escString) {
|
|
|
63
63
|
"?" return 'QMARK';
|
|
64
64
|
"|" return 'PIPE';
|
|
65
65
|
"^" return 'CARET';
|
|
66
|
+
"@" return 'AT';
|
|
66
67
|
\"([^"\\]|\\(.|\n))*\"|\'([^'\\]|\\(.|\n))*\' return 'STRING';
|
|
67
68
|
[a-zA-Z_][a-zA-Z0-9_?!]* return 'NAME';
|
|
68
69
|
0|[-]?[1-9][0-9]* return 'INT';
|
|
@@ -72,7 +73,7 @@ function fromEscString(escString) {
|
|
|
72
73
|
/lex
|
|
73
74
|
|
|
74
75
|
%token NAME STRING INT
|
|
75
|
-
%token LA LC LB LP RA RP RB RC EQ DOT COMMA SC COL DOLLAR PIPE CARET QMARK DOTS
|
|
76
|
+
%token LA LC LB LP RA RP RB RC EQ DOT COMMA SC COL DOLLAR PIPE CARET AT QMARK DOTS
|
|
76
77
|
%token EOF
|
|
77
78
|
|
|
78
79
|
%start input_with_eof
|
|
@@ -119,6 +120,7 @@ defs: { }
|
|
|
119
120
|
|
|
120
121
|
code
|
|
121
122
|
: name { $$ = { code: "ref", ref: $1.value, start: $1.start, end: $1.end}; }
|
|
123
|
+
| AT name { $$ = { code: "ref", ref: "@" + $2.value, start: $1.start, end: $2.end}; }
|
|
122
124
|
| codeDef { $$ = $1; }
|
|
123
125
|
;
|
|
124
126
|
|
|
@@ -216,6 +218,7 @@ exp
|
|
|
216
218
|
| lb list rb { $$ = {op: "vector", vector: $2, start: $1.start, end: $3.end}; }
|
|
217
219
|
| la list ra { $$ = {...union($2), start: $1.start, end: $3.end}; }
|
|
218
220
|
| name { $$ = {op: "ref", ref: $1.value, start: $1.start, end: $1.end}; }
|
|
221
|
+
| AT name { $$ = {op: "ref", ref: "@" + $2.value, start: $1.start, end: $2.end}; }
|
|
219
222
|
| lp rp { $$ = {...identity, start: $1.start, end: $2.end}; }
|
|
220
223
|
| lp comp rp { $$ = {...$2, start: $1.start, end: $3.end }; }
|
|
221
224
|
| str { $$ = {op: "str", str: $1.value, start: $1.start, end: $1.end }; }
|
package/parser.mjs
CHANGED
|
@@ -115,12 +115,12 @@ function fromEscString(escString) {
|
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
var parser = (function(){
|
|
118
|
-
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[4,6,8,10,12,14,16,30,38,40,
|
|
118
|
+
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[4,6,8,10,12,14,16,30,38,40,50,63],$V1=[1,10],$V2=[1,26],$V3=[1,27],$V4=[1,24],$V5=[1,22],$V6=[1,23],$V7=[1,25],$V8=[1,28],$V9=[1,11],$Va=[1,29],$Vb=[1,15],$Vc=[1,21],$Vd=[1,32],$Ve=[4,6,8,10,12,14,16,30,38,40,47,50,60,63],$Vf=[2,68],$Vg=[1,36],$Vh=[1,39],$Vi=[4,6,8,10,12,14,16,18,20,22,24,30,32,34,38,40,47,50,60,63],$Vj=[2,90],$Vk=[1,58],$Vl=[2,72],$Vm=[2,73],$Vn=[4,6,8,10,12,14,16,18,20,22,24,30,32,34,36,38,40,47,50,60,63],$Vo=[4,6,8],$Vp=[2,27],$Vq=[4,6,8,10,12,14,16,18,20,22,24,26,30,32,34,38,40,47,50,60,63],$Vr=[2,33],$Vs=[1,84],$Vt=[1,86],$Vu=[20,32],$Vv=[4,6,8,10,12,14,16,30,38,40,50,60,63],$Vw=[1,91],$Vx=[1,95],$Vy=[18,22,32],$Vz=[1,98],$VA=[2,50],$VB=[2,51],$VC=[1,110],$VD=[18,20,32],$VE=[2,84],$VF=[2,85],$VG=[2,86],$VH=[18,20,24,32];
|
|
119
119
|
var parser = {trace: function trace () { },
|
|
120
120
|
yy: {},
|
|
121
|
-
symbols_: {"error":2,"name":3,"NAME":4,"str":5,"STRING":6,"int":7,"INT":8,"la":9,"LA":10,"lc":11,"LC":12,"lb":13,"LB":14,"lp":15,"LP":16,"ra":17,"RA":18,"rc":19,"RC":20,"rb":21,"RB":22,"rp":23,"RP":24,"eq":25,"EQ":26,"dots":27,"DOTS":28,"dot":29,"DOT":30,"comma":31,"COMMA":32,"sc":33,"SC":34,"col":35,"COL":36,"dollar":37,"DOLLAR":38,"qmark":39,"QMARK":40,"incremental":41,"INCREMENTAL":42,"input_with_eof":43,"initialize_symbol_table":44,"defs":45,"comp":46,"EOF":47,"codeDef":48,"code":49,"
|
|
122
|
-
terminals_: {2:"error",4:"NAME",6:"STRING",8:"INT",10:"LA",12:"LC",14:"LB",16:"LP",18:"RA",20:"RC",22:"RB",24:"RP",26:"EQ",28:"DOTS",30:"DOT",32:"COMMA",34:"SC",36:"COL",38:"DOLLAR",40:"QMARK",42:"INCREMENTAL",47:"EOF",
|
|
123
|
-
productions_: [0,[3,1],[5,1],[7,1],[9,1],[11,1],[13,1],[15,1],[17,1],[19,1],[21,1],[23,1],[25,1],[27,1],[29,1],[31,1],[33,1],[35,1],[37,1],[39,1],[41,1],[43,4],[44,0],[44,1],[45,0],[45,5],[45,6],[49,1],[49,1],[48,3],[48,3],[48,3],[
|
|
121
|
+
symbols_: {"error":2,"name":3,"NAME":4,"str":5,"STRING":6,"int":7,"INT":8,"la":9,"LA":10,"lc":11,"LC":12,"lb":13,"LB":14,"lp":15,"LP":16,"ra":17,"RA":18,"rc":19,"RC":20,"rb":21,"RB":22,"rp":23,"RP":24,"eq":25,"EQ":26,"dots":27,"DOTS":28,"dot":29,"DOT":30,"comma":31,"COMMA":32,"sc":33,"SC":34,"col":35,"COL":36,"dollar":37,"DOLLAR":38,"qmark":39,"QMARK":40,"incremental":41,"INCREMENTAL":42,"input_with_eof":43,"initialize_symbol_table":44,"defs":45,"comp":46,"EOF":47,"codeDef":48,"code":49,"AT":50,"labelled_codes":51,"non_empty_labelled_codes":52,"code_label":53,"filter_":54,"labelled_filters":55,"filter":56,"non_empty_labelled_filters":57,"filter_label":58,"exp":59,"CARET":60,"labelled":61,"list":62,"PIPE":63,"non_empty_labelled":64,"comp_label":65,"non_empty_list":66,"$accept":0,"$end":1},
|
|
122
|
+
terminals_: {2:"error",4:"NAME",6:"STRING",8:"INT",10:"LA",12:"LC",14:"LB",16:"LP",18:"RA",20:"RC",22:"RB",24:"RP",26:"EQ",28:"DOTS",30:"DOT",32:"COMMA",34:"SC",36:"COL",38:"DOLLAR",40:"QMARK",42:"INCREMENTAL",47:"EOF",50:"AT",60:"CARET",63:"PIPE"},
|
|
123
|
+
productions_: [0,[3,1],[5,1],[7,1],[9,1],[11,1],[13,1],[15,1],[17,1],[19,1],[21,1],[23,1],[25,1],[27,1],[29,1],[31,1],[33,1],[35,1],[37,1],[39,1],[41,1],[43,4],[44,0],[44,1],[45,0],[45,5],[45,6],[49,1],[49,2],[49,1],[48,3],[48,3],[48,3],[51,0],[51,1],[52,1],[52,3],[53,2],[53,2],[53,2],[53,3],[53,3],[53,3],[54,2],[54,3],[54,3],[54,3],[54,3],[56,1],[56,3],[56,1],[55,0],[55,1],[57,1],[57,3],[58,1],[58,2],[58,2],[58,2],[58,3],[58,3],[58,3],[46,1],[46,2],[46,2],[59,3],[59,3],[59,3],[59,1],[59,2],[59,2],[59,3],[59,1],[59,1],[59,2],[59,2],[59,2],[59,2],[59,2],[59,1],[61,0],[61,1],[64,1],[64,3],[65,2],[65,2],[65,2],[65,3],[65,3],[65,3],[62,0],[62,1],[66,1],[66,3]],
|
|
124
124
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
|
|
125
125
|
/* this == yyval */
|
|
126
126
|
|
|
@@ -158,25 +158,28 @@ break;
|
|
|
158
158
|
case 27:
|
|
159
159
|
this.$ = { code: "ref", ref: $$[$0].value, start: $$[$0].start, end: $$[$0].end};
|
|
160
160
|
break;
|
|
161
|
-
case 28:
|
|
161
|
+
case 28:
|
|
162
|
+
this.$ = { code: "ref", ref: "@" + $$[$0].value, start: $$[$0-1].start, end: $$[$0].end};
|
|
163
|
+
break;
|
|
164
|
+
case 29: case 48: case 62: case 91:
|
|
162
165
|
this.$ = $$[$0];
|
|
163
166
|
break;
|
|
164
|
-
case
|
|
167
|
+
case 30:
|
|
165
168
|
if (Object.keys($$[$0-1]).length == 1)
|
|
166
169
|
this.$ = { code: "union", union: $$[$0-1], start: $$[$0-2].start, end: $$[$0].end };
|
|
167
170
|
else
|
|
168
171
|
this.$ = { code: "product", product: $$[$0-1], start: $$[$0-2].start, end: $$[$0].end };
|
|
169
172
|
break;
|
|
170
|
-
case
|
|
173
|
+
case 31:
|
|
171
174
|
this.$ = { code: "vector", vector: s.as_ref($$[$0-1]), start: $$[$0-2].start, end: $$[$0].end };
|
|
172
175
|
break;
|
|
173
|
-
case
|
|
176
|
+
case 32:
|
|
174
177
|
this.$ = { code: "union", union: $$[$0-1], start: $$[$0-2].start, end: $$[$0].end };
|
|
175
178
|
break;
|
|
176
|
-
case
|
|
179
|
+
case 33:
|
|
177
180
|
this.$ = {};
|
|
178
181
|
break;
|
|
179
|
-
case
|
|
182
|
+
case 34:
|
|
180
183
|
this.$ = $$[$0].reduce((r, lc) => {
|
|
181
184
|
if (r[lc.label])
|
|
182
185
|
anError(this._$,`Duplicate label '${lc.label}'.`);
|
|
@@ -184,49 +187,49 @@ case 33:
|
|
|
184
187
|
return r }
|
|
185
188
|
, {});
|
|
186
189
|
break;
|
|
187
|
-
case
|
|
190
|
+
case 35: case 53: case 92:
|
|
188
191
|
this.$ = [$$[$0]];
|
|
189
192
|
break;
|
|
190
|
-
case
|
|
193
|
+
case 36: case 54: case 93:
|
|
191
194
|
this.$ = [].concat($$[$0-2],$$[$0]);
|
|
192
195
|
break;
|
|
193
|
-
case
|
|
196
|
+
case 37: case 38: case 39:
|
|
194
197
|
this.$ = {label: $$[$0].value, code: $$[$0-1]};
|
|
195
198
|
break;
|
|
196
|
-
case
|
|
199
|
+
case 40: case 41: case 42:
|
|
197
200
|
this.$ = {label: $$[$0-2].value, code: $$[$0]};
|
|
198
201
|
break;
|
|
199
|
-
case
|
|
202
|
+
case 43:
|
|
200
203
|
this.$ = { type: "code", code: s.as_ref($$[$0]), start: $$[$0-1].start, end: $$[$0].end};
|
|
201
204
|
break;
|
|
202
|
-
case
|
|
205
|
+
case 44:
|
|
203
206
|
if ( !$$[$0-1].open && (Object.keys($$[$0-1].fields).length == 1))
|
|
204
207
|
this.$ = { type: "union", open: $$[$0-1].open, fields: $$[$0-1].fields, start: $$[$0-2].start, end: $$[$0].end};
|
|
205
208
|
else
|
|
206
209
|
this.$ = { type: null, open: $$[$0-1].open, fields: $$[$0-1].fields, start: $$[$0-2].start, end: $$[$0].end};
|
|
207
210
|
break;
|
|
208
|
-
case
|
|
211
|
+
case 45:
|
|
209
212
|
this.$ = { type: "union", open: $$[$0-1].open, fields: $$[$0-1].fields, start: $$[$0-2].start, end: $$[$0].end};
|
|
210
213
|
break;
|
|
211
|
-
case
|
|
214
|
+
case 46:
|
|
212
215
|
if ( !$$[$0-1].open && (Object.keys($$[$0-1].fields).length == 1))
|
|
213
216
|
this.$ = { type: "union", open: $$[$0-1].open, fields: $$[$0-1].fields, start: $$[$0-2].start, end: $$[$0].end};
|
|
214
217
|
else
|
|
215
218
|
this.$ = { type: "product", open: $$[$0-1].open, fields: $$[$0-1].fields, start: $$[$0-2].start, end: $$[$0].end};
|
|
216
219
|
break;
|
|
217
|
-
case
|
|
220
|
+
case 47:
|
|
218
221
|
this.$ = { type: "vector", vector: $$[$0-1], start: $$[$0-2].start, end: $$[$0].end };
|
|
219
222
|
break;
|
|
220
|
-
case
|
|
223
|
+
case 49:
|
|
221
224
|
this.$ = { name: $$[$0].value, ...$$[$0-2], start: $$[$0-2].start, end: $$[$0].end };
|
|
222
225
|
break;
|
|
223
|
-
case
|
|
226
|
+
case 50:
|
|
224
227
|
this.$ = { type: 'name', name: $$[$0].value, open: true, start: $$[$0].start, end: $$[$0].end};
|
|
225
228
|
break;
|
|
226
|
-
case
|
|
229
|
+
case 51:
|
|
227
230
|
this.$ = { fields: {}};
|
|
228
231
|
break;
|
|
229
|
-
case
|
|
232
|
+
case 52:
|
|
230
233
|
this.$ = $$[$0].reduce((r, lc) => {
|
|
231
234
|
if (lc.dots) {
|
|
232
235
|
r.open = true;
|
|
@@ -238,61 +241,64 @@ case 51:
|
|
|
238
241
|
return r }
|
|
239
242
|
, { fields: {} });
|
|
240
243
|
break;
|
|
241
|
-
case
|
|
244
|
+
case 55:
|
|
242
245
|
this.$ = {dots: true };
|
|
243
246
|
break;
|
|
244
|
-
case
|
|
247
|
+
case 56: case 57: case 58:
|
|
245
248
|
this.$ = {label: $$[$0].value, filter: $$[$0-1]};
|
|
246
249
|
break;
|
|
247
|
-
case
|
|
250
|
+
case 59: case 60: case 61:
|
|
248
251
|
this.$ = {label: $$[$0-2].value, filter: $$[$0]};
|
|
249
252
|
break;
|
|
250
|
-
case
|
|
253
|
+
case 63:
|
|
251
254
|
this.$ = {...comp($$[$0-1], $$[$0]), start: $$[$0-1].start, end:$$[$0].end};
|
|
252
255
|
break;
|
|
253
|
-
case
|
|
256
|
+
case 64:
|
|
254
257
|
this.$ = {op: 'caret', caret: $$[$0-1], start: $$[$0-1].start, end:$$[$0].end};
|
|
255
258
|
break;
|
|
256
|
-
case
|
|
259
|
+
case 65:
|
|
257
260
|
this.$ = {...$$[$0-1], start: $$[$0-2].start, end: $$[$0].end};
|
|
258
261
|
break;
|
|
259
|
-
case
|
|
262
|
+
case 66:
|
|
260
263
|
this.$ = {op: "vector", vector: $$[$0-1], start: $$[$0-2].start, end: $$[$0].end};
|
|
261
264
|
break;
|
|
262
|
-
case
|
|
265
|
+
case 67:
|
|
263
266
|
this.$ = {...union($$[$0-1]), start: $$[$0-2].start, end: $$[$0].end};
|
|
264
267
|
break;
|
|
265
|
-
case
|
|
268
|
+
case 68:
|
|
266
269
|
this.$ = {op: "ref", ref: $$[$0].value, start: $$[$0].start, end: $$[$0].end};
|
|
267
270
|
break;
|
|
268
|
-
case
|
|
271
|
+
case 69:
|
|
272
|
+
this.$ = {op: "ref", ref: "@" + $$[$0].value, start: $$[$0-1].start, end: $$[$0].end};
|
|
273
|
+
break;
|
|
274
|
+
case 70:
|
|
269
275
|
this.$ = {...identity, start: $$[$0-1].start, end: $$[$0].end};
|
|
270
276
|
break;
|
|
271
|
-
case
|
|
277
|
+
case 71:
|
|
272
278
|
this.$ = {...$$[$0-1], start: $$[$0-2].start, end: $$[$0].end };
|
|
273
279
|
break;
|
|
274
|
-
case
|
|
280
|
+
case 72:
|
|
275
281
|
this.$ = {op: "str", str: $$[$0].value, start: $$[$0].start, end: $$[$0].end };
|
|
276
282
|
break;
|
|
277
|
-
case
|
|
283
|
+
case 73:
|
|
278
284
|
this.$ = {op: "int", int: $$[$0].value, start: $$[$0].start, end: $$[$0].end };
|
|
279
285
|
break;
|
|
280
|
-
case
|
|
286
|
+
case 74: case 75: case 76:
|
|
281
287
|
this.$ = {op: "dot", dot: $$[$0].value, start: $$[$0-1].start, end: $$[$0].end };
|
|
282
288
|
break;
|
|
283
|
-
case
|
|
289
|
+
case 77:
|
|
284
290
|
this.$ = {op: "code", code: s.as_ref($$[$0]), start: $$[$0-1].start, end: $$[$0].end};
|
|
285
291
|
break;
|
|
286
|
-
case
|
|
292
|
+
case 78:
|
|
287
293
|
this.$ = {op: "filter", filter: $$[$0], start: $$[$0-1].start, end:$$[$0].end};
|
|
288
294
|
break;
|
|
289
|
-
case
|
|
295
|
+
case 79:
|
|
290
296
|
this.$ = {op: "pipe", start: $$[$0].start, end: $$[$0].end};
|
|
291
297
|
break;
|
|
292
|
-
case
|
|
298
|
+
case 80:
|
|
293
299
|
this.$ = {op: "product", product: []};
|
|
294
300
|
break;
|
|
295
|
-
case
|
|
301
|
+
case 81:
|
|
296
302
|
$$[$0].product.reduce( (labels, {label}) =>
|
|
297
303
|
{ if (labels[label])
|
|
298
304
|
anError(this._$,`Duplicate label '${label}'.`)
|
|
@@ -300,25 +306,25 @@ case 79:
|
|
|
300
306
|
return labels; }, {});
|
|
301
307
|
this.$ = $$[$0];
|
|
302
308
|
break;
|
|
303
|
-
case
|
|
309
|
+
case 82:
|
|
304
310
|
this.$ = {op: "product", product: [$$[$0]]};
|
|
305
311
|
break;
|
|
306
|
-
case
|
|
312
|
+
case 83:
|
|
307
313
|
$$[$0-2].product = [].concat($$[$0-2].product,$$[$0]); this.$ = $$[$0-2];
|
|
308
314
|
break;
|
|
309
|
-
case
|
|
315
|
+
case 84: case 85: case 86:
|
|
310
316
|
this.$ = {label: $$[$0].value, exp: $$[$0-1]};
|
|
311
317
|
break;
|
|
312
|
-
case
|
|
318
|
+
case 87: case 88: case 89:
|
|
313
319
|
this.$ = {label: $$[$0-2].value, exp: $$[$0]};
|
|
314
320
|
break;
|
|
315
|
-
case
|
|
321
|
+
case 90:
|
|
316
322
|
this.$ = [];
|
|
317
323
|
break;
|
|
318
324
|
}
|
|
319
325
|
},
|
|
320
|
-
table: [o($V0,[2,22],{43:1,44:2,41:3,42:[1,4]}),{1:[3]},o($V0,[2,24],{45:5}),o($V0,[2,23]),o($V0,[2,20]),{3:7,4:$V1,5:
|
|
321
|
-
defaultActions: {
|
|
326
|
+
table: [o($V0,[2,22],{43:1,44:2,41:3,42:[1,4]}),{1:[3]},o($V0,[2,24],{45:5}),o($V0,[2,23]),o($V0,[2,20]),{3:7,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,37:8,38:$V9,39:20,40:$Va,46:6,50:$Vb,59:9,63:$Vc},{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,47:[1,30],50:$Vb,59:31,60:$Vd,63:$Vc},o($Ve,$Vf,{25:35,26:$Vg}),{3:37,4:$V1,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,48:40,49:38,50:$Vh},o($Vi,[2,62]),o([4,6,8,10,12,14,16,18,20,22,24,26,30,32,34,36,38,40,47,50,60,63],[2,1]),o([4,10,12,14,50],[2,18]),{3:48,4:$V1,5:49,6:$V2,7:50,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,20:[2,80],29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:47,50:$Vb,59:9,61:44,63:$Vc,64:45,65:46},{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,22:$Vj,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:53,50:$Vb,59:9,62:51,63:$Vc,66:52},{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,18:$Vj,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:53,50:$Vb,59:9,62:54,63:$Vc,66:52},{3:55,4:$V1},{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,23:56,24:$Vk,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:57,50:$Vb,59:9,63:$Vc},o($Vi,$Vl),o($Vi,$Vm),{3:61,4:$V1,5:60,6:$V2,7:59,8:$V3},{3:64,4:$V1,9:67,10:$V4,11:68,12:$V5,13:69,14:$V6,15:66,16:$V7,37:65,38:$V9,54:63,56:62},o($Vi,[2,79]),o([4,6,8,10,12,14,16,20,28,30,38,40,50,63],[2,5]),o([4,6,8,10,12,14,16,22,30,38,40,50,63],[2,6]),o([4,6,8,10,12,14,16,18,28,30,38,40,50,63],[2,4]),o([4,6,8,10,12,14,16,24,28,30,38,40,50,63],[2,7]),o($Vn,[2,2]),o($Vn,[2,3]),o($Vo,[2,14]),o([4,10,12,14,16,38],[2,19]),{1:[2,21]},o($Vi,[2,63]),o($Vi,[2,64]),o($Vi,$Vf),{3:70,4:$V1,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,48:40,49:38,50:$Vh},{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:71,50:$Vb,59:9,63:$Vc},o($V0,[2,12]),o($Ve,$Vp,{25:72,26:$Vg}),o($Vi,[2,77]),{3:73,4:$V1},o($Vq,[2,29]),{3:78,4:$V1,5:79,6:$V2,7:80,8:$V3,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,20:$Vr,48:40,49:77,50:$Vh,51:74,52:75,53:76},{3:70,4:$V1,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,48:40,49:81,50:$Vh},{3:78,4:$V1,5:79,6:$V2,7:80,8:$V3,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,18:$Vr,48:40,49:77,50:$Vh,51:82,52:75,53:76},{19:83,20:$Vs},{20:[2,81],31:85,32:$Vt},o($Vu,[2,82]),{3:87,4:$V1,5:88,6:$V2,7:89,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,50:$Vb,59:31,60:$Vd,63:$Vc},o($Vv,$Vf,{35:90,36:$Vw}),o($Vv,$Vl,{35:92,36:$Vw}),o($Vv,$Vm,{35:93,36:$Vw}),{21:94,22:$Vx},o([18,22],[2,91],{31:96,32:$Vt}),o($Vy,[2,92],{11:12,13:13,9:14,15:16,5:17,7:18,29:19,39:20,59:31,3:33,37:34,4:$V1,6:$V2,8:$V3,10:$V4,12:$V5,14:$V6,16:$V7,30:$V8,38:$V9,40:$Va,50:$Vb,60:$Vd,63:$Vc}),{17:97,18:$Vz},o($Vi,[2,69]),o($Vi,[2,70]),{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,23:99,24:$Vk,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,50:$Vb,59:31,60:$Vd,63:$Vc},o($Vq,[2,11]),o($Vi,[2,74]),o($Vi,[2,75]),o($Vi,[2,76]),o($Vi,[2,78]),o($Vi,[2,48],{26:[1,100]}),o($Vi,$VA),{3:70,4:$V1,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,48:40,49:101,50:$Vh},{3:107,4:$V1,5:108,6:$V2,7:109,8:$V3,9:67,10:$V4,11:68,12:$V5,13:69,14:$V6,15:66,16:$V7,24:$VB,27:105,28:$VC,37:65,38:$V9,54:63,55:102,56:106,57:103,58:104},{3:107,4:$V1,5:108,6:$V2,7:109,8:$V3,9:67,10:$V4,11:68,12:$V5,13:69,14:$V6,15:66,16:$V7,18:$VB,27:105,28:$VC,37:65,38:$V9,54:63,55:111,56:106,57:103,58:104},{3:107,4:$V1,5:108,6:$V2,7:109,8:$V3,9:67,10:$V4,11:68,12:$V5,13:69,14:$V6,15:66,16:$V7,20:$VB,27:105,28:$VC,37:65,38:$V9,54:63,55:112,56:106,57:103,58:104},{3:64,4:$V1,9:67,10:$V4,11:68,12:$V5,13:69,14:$V6,15:66,16:$V7,37:65,38:$V9,54:63,56:113},o($Vq,$Vp),{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,33:114,34:[1,115],37:34,38:$V9,39:20,40:$Va,50:$Vb,59:31,60:$Vd,63:$Vc},{9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,48:116},o($Vq,[2,28]),{19:117,20:$Vs},o([18,20],[2,34],{31:118,32:$Vt}),o($VD,[2,35]),{3:119,4:$V1,5:120,6:$V2,7:121,8:$V3},o($Vo,$Vp,{35:122,36:$Vw}),{35:123,36:$Vw},{35:124,36:$Vw},{21:125,22:$Vx},{17:126,18:$Vz},o($Vi,[2,65]),o($Vq,[2,9]),{3:48,4:$V1,5:49,6:$V2,7:50,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:47,50:$Vb,59:9,63:$Vc,65:127},o([4,6,8,10,12,14,16,28,30,38,40,50,63],[2,15]),o($Vv,$Vf,{20:$VE,32:$VE}),o($Vv,$Vl,{20:$VF,32:$VF}),o($Vv,$Vm,{20:$VG,32:$VG}),{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:128,50:$Vb,59:9,63:$Vc},o($V0,[2,17]),{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:129,50:$Vb,59:9,63:$Vc},{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:130,50:$Vb,59:9,63:$Vc},o($Vi,[2,66]),o($Vq,[2,10]),{3:33,4:$V1,5:17,6:$V2,7:18,8:$V3,9:14,10:$V4,11:12,12:$V5,13:13,14:$V6,15:16,16:$V7,29:19,30:$V8,37:34,38:$V9,39:20,40:$Va,46:131,50:$Vb,59:9,63:$Vc},o($Vi,[2,67]),o($Vq,[2,8]),o($Vi,[2,71]),{3:132,4:$V1},o($Vq,[2,43]),{23:133,24:$Vk},o([18,20,24],[2,52],{31:134,32:$Vt}),o($VH,[2,53]),o($VH,[2,55]),{3:135,4:$V1,5:136,6:$V2,7:137,8:$V3},o($Vo,$VA,{35:138,36:$Vw}),{35:139,36:$Vw},{35:140,36:$Vw},o($VH,[2,13]),{17:141,18:$Vz},{19:142,20:$Vs},{21:143,22:$Vx},o($V0,[2,25]),o($V0,[2,16]),{34:[1,144]},o($Vq,[2,30]),{3:78,4:$V1,5:79,6:$V2,7:80,8:$V3,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,48:40,49:77,50:$Vh,53:145},o($VD,[2,37]),o($VD,[2,38]),o($VD,[2,39]),{3:70,4:$V1,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,48:40,49:146,50:$Vh},{3:70,4:$V1,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,48:40,49:147,50:$Vh},{3:70,4:$V1,9:43,10:$V4,11:41,12:$V5,13:42,14:$V6,48:40,49:148,50:$Vh},o($Vq,[2,31]),o($Vq,[2,32]),o($Vu,[2,83]),o($Vu,[2,87],{11:12,13:13,9:14,15:16,5:17,7:18,29:19,39:20,59:31,3:33,37:34,4:$V1,6:$V2,8:$V3,10:$V4,12:$V5,14:$V6,16:$V7,30:$V8,38:$V9,40:$Va,50:$Vb,60:$Vd,63:$Vc}),o($Vu,[2,88],{11:12,13:13,9:14,15:16,5:17,7:18,29:19,39:20,59:31,3:33,37:34,4:$V1,6:$V2,8:$V3,10:$V4,12:$V5,14:$V6,16:$V7,30:$V8,38:$V9,40:$Va,50:$Vb,60:$Vd,63:$Vc}),o($Vu,[2,89],{11:12,13:13,9:14,15:16,5:17,7:18,29:19,39:20,59:31,3:33,37:34,4:$V1,6:$V2,8:$V3,10:$V4,12:$V5,14:$V6,16:$V7,30:$V8,38:$V9,40:$Va,50:$Vb,60:$Vd,63:$Vc}),o($Vy,[2,93],{11:12,13:13,9:14,15:16,5:17,7:18,29:19,39:20,59:31,3:33,37:34,4:$V1,6:$V2,8:$V3,10:$V4,12:$V5,14:$V6,16:$V7,30:$V8,38:$V9,40:$Va,50:$Vb,60:$Vd,63:$Vc}),o($Vi,[2,49]),o($Vq,[2,44]),{3:107,4:$V1,5:108,6:$V2,7:109,8:$V3,9:67,10:$V4,11:68,12:$V5,13:69,14:$V6,15:66,16:$V7,27:105,28:$VC,37:65,38:$V9,54:63,56:106,58:149},o($VH,[2,56]),o($VH,[2,57]),o($VH,[2,58]),{3:64,4:$V1,9:67,10:$V4,11:68,12:$V5,13:69,14:$V6,15:66,16:$V7,37:65,38:$V9,54:63,56:150},{3:64,4:$V1,9:67,10:$V4,11:68,12:$V5,13:69,14:$V6,15:66,16:$V7,37:65,38:$V9,54:63,56:151},{3:64,4:$V1,9:67,10:$V4,11:68,12:$V5,13:69,14:$V6,15:66,16:$V7,37:65,38:$V9,54:63,56:152},o($Vq,[2,45]),o($Vq,[2,46]),o($Vq,[2,47]),o($V0,[2,26]),o($VD,[2,36]),o($VD,[2,40]),o($VD,[2,41]),o($VD,[2,42]),o($VH,[2,54]),o($VH,[2,59]),o($VH,[2,60]),o($VH,[2,61])],
|
|
327
|
+
defaultActions: {30:[2,21]},
|
|
322
328
|
parseError: function parseError (str, hash) {
|
|
323
329
|
if (hash.recoverable) {
|
|
324
330
|
this.trace(str);
|
|
@@ -830,24 +836,26 @@ case 17:return 38;
|
|
|
830
836
|
break;
|
|
831
837
|
case 18:return 40;
|
|
832
838
|
break;
|
|
833
|
-
case 19:return
|
|
839
|
+
case 19:return 63;
|
|
840
|
+
break;
|
|
841
|
+
case 20:return 60;
|
|
834
842
|
break;
|
|
835
|
-
case
|
|
843
|
+
case 21:return 50;
|
|
836
844
|
break;
|
|
837
|
-
case
|
|
845
|
+
case 22:return 6;
|
|
838
846
|
break;
|
|
839
|
-
case
|
|
847
|
+
case 23:return 4;
|
|
840
848
|
break;
|
|
841
|
-
case
|
|
849
|
+
case 24:return 8;
|
|
842
850
|
break;
|
|
843
|
-
case
|
|
851
|
+
case 25:return 42;
|
|
844
852
|
break;
|
|
845
|
-
case
|
|
853
|
+
case 26:return 47;
|
|
846
854
|
break;
|
|
847
855
|
}
|
|
848
856
|
},
|
|
849
|
-
rules: [/^(?:[/][*]([^*]*[*]+[^*/])*[^*]*[*]+[/])/,/^(?:(\/\/|#|%|--|\\)[^\n]*)/,/^(?:\s+)/,/^(?:<)/,/^(?:\{)/,/^(?:\[)/,/^(?:\()/,/^(?:>)/,/^(?:\})/,/^(?:\])/,/^(?:\))/,/^(?:=)/,/^(?:\.\.\.)/,/^(?:\.)/,/^(?:,)/,/^(?:;)/,/^(?::)/,/^(?:\$)/,/^(?:\?)/,/^(?:\|)/,/^(?:\^)/,/^(?:"([^"\\]|\\(.|\n))*"|'([^'\\]|\\(.|\n))*')/,/^(?:[a-zA-Z_][a-zA-Z0-9_?!]*)/,/^(?:0|[-]?[1-9][0-9]*)/,/^(?:\+\+\+)/,/^(?:$)/],
|
|
850
|
-
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],"inclusive":true}}
|
|
857
|
+
rules: [/^(?:[/][*]([^*]*[*]+[^*/])*[^*]*[*]+[/])/,/^(?:(\/\/|#|%|--|\\)[^\n]*)/,/^(?:\s+)/,/^(?:<)/,/^(?:\{)/,/^(?:\[)/,/^(?:\()/,/^(?:>)/,/^(?:\})/,/^(?:\])/,/^(?:\))/,/^(?:=)/,/^(?:\.\.\.)/,/^(?:\.)/,/^(?:,)/,/^(?:;)/,/^(?::)/,/^(?:\$)/,/^(?:\?)/,/^(?:\|)/,/^(?:\^)/,/^(?:@)/,/^(?:"([^"\\]|\\(.|\n))*"|'([^'\\]|\\(.|\n))*')/,/^(?:[a-zA-Z_][a-zA-Z0-9_?!]*)/,/^(?:0|[-]?[1-9][0-9]*)/,/^(?:\+\+\+)/,/^(?:$)/],
|
|
858
|
+
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26],"inclusive":true}}
|
|
851
859
|
});
|
|
852
860
|
return lexer;
|
|
853
861
|
})();
|
package/patterns.mjs
CHANGED
|
@@ -174,12 +174,12 @@ function patterns(representatives, rels) {
|
|
|
174
174
|
case "int":
|
|
175
175
|
rel.patterns = [];
|
|
176
176
|
rel.patterns[0] = rootDef.typePatternGraph.addNewNode();
|
|
177
|
-
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('int');
|
|
177
|
+
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('@int');
|
|
178
178
|
break;
|
|
179
179
|
case "str":
|
|
180
180
|
rel.patterns = [];
|
|
181
181
|
rel.patterns[0] = rootDef.typePatternGraph.addNewNode();
|
|
182
|
-
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('string');
|
|
182
|
+
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('@string');
|
|
183
183
|
break;
|
|
184
184
|
case "identity":
|
|
185
185
|
rel.patterns = [];
|
|
@@ -359,39 +359,39 @@ function patterns(representatives, rels) {
|
|
|
359
359
|
case "true":
|
|
360
360
|
case "false":
|
|
361
361
|
rel.patterns[0] = rootDef.typePatternGraph.addNewNode();
|
|
362
|
-
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('bool');
|
|
362
|
+
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('@bool');
|
|
363
363
|
break;
|
|
364
364
|
case "PLUS":
|
|
365
365
|
case "TIMES":
|
|
366
|
-
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('int');
|
|
366
|
+
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('@int');
|
|
367
367
|
rel.patterns[0] = rootDef.typePatternGraph.addNewNode({pattern: '[]'}, {"vector-member": [rel.patterns[1]]});
|
|
368
368
|
break;
|
|
369
369
|
case "CONCAT":
|
|
370
|
-
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('string');
|
|
370
|
+
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('@string');
|
|
371
371
|
rel.patterns[0] = rootDef.typePatternGraph.addNewNode({pattern: '[]'}, {"vector-member": [rel.patterns[1]]});
|
|
372
372
|
break;
|
|
373
373
|
case "toVEC":
|
|
374
|
-
rel.patterns[0] = rootDef.typePatternGraph.getTypeId('string')
|
|
374
|
+
rel.patterns[0] = rootDef.typePatternGraph.getTypeId('@string')
|
|
375
375
|
rel.patterns[1] = rootDef.typePatternGraph.addNewNode({pattern: '[]'}, {"vector-member": [rel.patterns[0]]});
|
|
376
376
|
break;
|
|
377
377
|
case "toDateMsec":
|
|
378
378
|
rel.patterns[0] = rootDef.typePatternGraph.addNewNode();
|
|
379
|
-
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('int');
|
|
379
|
+
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('@int');
|
|
380
380
|
break;
|
|
381
381
|
case "toJSON":
|
|
382
382
|
rel.patterns[0] = rootDef.typePatternGraph.addNewNode();
|
|
383
|
-
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('string');
|
|
383
|
+
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('@string');
|
|
384
384
|
break;
|
|
385
385
|
case "toDateStr":
|
|
386
386
|
rel.patterns[0] = rootDef.typePatternGraph.addNewNode();
|
|
387
|
-
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('string');
|
|
387
|
+
rel.patterns[1] = rootDef.typePatternGraph.getTypeId('@string');
|
|
388
388
|
break;
|
|
389
389
|
case "GT":
|
|
390
390
|
case "EQ":
|
|
391
391
|
rel.patterns[0] = rel.patterns[1] = rootDef.typePatternGraph.addNewNode({pattern: '[]'}, {"vector-member": [rootDef.typePatternGraph.addNewNode()]});
|
|
392
392
|
break;
|
|
393
393
|
case "fromJSON":
|
|
394
|
-
rel.patterns[0] = rootDef.typePatternGraph.getTypeId('string');
|
|
394
|
+
rel.patterns[0] = rootDef.typePatternGraph.getTypeId('@string');
|
|
395
395
|
rel.patterns[1] = rootDef.typePatternGraph.addNewNode();
|
|
396
396
|
break;
|
|
397
397
|
case "CONS": {
|
|
@@ -405,7 +405,7 @@ function patterns(representatives, rels) {
|
|
|
405
405
|
rel.patterns[1] = rootDef.typePatternGraph.addNewNode({pattern: '{}'}, {"car": [member], "cdr": [rel.patterns[0]]});
|
|
406
406
|
}; break;
|
|
407
407
|
case "DIV": {
|
|
408
|
-
const intId = rootDef.typePatternGraph.getTypeId('int');
|
|
408
|
+
const intId = rootDef.typePatternGraph.getTypeId('@int');
|
|
409
409
|
rel.patterns[0] = rootDef.typePatternGraph.addNewNode({pattern: '[]'}, {"vector-member": [intId]});
|
|
410
410
|
rel.patterns[1] = rootDef.typePatternGraph.addNewNode({pattern: '{}'}, {"div": [intId], "rem": [intId]});
|
|
411
411
|
}; break;
|
package/run.mjs
CHANGED
|
@@ -68,9 +68,9 @@ const builtin = {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
const codes = {
|
|
71
|
-
int: (x) => Number.isInteger(x),
|
|
72
|
-
string: (x) => x instanceof String || "string" === typeof x,
|
|
73
|
-
bool: (x) => x === true || x === false,
|
|
71
|
+
"@int": (x) => Number.isInteger(x),
|
|
72
|
+
"@string": (x) => x instanceof String || "string" === typeof x,
|
|
73
|
+
"@bool": (x) => x === true || x === false,
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
function verify(code, value) {
|
package/test-fingerprint.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import hash from './hash.mjs';
|
|
|
5
5
|
`
|
|
6
6
|
$nat = < {} zero, nat succ>;
|
|
7
7
|
$pair = {nat x, nat y};
|
|
8
|
-
$b = {int"x", bool y};
|
|
9
|
-
$vector = [int];
|
|
8
|
+
$b = {@int"x", @bool y};
|
|
9
|
+
$vector = [@int];
|
|
10
10
|
$tree = <{nat value, tree left, tree right} binary, nat leaf, {nat value, tree tree} unary, [tree] list_of_trees>;
|
|
11
11
|
|
|
12
12
|
succ = { $nat succ} $nat;
|
package/test.mjs
CHANGED
package/tests.sh
ADDED
package/typing.mjs
CHANGED
|
@@ -401,14 +401,14 @@ class TypePatternGraph {
|
|
|
401
401
|
case 'type': {
|
|
402
402
|
const code = codes.find(p2.type);
|
|
403
403
|
switch (code.code) {
|
|
404
|
-
case 'int':
|
|
404
|
+
case '@int':
|
|
405
405
|
// supports (2 .2) which returns unit
|
|
406
406
|
if (p1.fields.every(x => `${x}`.match(/^[0-9]+$/)))
|
|
407
407
|
return p2;
|
|
408
408
|
break;
|
|
409
|
-
case 'string':
|
|
409
|
+
case '@string':
|
|
410
410
|
return p2;
|
|
411
|
-
case 'bool':
|
|
411
|
+
case '@bool':
|
|
412
412
|
if (p1.fields.every(x => `${x}`.match(/^true|false$/)))
|
|
413
413
|
return p2;
|
|
414
414
|
break;
|
|
@@ -471,14 +471,14 @@ class TypePatternGraph {
|
|
|
471
471
|
case 'type':{
|
|
472
472
|
const code = codes.find(p2.type);
|
|
473
473
|
switch (code.code) {
|
|
474
|
-
case 'int':
|
|
474
|
+
case '@int':
|
|
475
475
|
// supports (2 .2) which returns unit
|
|
476
476
|
if (p1.fields.every(x => `${x}`.match(/^[0-9]+$/)))
|
|
477
477
|
return p2;
|
|
478
478
|
break;
|
|
479
|
-
case 'string':
|
|
479
|
+
case '@string':
|
|
480
480
|
return p2;
|
|
481
|
-
case 'bool':
|
|
481
|
+
case '@bool':
|
|
482
482
|
if (p1.fields.every(x => `${x}`.match(/^true|false$/)))
|
|
483
483
|
return p2;
|
|
484
484
|
break;
|
|
@@ -508,13 +508,13 @@ class TypePatternGraph {
|
|
|
508
508
|
case 'type':{
|
|
509
509
|
const code = codes.find(p2.type);
|
|
510
510
|
switch (code.code) {
|
|
511
|
-
case 'int':
|
|
511
|
+
case '@int':
|
|
512
512
|
if (p1.fields.every(x => `${x}`.match(/^[0-9]+$/)))
|
|
513
513
|
return p2;
|
|
514
514
|
break;
|
|
515
|
-
case 'string':
|
|
515
|
+
case '@string':
|
|
516
516
|
return p2;
|
|
517
|
-
case 'bool':
|
|
517
|
+
case '@bool':
|
|
518
518
|
if (p1.fields.every(x => `${x}`.match(/^true|false$/)))
|
|
519
519
|
return p2;
|
|
520
520
|
break;
|
|
@@ -645,9 +645,9 @@ class TypePatternGraph {
|
|
|
645
645
|
if (new_pattern.pattern == 'type') {
|
|
646
646
|
const code = codes.find(new_pattern.type);
|
|
647
647
|
switch (code.code) {
|
|
648
|
-
case 'int':
|
|
649
|
-
case 'string':
|
|
650
|
-
case 'bool': {
|
|
648
|
+
case '@int':
|
|
649
|
+
case '@string':
|
|
650
|
+
case '@bool': {
|
|
651
651
|
// all edges are goin to unit type
|
|
652
652
|
const unit_id = this.getTypeId(unitCode);
|
|
653
653
|
for (const lab in this.edges[new_id]) {
|
|
@@ -667,7 +667,7 @@ class TypePatternGraph {
|
|
|
667
667
|
const target_type_id = this.getTypeId(code.vector);
|
|
668
668
|
|
|
669
669
|
this.edges[new_id] = {
|
|
670
|
-
'vector-member': asSet([ target_type_id, ...Object.values(this.edges[new_id])])
|
|
670
|
+
'vector-member': asSet([ target_type_id, ...[].concat(...Object.values(this.edges[new_id]))])
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
673
|
}
|