UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

35 lines (34 loc) 1.11 kB
import { current, advance } from "../parser/parser-context.js"; export const booleansPlugin = { name: "booleans", parsePrefix: (ctx) => { const tok = current(ctx); if (tok.type === "Boolean") { advance(ctx); return { type: "BooleanLiteral", value: tok.value === "true", start: tok.start, end: tok.end, }; } if (tok.type === "Null") { advance(ctx); return { type: "NullLiteral", value: null, start: tok.start, end: tok.end }; } if (tok.type === "Undefined") { advance(ctx); return { type: "UndefinedLiteral", value: undefined, start: tok.start, end: tok.end }; } return null; }, evaluate: (node) => { if (node.type === "BooleanLiteral") return { value: node.value }; if (node.type === "NullLiteral") return { value: null }; if (node.type === "UndefinedLiteral") return { value: undefined }; return null; }, };