UNPKG

cbon

Version:
98 lines (97 loc) 2.25 kB
import { TLineComment, TBlockComment } from "./token"; function MakeCommentItem(items) { return items.map(i => i instanceof TLineComment ? new LineComment(i.range, i.items) : i instanceof TBlockComment ? new BlockComment(i.range, i.items) : i); } export class Unit { } export class Comment extends Unit { } export class LineComment extends Comment { constructor(range, items) { super(); this.items = MakeCommentItem(items); this.range = range; } } export class BlockComment extends Comment { constructor(range, items) { super(); this.items = MakeCommentItem(items); this.range = range; } } export class Comma extends Unit { constructor(range) { super(); this.range = range; } } export class Null extends Unit { constructor(range) { super(); this.range = range; } } export class Str extends Unit { constructor(range, val, col) { super(); this.val = val; this.col = col; this.range = range; } } export class Num extends Unit { constructor(range, val) { super(); this.val = val; this.range = range; } } export class Bool extends Unit { constructor(range, val) { super(); this.val = val; this.range = range; } } export class Key { constructor(range, key) { this.key = key; this.range = range; } } export class Split { constructor(range, type) { this.type = type; this.range = range; } } export class KeyVal { constructor(key, val, split) { this.key = key; this.val = val; this.split = split; } } export class Block extends Unit { constructor(begin, end, items) { super(); this.items = items; this.begin = begin; this.end = end; } } export class Arr extends Unit { constructor(begin, end, items) { super(); this.items = items; this.begin = begin; this.end = end; } } export class Docs extends Unit { constructor(items) { super(); this.items = items; } }