novy-syndicate/src/gen/rewrite.ts

228 lines
8.1 KiB
TypeScript

import * as _ from "@preserves/core";
export const $__ = Symbol.for("_");
export const $and = Symbol.for("and");
export const $arr = Symbol.for("arr");
export const $bind = Symbol.for("bind");
export const $compound = Symbol.for("compound");
export const $dict = Symbol.for("dict");
export const $lit = Symbol.for("lit");
export const $not = Symbol.for("not");
export const $rec = Symbol.for("rec");
export const $ref = Symbol.for("ref");
export const $rewrite = Symbol.for("rewrite");
export const __lit3 = Symbol.for("/");
export type ConstructorSpec = (
_.Record<(typeof $rec), [_val, number], _ptr> |
_.Record<(typeof $arr), [number], _ptr> |
_.Record<(typeof $dict), [], _ptr>
);
export const Pattern = _.Record.makeConstructor<{
"_field0": [
_.Record<(typeof $__), [], _ptr>,
_.Record<(typeof $bind), [symbol, Pattern], _ptr>,
_.Record<(typeof $and), [Array<Pattern>], _ptr>,
_.Record<(typeof $not), [Pattern], _ptr>,
_.Record<(typeof $lit), [_val], _ptr>,
_.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Pattern>], _ptr>
]
}, _ptr>()(__lit3, ["_field0"]);
export type Pattern = _.Record<
(typeof __lit3),
[
[
_.Record<(typeof $__), [], _ptr>,
_.Record<(typeof $bind), [symbol, Pattern], _ptr>,
_.Record<(typeof $and), [Array<Pattern>], _ptr>,
_.Record<(typeof $not), [Pattern], _ptr>,
_.Record<(typeof $lit), [_val], _ptr>,
_.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Pattern>], _ptr>
]
],
_ptr
>;
export const Template = _.Record.makeConstructor<{
"_field0": [
_.Record<(typeof $ref), [symbol], _ptr>,
_.Record<(typeof $lit), [_val], _ptr>,
_.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Template>], _ptr>
]
}, _ptr>()(__lit3, ["_field0"]);
export type Template = _.Record<
(typeof __lit3),
[
[
_.Record<(typeof $ref), [symbol], _ptr>,
_.Record<(typeof $lit), [_val], _ptr>,
_.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Template>], _ptr>
]
],
_ptr
>;
export const Rewrite = _.Record.makeConstructor<{"_field0": Pattern, "_field1": Template}, _ptr>()($rewrite, ["_field0","_field1"]);
export type Rewrite = _.Record<(typeof $rewrite), [Pattern, Template], _ptr>;
export type _ptr = never;
export type _val = _.Value<_ptr>;
export function isConstructorSpec(v: any): v is ConstructorSpec {
return (
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $rec) &&
((v.length === 2) && true && typeof v[1] === 'number')
) ||
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $arr) &&
((v.length === 1) && typeof v[0] === 'number')
) ||
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $dict) &&
((v.length === 0))
)
);
}
export function asConstructorSpec(v: any): ConstructorSpec {
if (!isConstructorSpec(v)) {throw new TypeError(`Invalid ConstructorSpec: ${_.stringify(v)}`);} else {return v;};
}
export function isPattern(v: any): v is Pattern {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, __lit3) &&
(
(v.length === 1) &&
(
_.Array.isArray(v[0]) &&
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) &&
(v[0].length === 6) &&
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][0]) &&
_.is(v[0][0].label, $__) &&
((v[0][0].length === 0))
) &&
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][1]) &&
_.is(v[0][1].label, $bind) &&
(
(v[0][1].length === 2) &&
typeof v[0][1][0] === 'symbol' &&
isPattern(v[0][1][1])
)
) &&
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][2]) &&
_.is(v[0][2].label, $and) &&
(
(v[0][2].length === 1) &&
(
_.Array.isArray(v[0][2][0]) &&
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][2][0]) &&
(v[0][2][0].length >= 0) &&
v[0][2][0].slice(0).every(v => (isPattern(v)))
)
)
) &&
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][3]) &&
_.is(v[0][3].label, $not) &&
((v[0][3].length === 1) && isPattern(v[0][3][0]))
) &&
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][4]) &&
_.is(v[0][4].label, $lit) &&
((v[0][4].length === 1) && true)
) &&
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][5]) &&
_.is(v[0][5].label, $compound) &&
(
(v[0][5].length === 2) &&
isConstructorSpec(v[0][5][0]) &&
(
_.Dictionary.isDictionary<_val, _ptr>(v[0][5][1]) &&
((() => {
for (const e of v[0][5][1]) {if (!(true)) return false; if (!(isPattern(e[1]))) return false;};
return true;
})())
)
)
)
)
)
);
}
export function asPattern(v: any): Pattern {
if (!isPattern(v)) {throw new TypeError(`Invalid Pattern: ${_.stringify(v)}`);} else {return v;};
}
export function isTemplate(v: any): v is Template {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, __lit3) &&
(
(v.length === 1) &&
(
_.Array.isArray(v[0]) &&
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) &&
(v[0].length === 3) &&
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][0]) &&
_.is(v[0][0].label, $ref) &&
((v[0][0].length === 1) && typeof v[0][0][0] === 'symbol')
) &&
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][1]) &&
_.is(v[0][1].label, $lit) &&
((v[0][1].length === 1) && true)
) &&
(
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0][2]) &&
_.is(v[0][2].label, $compound) &&
(
(v[0][2].length === 2) &&
isConstructorSpec(v[0][2][0]) &&
(
_.Dictionary.isDictionary<_val, _ptr>(v[0][2][1]) &&
((() => {
for (const e of v[0][2][1]) {if (!(true)) return false; if (!(isTemplate(e[1]))) return false;};
return true;
})())
)
)
)
)
)
);
}
export function asTemplate(v: any): Template {
if (!isTemplate(v)) {throw new TypeError(`Invalid Template: ${_.stringify(v)}`);} else {return v;};
}
export function isRewrite(v: any): v is Rewrite {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $rewrite) &&
((v.length === 2) && isPattern(v[0]) && isTemplate(v[1]))
);
}
export function asRewrite(v: any): Rewrite {
if (!isRewrite(v)) {throw new TypeError(`Invalid Rewrite: ${_.stringify(v)}`);} else {return v;};
}