diff --git a/packages/cxx-gen-ast/src/gen_ast_decoder_cc.ts b/packages/cxx-gen-ast/src/gen_ast_decoder_cc.ts index 7a48db93..d84cae39 100644 --- a/packages/cxx-gen-ast/src/gen_ast_decoder_cc.ts +++ b/packages/cxx-gen-ast/src/gen_ast_decoder_cc.ts @@ -48,14 +48,14 @@ export function gen_ast_decoder_cc({ const className = makeClassName(base); emit(); emit( - ` auto ASTDecoder::decode${className}(const void* ptr, io::${className} type) -> ${base}* {` + ` auto ASTDecoder::decode${className}(const void* ptr, io::${className} type) -> ${base}* {`, ); emit(` switch (type) {`); nodes.forEach(({ name }) => { const className = makeClassName(name); emit(` case io::${baseClassName}_${className}:`); emit( - ` return decode${className}(reinterpret_cast(ptr));` + ` return decode${className}(reinterpret_cast(ptr));`, ); }); emit(` default:`); @@ -70,7 +70,7 @@ export function gen_ast_decoder_cc({ const className = makeClassName(name); emit(); emit( - ` auto ASTDecoder::decode${className}(const io::${className}* node) -> ${name}* {` + ` auto ASTDecoder::decode${className}(const io::${className}* node) -> ${name}* {`, ); emit(` if (!node) return nullptr;`); emit(); @@ -88,7 +88,9 @@ export function gen_ast_decoder_cc({ const className = makeClassName(m.type); emit(` if (node->${snakeName}()) {`); emit(` auto* inserter = &ast->${m.name};`); - emit(` for (std::uint32_t i = 0; i < node->${snakeName}()->size();`); + emit( + ` for (std::uint32_t i = 0; i < node->${snakeName}()->size();`, + ); emit(` ++i) {`); emit(` *inserter = new (pool_) List(decode${className}(`); emit(` node->${snakeName}()->Get(i),`); @@ -100,7 +102,9 @@ export function gen_ast_decoder_cc({ const className = makeClassName(m.type); emit(` if (node->${snakeName}()) {`); emit(` auto* inserter = &ast->${m.name};`); - emit(` for (std::uint32_t i = 0; i < node->${snakeName}()->size();`); + emit( + ` for (std::uint32_t i = 0; i < node->${snakeName}()->size();`, + ); emit(` ++i) {`); emit(` *inserter = new (pool_) List(decode${className}(`); emit(` node->${snakeName}()->Get(i)));`); diff --git a/packages/cxx-gen-ast/src/gen_ast_encoder_cc.ts b/packages/cxx-gen-ast/src/gen_ast_encoder_cc.ts index 7483ecc3..ec8bcc97 100644 --- a/packages/cxx-gen-ast/src/gen_ast_encoder_cc.ts +++ b/packages/cxx-gen-ast/src/gen_ast_encoder_cc.ts @@ -44,7 +44,7 @@ export function gen_ast_encoder_cc({ const emitLiteral = ( m: Attribute, table: string, - finalizers: (() => void)[] + finalizers: (() => void)[], ) => { const fieldName = toSnakeName(m.name); @@ -70,7 +70,7 @@ export function gen_ast_encoder_cc({ const className = makeClassName(base); emit(); emit( - ` auto ASTEncoder::accept${className}(${base}* ast) -> std::tuple, std::uint32_t> {` + ` auto ASTEncoder::accept${className}(${base}* ast) -> std::tuple, std::uint32_t> {`, ); emit(` if (!ast) return {};`); emit(` flatbuffers::Offset<> offset;`); diff --git a/packages/cxx-gen-ast/src/gen_ast_h.ts b/packages/cxx-gen-ast/src/gen_ast_h.ts index bb98a9d7..57b95c8f 100644 --- a/packages/cxx-gen-ast/src/gen_ast_h.ts +++ b/packages/cxx-gen-ast/src/gen_ast_h.ts @@ -90,7 +90,7 @@ export function gen_ast_h({ ast, output }: { ast: AST; output: string }) { } emit( - ` void accept(ASTVisitor* visitor) override { visitor->visit(this); }` + ` void accept(ASTVisitor* visitor) override { visitor->visit(this); }`, ); emit(); emit(` auto firstSourceLocation() -> SourceLocation override;`); @@ -117,7 +117,7 @@ template emit(` switch (ast->kind()) {`); nodes.forEach(({ name }) => { emit( - ` case ${name}::Kind: return std::invoke(std::forward(visitor), static_cast<${name}*>(ast));` + ` case ${name}::Kind: return std::invoke(std::forward(visitor), static_cast<${name}*>(ast));`, ); }); emit(` default: cxx_runtime_error("unexpected ${variantName}");`); diff --git a/packages/cxx-gen-ast/src/gen_ast_pretty_printer_cc.ts b/packages/cxx-gen-ast/src/gen_ast_pretty_printer_cc.ts index 1d0b6aa4..f779643b 100644 --- a/packages/cxx-gen-ast/src/gen_ast_pretty_printer_cc.ts +++ b/packages/cxx-gen-ast/src/gen_ast_pretty_printer_cc.ts @@ -104,14 +104,17 @@ export function gen_ast_pretty_printer_cc({ case "dotLoc": case "accessLoc": case "lbracketLoc": + case "lbracket2Loc": case "lparen2Loc": case "lparenLoc": case "openLoc": case "rbracketLoc": + case "rbracket2Loc": case "rparen2Loc": case "rparenLoc": case "greaterLoc": case "scopeLoc": + case "commaLoc": emit(`nospace();`); break; @@ -127,7 +130,9 @@ export function gen_ast_pretty_printer_cc({ case "rbraceLoc": emit(`unindent();`); - emit(`newline();`); + if (!["BracedInitListAST"].includes(name)) { + emit(`newline();`); + } break; default: @@ -139,14 +144,17 @@ export function gen_ast_pretty_printer_cc({ switch (m.name) { case "lbraceLoc": emit(`indent();`); - emit(`newline();`); + if (!["BracedInitListAST"].includes(name)) { + emit(`newline();`); + } break; case "closeLoc": + case "lbracketLoc": + case "lbracket2Loc": case "dotLoc": case "lessLoc": case "lparenLoc": - case "minusGreaterLoc": case "openLoc": case "scopeLoc": case "accessLoc": @@ -154,7 +162,9 @@ export function gen_ast_pretty_printer_cc({ break; case "rbraceLoc": - emit(`newline();`); + if (!["BracedInitListAST"].includes(name)) { + emit(`newline();`); + } break; case "semicolonLoc": @@ -167,6 +177,10 @@ export function gen_ast_pretty_printer_cc({ if (name === "TemplateDeclarationAST") emit(`newline();`); break; + case "minusGreaterLoc": + emit(`space();`); + break; + case "colonLoc": if ( [ @@ -242,7 +256,7 @@ export function gen_ast_pretty_printer_cc({ nodes.forEach(({ name, members }) => { emit(); emit( - `void ASTPrettyPrinter::${className}Visitor::operator()(${name}* ast) {` + `void ASTPrettyPrinter::${className}Visitor::operator()(${name}* ast) {`, ); members.forEach((m) => { @@ -270,6 +284,7 @@ export function gen_ast_pretty_printer_cc({ if (m.name === "lparen2Loc" && name === "GccAttributeAST") { emit(` +nospace(); for (auto loc = ast->lparen2Loc; loc; loc = loc.next()) { if (loc == ast->rparenLoc) break; accept.writeToken(loc); @@ -314,7 +329,13 @@ if (ast->op == TokenKind::T_NEW_ARRAY) { emit(`for (auto it = ast->${m.name}; it; it = it->next) {`); emit(`accept(it->value);`); if (isCommaSeparated(m, name)) { - emit(`if (it->next) { nospace(); accept.write(","); }`); + if (["enumeratorList"].includes(m.name)) { + emit( + `if (it->next) { nospace(); accept.write(","); newline(); }`, + ); + } else { + emit(`if (it->next) { nospace(); accept.write(","); }`); + } } emit(`}`); emit(); diff --git a/packages/cxx-gen-ast/src/gen_ast_printer_cc.ts b/packages/cxx-gen-ast/src/gen_ast_printer_cc.ts index 692b902f..8df5dc66 100644 --- a/packages/cxx-gen-ast/src/gen_ast_printer_cc.ts +++ b/packages/cxx-gen-ast/src/gen_ast_printer_cc.ts @@ -62,7 +62,7 @@ export function gen_ast_printer_cc({ emit(` ++indent_;`); emit(` out_ << std::format("{:{}}", "", indent_ * 2);`); emit( - ` out_ << std::format("${fieldName}: {}\\n", ast->${member.name});` + ` out_ << std::format("${fieldName}: {}\\n", ast->${member.name});`, ); emit(` --indent_;`); emit(` }`); @@ -70,7 +70,7 @@ export function gen_ast_printer_cc({ emit(` ++indent_;`); emit(` out_ << std::format("{:{}}", "", indent_ * 2);`); emit( - ` out_ << std::format("${fieldName}: {}\\n", ast->${member.name});` + ` out_ << std::format("${fieldName}: {}\\n", ast->${member.name});`, ); emit(` --indent_;`); } else if (member.kind == "attribute" && member.type.endsWith("Literal")) { @@ -78,7 +78,7 @@ export function gen_ast_printer_cc({ emit(` ++indent_;`); emit(` out_ << std::format("{:{}}", "", indent_ * 2);`); emit( - ` out_ << std::format("${fieldName}: {}\\n", ast->${member.name}->value());` + ` out_ << std::format("${fieldName}: {}\\n", ast->${member.name}->value());`, ); emit(` --indent_;`); emit(` }`); @@ -90,7 +90,7 @@ export function gen_ast_printer_cc({ emit(` ++indent_;`); emit(` out_ << std::format("{:{}}", "", indent_ * 2);`); emit( - ` out_ << std::format("${fieldName}: {}\\n", Token::spell(ast->${member.name}));` + ` out_ << std::format("${fieldName}: {}\\n", Token::spell(ast->${member.name}));`, ); emit(` --indent_;`); emit(` }`); @@ -101,7 +101,7 @@ export function gen_ast_printer_cc({ emit(` ++indent_;`); emit(` out_ << std::format("{:{}}", "", indent_ * 2);`); emit( - ` out_ << std::format("${fieldName}: {}\\n", to_string(ast->${member.name}));` + ` out_ << std::format("${fieldName}: {}\\n", to_string(ast->${member.name}));`, ); emit(` --indent_;`); } @@ -115,7 +115,7 @@ export function gen_ast_printer_cc({ emit(` out_ << "${astName(name)}";`); emit(` if (ast->type) {`); emit( - ` out_ << std::format(" [{} {}]", to_string(ast->valueCategory), to_string(ast->type));` + ` out_ << std::format(" [{} {}]", to_string(ast->valueCategory), to_string(ast->type));`, ); emit(` }`); emit(` out_ << "\\n";`); diff --git a/packages/cxx-gen-ast/src/gen_ast_slot_cc.ts b/packages/cxx-gen-ast/src/gen_ast_slot_cc.ts index edd1b45c..d9dce481 100644 --- a/packages/cxx-gen-ast/src/gen_ast_slot_cc.ts +++ b/packages/cxx-gen-ast/src/gen_ast_slot_cc.ts @@ -51,7 +51,7 @@ export function gen_ast_slot_cc({ ast, output }: { ast: AST; output: string }) { by_base.forEach((nodes) => { nodes.forEach(({ name, members }) => { const memberSlots = members.filter( - (m) => classifyMemberSlot(m) !== undefined + (m) => classifyMemberSlot(m) !== undefined, ); emit(); @@ -87,7 +87,7 @@ export function gen_ast_slot_cc({ ast, output }: { ast: AST; output: string }) { case MemberSlotClassification.IdentifierAttribute: emit(` case ${slotCount}: // ${m.name}`); emit( - ` value_ = reinterpret_cast(ast->${m.name});` + ` value_ = reinterpret_cast(ast->${m.name});`, ); emit(` slotKind_ = ASTSlotKind::kIdentifierAttribute;`); emit(` slotNameIndex_ = SlotNameIndex{${slotNameIndex}};`); @@ -96,7 +96,7 @@ export function gen_ast_slot_cc({ ast, output }: { ast: AST; output: string }) { case MemberSlotClassification.LiteralAttribute: emit(` case ${slotCount}: // ${m.name}`); emit( - ` value_ = reinterpret_cast(ast->${m.name});` + ` value_ = reinterpret_cast(ast->${m.name});`, ); emit(` slotKind_ = ASTSlotKind::kLiteralAttribute;`); emit(` slotNameIndex_ = SlotNameIndex{${slotNameIndex}};`); @@ -112,7 +112,7 @@ export function gen_ast_slot_cc({ ast, output }: { ast: AST; output: string }) { case MemberSlotClassification.Node: emit(` case ${slotCount}: // ${m.name}`); emit( - ` value_ = reinterpret_cast(ast->${m.name});` + ` value_ = reinterpret_cast(ast->${m.name});`, ); emit(` slotKind_ = ASTSlotKind::kNode;`); emit(` slotNameIndex_ = SlotNameIndex{${slotNameIndex}};`); @@ -121,7 +121,7 @@ export function gen_ast_slot_cc({ ast, output }: { ast: AST; output: string }) { case MemberSlotClassification.NodeList: emit(` case ${slotCount}: // ${m.name}`); emit( - ` value_ = reinterpret_cast(ast->${m.name});` + ` value_ = reinterpret_cast(ast->${m.name});`, ); emit(` slotKind_ = ASTSlotKind::kNodeList;`); emit(` slotNameIndex_ = SlotNameIndex{${slotNameIndex}};`); diff --git a/packages/cxx-gen-ast/src/gen_token_fwd_h.ts b/packages/cxx-gen-ast/src/gen_token_fwd_h.ts index 1a9f6829..11e2be92 100644 --- a/packages/cxx-gen-ast/src/gen_token_fwd_h.ts +++ b/packages/cxx-gen-ast/src/gen_token_fwd_h.ts @@ -30,13 +30,13 @@ export function gen_token_fwd_h({ output }: { output: string }) { emit("#define FOR_EACH_BASE_TOKEN(V) \\"); tokens.BASE_TOKENS.forEach((tk) => - emit(` V(${tk}, "${baseTokenId(tk)}") \\`) + emit(` V(${tk}, "${baseTokenId(tk)}") \\`), ); emit(); emit("#define FOR_EACH_OPERATOR(V) \\"); tokens.OPERATORS.forEach(([tk, spelling]) => - emit(` V(${tk}, "${spelling}") \\`) + emit(` V(${tk}, "${spelling}") \\`), ); emit(); @@ -46,13 +46,13 @@ export function gen_token_fwd_h({ output }: { output: string }) { emit(); emit("#define FOR_EACH_BUILTIN_TYPE_TRAIT(V) \\"); tokens.BUILTIN_TYPE_TRAITS.forEach((tk) => - emit(` V(${tk.toUpperCase()}, "${tk}") \\`) + emit(` V(${tk.toUpperCase()}, "${tk}") \\`), ); emit(); emit("#define FOR_EACH_TOKEN_ALIAS(V) \\"); tokens.TOKEN_ALIASES.forEach(([tk, other]) => - emit(` V(${tk.toUpperCase()}, ${other}) \\`) + emit(` V(${tk.toUpperCase()}, ${other}) \\`), ); const out = `${cpy_header} diff --git a/packages/cxx-gen-ast/src/new_ast_op_cc.ts b/packages/cxx-gen-ast/src/new_ast_op_cc.ts index a43059fb..66f51bcd 100644 --- a/packages/cxx-gen-ast/src/new_ast_op_cc.ts +++ b/packages/cxx-gen-ast/src/new_ast_op_cc.ts @@ -116,7 +116,7 @@ export function new_ast_op_cc({ const resultTy = `${chopAST(base)}Result`; emit(); emit( - `auto ${opName}::${className}Visitor::operator()(${name}* ast) -> ${resultTy} {` + `auto ${opName}::${className}Visitor::operator()(${name}* ast) -> ${resultTy} {`, ); members.forEach((m) => { switch (m.kind) { diff --git a/packages/cxx-gen-ast/src/new_ast_rewriter_cc.ts b/packages/cxx-gen-ast/src/new_ast_rewriter_cc.ts index a8d4dc8c..a34a76a8 100644 --- a/packages/cxx-gen-ast/src/new_ast_rewriter_cc.ts +++ b/packages/cxx-gen-ast/src/new_ast_rewriter_cc.ts @@ -62,17 +62,17 @@ export function new_ast_rewriter_cc({ emit(` struct ASTRewriter::${className}Visitor {`); emit(` ASTRewriter& rewrite;`); emit( - `[[nodiscard]] auto translationUnit() const -> TranslationUnit* { return rewrite.unit_; }` + `[[nodiscard]] auto translationUnit() const -> TranslationUnit* { return rewrite.unit_; }`, ); emit(); emit( - `[[nodiscard]] auto control() const -> Control* { return rewrite.control(); }` + `[[nodiscard]] auto control() const -> Control* { return rewrite.control(); }`, ); emit( - `[[nodiscard]] auto arena() const -> Arena* { return rewrite.arena(); }` + `[[nodiscard]] auto arena() const -> Arena* { return rewrite.arena(); }`, ); emit( - `[[nodiscard]] auto rewriter() const -> ASTRewriter* { return &rewrite; }` + `[[nodiscard]] auto rewriter() const -> ASTRewriter* { return &rewrite; }`, ); nodes.forEach(({ name }) => { emit(); @@ -83,7 +83,7 @@ export function new_ast_rewriter_cc({ const emitRewriterBody = (members: Member[], visitor: string = "rewrite") => { const blockSymbol = members.find( - (m) => m.kind === "attribute" && m.type === "BlockSymbol" + (m) => m.kind === "attribute" && m.type === "BlockSymbol", ); if (blockSymbol) { @@ -114,11 +114,11 @@ export function new_ast_rewriter_cc({ if (specsAttr) { emit(); emit( - `auto ${m.name}Type = getDeclaratorType(translationUnit(), copy->${m.name}, ${specsAttr}Ctx.getType());` + `auto ${m.name}Type = getDeclaratorType(translationUnit(), copy->${m.name}, ${specsAttr}Ctx.getType());`, ); typeAttr = members.find( - (m) => m.kind === "attribute" && m.name === "type" + (m) => m.kind === "attribute" && m.name === "type", ); if (typeAttr) { @@ -131,7 +131,7 @@ export function new_ast_rewriter_cc({ } // switch } else { emit( - `copy->${m.name} = ast_cast<${m.type}>(${visitor}(ast->${m.name}));` + `copy->${m.name} = ast_cast<${m.type}>(${visitor}(ast->${m.name}));`, ); } break; @@ -150,7 +150,7 @@ export function new_ast_rewriter_cc({ } // switch emit( - `for (auto ${m.name} = ©->${m.name}; auto node : ListView{ast->${m.name}}) {` + `for (auto ${m.name} = ©->${m.name}; auto node : ListView{ast->${m.name}}) {`, ); switch (m.type) { @@ -167,7 +167,7 @@ export function new_ast_rewriter_cc({ emit(`*${m.name} = make_list_node(arena(), value);`); } else { emit( - `*${m.name} = make_list_node(arena(), ast_cast<${m.type}>(value));` + `*${m.name} = make_list_node(arena(), ast_cast<${m.type}>(value));`, ); } emit(`${m.name} = &(*${m.name})->next;`); @@ -234,7 +234,7 @@ export function new_ast_rewriter_cc({ switch (name) { case "InitDeclaratorAST": emit( - `auto ASTRewriter::operator()(${name}* ast, const DeclSpecs& declSpecs) -> ${name}* {` + `auto ASTRewriter::operator()(${name}* ast, const DeclSpecs& declSpecs) -> ${name}* {`, ); break; default: @@ -259,7 +259,7 @@ export function new_ast_rewriter_cc({ nodes.forEach(({ name, members }) => { emit(); emit( - `auto ASTRewriter::${className}Visitor::operator()(${name}* ast) -> ${base}* {` + `auto ASTRewriter::${className}Visitor::operator()(${name}* ast) -> ${base}* {`, ); if (name === "IdExpressionAST") { emit(` diff --git a/packages/cxx-gen-ast/src/new_ast_rewriter_h.ts b/packages/cxx-gen-ast/src/new_ast_rewriter_h.ts index fc82748f..73ad22e0 100644 --- a/packages/cxx-gen-ast/src/new_ast_rewriter_h.ts +++ b/packages/cxx-gen-ast/src/new_ast_rewriter_h.ts @@ -54,7 +54,7 @@ export function new_ast_rewriter_h({ switch (name) { case "InitDeclaratorAST": emit( - ` [[nodiscard]] auto operator()(${name}* ast, const DeclSpecs& declSpecs) -> ${name}*;` + ` [[nodiscard]] auto operator()(${name}* ast, const DeclSpecs& declSpecs) -> ${name}*;`, ); break; default: diff --git a/src/parser/cxx/ast_pretty_printer.cc b/src/parser/cxx/ast_pretty_printer.cc index fe1f3e2b..961212ce 100644 --- a/src/parser/cxx/ast_pretty_printer.cc +++ b/src/parser/cxx/ast_pretty_printer.cc @@ -815,6 +815,7 @@ void ASTPrettyPrinter::operator()(SplicerAST* ast) { if (ast->lbracketLoc) { nospace(); writeToken(ast->lbracketLoc); + nospace(); } if (ast->colonLoc) { nospace(); @@ -1066,6 +1067,7 @@ void ASTPrettyPrinter::operator()(ParameterDeclarationClauseAST* ast) { } if (ast->commaLoc) { + nospace(); writeToken(ast->commaLoc); } if (ast->ellipsisLoc) { @@ -1078,7 +1080,7 @@ void ASTPrettyPrinter::operator()(TrailingReturnTypeAST* ast) { if (ast->minusGreaterLoc) { writeToken(ast->minusGreaterLoc); - nospace(); + space(); } operator()(ast->typeId); } @@ -1402,6 +1404,7 @@ void ASTPrettyPrinter::DeclarationVisitor::operator()( } accept(ast->expression); if (ast->commaLoc) { + nospace(); accept.writeToken(ast->commaLoc); } if (ast->literalLoc) { @@ -1781,6 +1784,7 @@ void ASTPrettyPrinter::DeclarationVisitor::operator()( if (ast->lbracketLoc) { nospace(); accept.writeToken(ast->lbracketLoc); + nospace(); } for (auto it = ast->bindingList; it; it = it->next) { @@ -1808,6 +1812,7 @@ void ASTPrettyPrinter::DeclarationVisitor::operator()(AsmOperandAST* ast) { if (ast->lbracketLoc) { nospace(); accept.writeToken(ast->lbracketLoc); + nospace(); } if (ast->symbolicNameLoc) { accept.writeToken(ast->symbolicNameLoc); @@ -2247,6 +2252,7 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()(LambdaExpressionAST* ast) { if (ast->lbracketLoc) { nospace(); accept.writeToken(ast->lbracketLoc); + nospace(); } if (ast->captureDefaultLoc) { accept.writeToken(ast->captureDefaultLoc); @@ -2420,6 +2426,7 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()(VaArgExpressionAST* ast) { } accept(ast->expression); if (ast->commaLoc) { + nospace(); accept.writeToken(ast->commaLoc); } accept(ast->typeId); @@ -2435,6 +2442,7 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()( if (ast->lbracketLoc) { nospace(); accept.writeToken(ast->lbracketLoc); + nospace(); } accept(ast->indexExpression); if (ast->rbracketLoc) { @@ -2567,6 +2575,7 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()( } accept(ast->typeId); if (ast->commaLoc) { + nospace(); accept.writeToken(ast->commaLoc); } accept(ast->expression); @@ -2588,6 +2597,7 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()( } accept(ast->typeId); if (ast->commaLoc) { + nospace(); accept.writeToken(ast->commaLoc); } accept(ast->expression); @@ -2814,6 +2824,7 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()(DeleteExpressionAST* ast) { if (ast->lbracketLoc) { nospace(); accept.writeToken(ast->lbracketLoc); + nospace(); } if (ast->rbracketLoc) { nospace(); @@ -2959,7 +2970,6 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()(BracedInitListAST* ast) { space(); accept.writeToken(ast->lbraceLoc); indent(); - newline(); } for (auto it = ast->expressionList; it; it = it->next) { @@ -2971,13 +2981,12 @@ void ASTPrettyPrinter::ExpressionVisitor::operator()(BracedInitListAST* ast) { } if (ast->commaLoc) { + nospace(); accept.writeToken(ast->commaLoc); } if (ast->rbraceLoc) { unindent(); - newline(); accept.writeToken(ast->rbraceLoc); - newline(); } } @@ -3385,10 +3394,12 @@ void ASTPrettyPrinter::SpecifierVisitor::operator()(EnumSpecifierAST* ast) { if (it->next) { nospace(); accept.write(","); + newline(); } } if (ast->commaLoc) { + nospace(); accept.writeToken(ast->commaLoc); } if (ast->rbraceLoc) { @@ -3583,6 +3594,7 @@ void ASTPrettyPrinter::DeclaratorChunkVisitor::operator()( if (ast->lbracketLoc) { nospace(); accept.writeToken(ast->lbracketLoc); + nospace(); } accept(ast->expression); if (ast->rbracketLoc) { @@ -3925,7 +3937,7 @@ void ASTPrettyPrinter::RequirementVisitor::operator()( } if (ast->minusGreaterLoc) { accept.writeToken(ast->minusGreaterLoc); - nospace(); + space(); } accept(ast->typeConstraint); if (ast->semicolonLoc) { @@ -4121,9 +4133,12 @@ void ASTPrettyPrinter::AttributeSpecifierVisitor::operator()( if (ast->lbracketLoc) { nospace(); accept.writeToken(ast->lbracketLoc); + nospace(); } if (ast->lbracket2Loc) { + nospace(); accept.writeToken(ast->lbracket2Loc); + nospace(); } accept(ast->attributeUsingPrefix); @@ -4140,6 +4155,7 @@ void ASTPrettyPrinter::AttributeSpecifierVisitor::operator()( accept.writeToken(ast->rbracketLoc); } if (ast->rbracket2Loc) { + nospace(); accept.writeToken(ast->rbracket2Loc); } } @@ -4158,6 +4174,7 @@ void ASTPrettyPrinter::AttributeSpecifierVisitor::operator()( if (ast->lparen2Loc) { nospace(); + nospace(); for (auto loc = ast->lparen2Loc; loc; loc = loc.next()) { if (loc == ast->rparenLoc) break; accept.writeToken(loc);