@flowscripter/mpeg-sdl-parser
Version:
ISO/IEC 14496-34 Syntactic Description Language (MPEG SDL) parser implemented in TypeScript
41 lines (38 loc) • 1.45 kB
text/typescript
import type { Token } from "../token/Token.ts";
import type { AbstractNode } from "./AbstractNode.ts";
import { AbstractStatement } from "./AbstractStatement.ts";
import type { ElementaryType } from "./ElementaryType.ts";
import { StatementKind } from "./enum/statement_kind.ts";
import type { Identifier } from "./Identifier.ts";
import type { MapEntry } from "./MapEntry.ts";
export class MapDeclaration extends AbstractStatement {
constructor(
public readonly identifier: Identifier,
public readonly outputElementaryType: ElementaryType | undefined,
public readonly outputClassIdentifier: Identifier | undefined,
public readonly mapEntries: MapEntry[],
public readonly mapKeyword: Token,
public readonly openParenthesisPunctuator: Token,
public readonly closeParenthesisPunctuator: Token,
public readonly openBracePunctuator: Token,
public readonly commaPunctuators: Token[] | undefined,
public readonly closeBracePunctuator: Token,
) {
super(
StatementKind.MAP_DECLARATION,
mapKeyword,
closeBracePunctuator,
);
}
override *getChildNodeIterable(): IterableIterator<AbstractNode> {
yield this.identifier;
if (this.outputElementaryType) {
yield this.outputElementaryType;
} else if (this.outputClassIdentifier) {
yield this.outputClassIdentifier;
}
for (let i = 0; i < this.mapEntries.length; i++) {
yield this.mapEntries[i];
}
}
}