import { Span } from "../diagnostics.ts"; import { Expr, ExprKind, Ident, Item, ItemKind, Pat, PatKind, Stmt, StmtKind, Ty, TyKind, } from "./ast.ts"; export class Cx { private idCounter = 0; private id(): number { return this.idCounter++; } public stmt(kind: StmtKind, span: Span): Stmt { const id = this.id(); return { id, kind, span }; } public item( kind: ItemKind, span: Span, ident: Ident, pub: boolean, ): Item { const id = this.id(); return { id, kind, span, ident, pub }; } public expr(kind: ExprKind, span: Span): Expr { const id = this.id(); return { id, kind, span }; } public pat(kind: PatKind, span: Span): Pat { const id = this.id(); return { id, kind, span }; } public ty(kind: TyKind, span: Span): Ty { const id = this.id(); return { id, kind, span }; } }