Actually, the message format is LLSD notation not python (d'oh)

This commit is contained in:
Casper Warden
2023-11-10 14:25:34 +00:00
parent 72d4eff2d8
commit 3c69b8f05e
26 changed files with 792 additions and 682 deletions

View File

@@ -0,0 +1,53 @@
import { LLSDTokenGenerator } from './LLSDTokenGenerator';
import { LLSDTokenType } from './LLSDTokenType';
import { LLSDNotationParser } from './LLSDNotationParser';
import { LLSDType } from './LLSDType';
export class LLSDArray
{
public static parse(gen: LLSDTokenGenerator): LLSDType[]
{
const arr: LLSDType[] = [];
let value: LLSDType | undefined = undefined;
while (true)
{
const token = gen();
if (token === undefined)
{
throw new Error('Unexpected end of input in array');
}
switch (token.type)
{
case LLSDTokenType.WHITESPACE:
{
continue;
}
case LLSDTokenType.ARRAY_END:
{
if (value !== undefined)
{
arr.push(value);
}
return arr;
}
case LLSDTokenType.COMMA:
{
if (value === undefined)
{
throw new Error('Expected value before comma');
}
arr.push(value);
value = undefined;
continue;
}
}
if (value !== undefined)
{
throw new Error('Comma or end brace expected');
}
value = LLSDNotationParser.parseValueToken(gen, token);
}
}
}