/
prsSet.js
30 lines (30 loc) · 843 Bytes
/
prsSet.js
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
27
28
29
30
import { tryParse } from 'trans-render/lib/prs/tryParse.js';
const localPropToSet = String.raw `(?<localPropToSet>[\w\-\:\|\+]+)`;
const toDest = String.raw `(?<!\\)To(?<to>.*)`;
const reSetStatements = [
{
regExp: new RegExp(String.raw `^${localPropToSet}${toDest}`),
defaultVals: {}
},
{
regExp: new RegExp(String.raw `^${localPropToSet}`),
defaultVals: {
to: '$i'
}
}
];
export function prsSet(self) {
const { Set } = self;
const setRules = [];
for (const setS of Set) {
const test = tryParse(setS, reSetStatements);
if (test === null)
throw 'PE';
test.localPropToSet = test.localPropToSet?.replaceAll(':', ".");
console.log({ setS, test });
setRules.push(test);
}
return {
setRules
};
}