-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDSSArray.ts
33 lines (30 loc) · 1.04 KB
/
DSSArray.ts
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
31
32
33
import { Specifier } from './ts-refs/trans-render/dss/types.js'; //'./dss/types.js';
import { IObject$tring } from './ts-refs/trans-render/types.js';
export class DSSArray implements IObject$tring{
strVal: string | undefined;
objVal: any;
arrVal: any[] | undefined;
constructor(public s: string){}
async parse(){
const {parse} = await import('./dss/parse.js');
const split = this.s.split(' ').map(s => s.trim()).filter(s => !!s);
const specifiers: Specifier[] = [];
let lastDSS: Specifier | undefined;
let inAsMode = false;
for(const dss of split){
if(dss === 'and') continue;
if(dss === 'as'){
inAsMode = true;
continue;
}
if(lastDSS !== undefined && inAsMode){
lastDSS.as = dss as 'number';
inAsMode = false;
continue;
}
lastDSS = await parse(dss);
specifiers.push(lastDSS);
}
this.arrVal = specifiers;
}
}