UNPKG

cbon

Version:
70 lines (69 loc) 1.67 kB
export class Token { } export class TEOF extends Token { constructor(range) { super(); this.range = range; } } export class TComment extends Token { } export class TLineComment extends TComment { constructor(range, items) { super(); this.items = items; this.range = range; } } export class TBlockComment extends TComment { constructor(range, items) { super(); this.items = items; this.range = range; } } export class TWord extends Token { constructor(range, val) { super(); this.val = val; this.range = range; } } export class TStr extends Token { constructor(range, val, col) { super(); this.val = val; this.col = col; this.range = range; } } export class TSymbol extends Token { constructor(range, val) { super(); this.val = val; this.range = range; } } export class TSComma extends TSymbol { } export class TSSplit extends TSymbol { } export class TSArrStart extends TSymbol { } export class TSArrEnd extends TSymbol { } export class TSObjStart extends TSymbol { } export class TSObjEnd extends TSymbol { } export function makeTSymbol(range, val) { switch (val) { case ',': return new TSComma(range, val); case ':': case '=': return new TSSplit(range, val); case '[': return new TSArrStart(range, val); case ']': return new TSArrEnd(range, val); case '{': return new TSObjStart(range, val); case '}': return new TSObjEnd(range, val); } }