alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
131 lines (129 loc) • 3.13 kB
JavaScript
import {
any,
array,
enums,
literal,
record,
string,
tuple,
union
} from "../../chunks/chunk-7LBNER34.js";
import "../../chunks/chunk-U5RRZUYZ.js";
// src/core/pages/ExprData.ts
import { Selection } from "./Selection.js";
import { TargetData } from "./TargetData.js";
var UnaryOp = /* @__PURE__ */ ((UnaryOp2) => {
UnaryOp2["Not"] = "Not";
UnaryOp2["IsNull"] = "IsNull";
return UnaryOp2;
})(UnaryOp || {});
var BinaryOp = /* @__PURE__ */ ((BinaryOp2) => {
BinaryOp2["Add"] = "Add";
BinaryOp2["Subt"] = "Subt";
BinaryOp2["Mult"] = "Mult";
BinaryOp2["Mod"] = "Mod";
BinaryOp2["Div"] = "Div";
BinaryOp2["Greater"] = "Greater";
BinaryOp2["GreaterOrEqual"] = "GreaterOrEqual";
BinaryOp2["Less"] = "Less";
BinaryOp2["LessOrEqual"] = "LessOrEqual";
BinaryOp2["Equals"] = "Equals";
BinaryOp2["NotEquals"] = "NotEquals";
BinaryOp2["And"] = "And";
BinaryOp2["Or"] = "Or";
BinaryOp2["Like"] = "Like";
BinaryOp2["In"] = "In";
BinaryOp2["NotIn"] = "NotIn";
BinaryOp2["Concat"] = "Concat";
return BinaryOp2;
})(BinaryOp || {});
var ExprData;
((ExprData2) => {
let types;
((types2) => {
class UnOp2 {
type = literal("unop");
op = enums(UnaryOp);
expr = ExprData2.adt;
}
types2.UnOp = UnOp2;
class BinOp2 {
type = literal("binop");
a = ExprData2.adt;
op = enums(BinaryOp);
b = ExprData2.adt;
}
types2.BinOp = BinOp2;
class Field2 {
type = literal("field");
target = TargetData;
field = string;
}
types2.Field = Field2;
class Access2 {
type = literal("access");
expr = ExprData2.adt;
field = string;
}
types2.Access = Access2;
class Value2 {
type = literal("value");
value = any;
}
types2.Value = Value2;
class Record2 {
type = literal("record");
fields = record(ExprData2.adt);
}
types2.Record = Record2;
class Case2 {
type = literal("case");
expr = ExprData2.adt;
cases = array(tuple(ExprData2.adt, Selection.adt));
defaultCase = Selection.adt.optional;
}
types2.Case = Case2;
})(types || (types = {}));
function UnOp(op, expr) {
return { type: "unop", op, expr };
}
ExprData2.UnOp = UnOp;
function BinOp(a, op, b) {
return { type: "binop", a, op, b };
}
ExprData2.BinOp = BinOp;
function Field(target, field) {
return { type: "field", target, field };
}
ExprData2.Field = Field;
function Access(expr, field) {
return { type: "access", expr, field };
}
ExprData2.Access = Access;
function Value(value) {
return { type: "value", value };
}
ExprData2.Value = Value;
function Record(fields) {
return { type: "record", fields };
}
ExprData2.Record = Record;
function Case(expr, cases, defaultCase) {
return { type: "case", expr, cases, defaultCase };
}
ExprData2.Case = Case;
ExprData2.adt = union(
types.UnOp,
types.BinOp,
types.Field,
types.Access,
types.Value,
types.Record,
types.Case
);
})(ExprData || (ExprData = {}));
export {
BinaryOp,
ExprData,
UnaryOp
};