@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
16 lines (15 loc) • 662 B
JavaScript
import { current, expect } from "./parser-context.js";
import { parseExpression } from "./parse-expression.js";
export function parseArrayLiteral(ctx) {
const start = expect(ctx, "Punctuation", "[").start;
const elements = [];
while (!(current(ctx).type === "Punctuation" && current(ctx).value === "]")) {
if (elements.length > 0)
expect(ctx, "Punctuation", ",");
if (current(ctx).type === "Punctuation" && current(ctx).value === "]")
break;
elements.push(parseExpression(ctx, 0));
}
const end = expect(ctx, "Punctuation", "]").end;
return { type: "ArrayLiteral", elements, start, end };
}