UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

53 lines (52 loc) 1.19 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); class AttributeDict { static { __name(this, "AttributeDict"); } name; ast; type; /** The list of {@link IAttribute} objects. */ attributes = /* @__PURE__ */ new Map(); constructor(type) { this.type = type; } add(a) { a.dict = this; this.attributes.set(a.name, a); return a; } get(name) { return this.attributes.get(name) ?? null; } getName() { return this.name; } size() { return this.attributes.size; } /** * @param other The other {@link AttributeDict} to compare with. * * @returns the set of keys that collide from {@code this} and {@code other}. */ intersection(other) { const result = /* @__PURE__ */ new Set(); if (other === null || other.size() === 0 || this.size() === 0) { return result; } this.attributes.forEach((value, key) => { if (other.attributes.has(key)) { result.add(key); } }); return result; } toString() { return this.getName() + ":" + String(this.attributes); } } export { AttributeDict };