UNPKG

@flowscripter/mpeg-sdl-parser

Version:

ISO/IEC 14496-34 Syntactic Description Language (MPEG SDL) parser implemented in TypeScript

24 lines (20 loc) 788 B
import { AstPath, type Doc, doc } from "prettier"; import { getDocWithTrivia } from "./print_utils"; import type { AbstractNode } from "../ast/node/AbstractNode"; import type { WhileStatement } from "../ast/node/WhileStatement"; const { join } = doc.builders; export function printWhileStatement( path: AstPath<WhileStatement>, print: (path: AstPath<AbstractNode>) => Doc, ): Doc { const whileStatement = path.node; const elements = []; elements.push(getDocWithTrivia(whileStatement.whileKeyword)); elements.push([ getDocWithTrivia(whileStatement.openParenthesisPunctuator), path.call(print, "condition"), getDocWithTrivia(whileStatement.closeParenthesisPunctuator), ]); elements.push(path.call(print, "compoundStatement")); return join(" ", elements); }