UNPKG

@nodescript/core

Version:

Visual programming language for Browser and Node

26 lines 701 B
import { CompilerError } from './CompilerError.js'; export class SymTable { constructor() { this.symCounters = new Map(); this.symtable = new Map(); } get(id, fallback) { const sym = this.symtable.get(id); if (sym == null) { if (fallback == null) { throw new CompilerError(`Symbol not found: ${id}`); } return fallback; } return sym; } set(id, sym) { this.symtable.set(id, sym); } nextSym(sym) { const c = this.symCounters.get(sym) ?? 0; this.symCounters.set(sym, c + 1); return `${sym}${c + 1}`; } } //# sourceMappingURL=SymTable.js.map