@Test public void testParseAndPrintStructs3() throws Exception { final String program = "" + "struct S {\n" + " int a;\n" + " int b;\n" + "} someS = S(8, 9);\n" + "\n" + "struct T {\n" + " S myS1;\n" + " S myS2;\n" + "} ;\n" + "\n" + "void main()\n" + "{\n" + " T myT = T(S(1, 2), S(someS.a, 4));\n" + "}\n"; assertEquals(program, PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(program ))); }
public static String prettyPrintAsString(IAstNode node) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); new PrettyPrinterVisitor(new PrintStream(bytes)).visit(node); return new String(bytes.toByteArray(), StandardCharsets.UTF_8); }
PrettyPrinterVisitor extends StandardVisitor { public static String prettyPrintAsString(IAstNode node) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); new PrettyPrinterVisitor(new PrintStream(bytes)).visit(node); return new String(bytes.toByteArray(), StandardCharsets.UTF_8); } }
PrettyPrinterVisitor extends StandardVisitor { public static String prettyPrintAsString(IAstNode node) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); new PrettyPrinterVisitor(new PrintStream(bytes)).visit(node); return new String(bytes.toByteArray(), StandardCharsets.UTF_8); } PrettyPrinterVisitor(PrintStream out);  PrettyPrinterVisitor(PrintStream out,
                              int indentationWidth,
                              Supplier<String> newLineSupplier,
                              boolean emitGraphicsFuzzDefines,
                              Optional<String> license,
                              Optional<UniformValueSupplier> uniformValues); }
PrettyPrinterVisitor extends StandardVisitor { public static String prettyPrintAsString(IAstNode node) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); new PrettyPrinterVisitor(new PrintStream(bytes)).visit(node); return new String(bytes.toByteArray(), StandardCharsets.UTF_8); } PrettyPrinterVisitor(PrintStream out);  PrettyPrinterVisitor(PrintStream out,
                              int indentationWidth,
                              Supplier<String> newLineSupplier,
                              boolean emitGraphicsFuzzDefines,
                              Optional<String> license,
                              Optional<UniformValueSupplier> uniformValues); static String prettyPrintAsString(IAstNode node); static String prettyPrintAsString(IAstNode node, UniformValueSupplier uniformValues); static void emitShader(TranslationUnit shader,
                                Optional<String> license,
                                PrintStream stream,
                                int indentationWidth,
                                Supplier<String> newlineSupplier); static void emitShader(TranslationUnit shader,
                                Optional<String> license,
                                PrintStream stream,
                                int indentationWidth,
                                Supplier<String> newlineSupplier,
                                Optional<UniformValueSupplier> uniformValueSupplier); @Override void visitPrecisionDeclaration(PrecisionDeclaration precisionDeclaration); @Override void visitDeclarationStmt(DeclarationStmt declarationStmt); @Override void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration); @Override void visitFunctionDefinition(FunctionDefinition functionDefinition); @Override void visitFunctionPrototype(FunctionPrototype functionPrototype); @Override void visitParameterDecl(ParameterDecl parameterDecl); @Override void visitBlockStmt(BlockStmt stmt); @Override void visitIfStmt(IfStmt ifStmt); @Override void visitBinaryExpr(BinaryExpr binaryExpr); @Override void visitParenExpr(ParenExpr parenExpr); @Override void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr); @Override void visitUnaryExpr(UnaryExpr unaryExpr); @Override void visitMemberLookupExpr(MemberLookupExpr memberLookupExpr); @Override void visitIntConstantExpr(IntConstantExpr intConstantExpr); @Override void visitUIntConstantExpr(UIntConstantExpr intConstantExpr); @Override void visitFloatConstantExpr(FloatConstantExpr floatConstantExpr); @Override void visitBoolConstantExpr(BoolConstantExpr boolConstantExpr); @Override void visitBreakStmt(BreakStmt breakStmt); @Override void visitContinueStmt(ContinueStmt continueStmt); @Override void visitDiscardStmt(DiscardStmt discardStmt); @Override void visitReturnStmt(ReturnStmt returnStmt); @Override void visitExprStmt(ExprStmt exprStmt); @Override void visitFunctionCallExpr(FunctionCallExpr functionCallExpr); @Override void visitTypeConstructorExpr(TypeConstructorExpr typeConstructorExpr); @Override void visitQualifiedType(QualifiedType qualifiedType); @Override void visitBasicType(BasicType basicType); @Override void visitSamplerType(SamplerType samplerType); @Override void visitImageType(ImageType imageType); @Override void visitVoidType(VoidType voidType); @Override void visitAtomicIntType(AtomicIntType atomicIntType); @Override void visitNullStmt(NullStmt nullStmt); @Override void visitWhileStmt(WhileStmt whileStmt); @Override void visitForStmt(ForStmt forStmt); @Override void visitDoStmt(DoStmt doStmt); @Override void visitTernaryExpr(TernaryExpr ternaryExpr); @Override void visitArrayIndexExpr(ArrayIndexExpr arrayIndexExpr); @Override void visitStructNameType(StructNameType structNameType); @Override void visitArrayType(ArrayType arrayType); @Override void visitArrayConstructorExpr(ArrayConstructorExpr arrayConstructorExpr); @Override void visitStructDefinitionType(StructDefinitionType structDefinitionType); @Override void visitSwitchStmt(SwitchStmt switchStmt); @Override void visitDefaultCaseLabel(DefaultCaseLabel defaultCaseLabel); @Override void visitExprCaseLabel(ExprCaseLabel exprCaseLabel); @Override void visitInterfaceBlock(InterfaceBlock interfaceBlock); @Override void visitDefaultLayout(DefaultLayout defaultLayout); @Override void visitTranslationUnit(TranslationUnit translationUnit); @Override void visitPragmaStatement(PragmaStatement pragmaStatement); @Override void visitExtensionStatement(ExtensionStatement extensionStatement); @Override String toString(); static String defaultIndent(int level); static void emitGraphicsFuzzDefines(PrintStream out,
                                             ShadingLanguageVersion shadingLanguageVersion); }
PrettyPrinterVisitor extends StandardVisitor { public static String prettyPrintAsString(IAstNode node) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); new PrettyPrinterVisitor(new PrintStream(bytes)).visit(node); return new String(bytes.toByteArray(), StandardCharsets.UTF_8); } PrettyPrinterVisitor(PrintStream out);  PrettyPrinterVisitor(PrintStream out,
                              int indentationWidth,
                              Supplier<String> newLineSupplier,
                              boolean emitGraphicsFuzzDefines,
                              Optional<String> license,
                              Optional<UniformValueSupplier> uniformValues); static String prettyPrintAsString(IAstNode node); static String prettyPrintAsString(IAstNode node, UniformValueSupplier uniformValues); static void emitShader(TranslationUnit shader,
                                Optional<String> license,
                                PrintStream stream,
                                int indentationWidth,
                                Supplier<String> newlineSupplier); static void emitShader(TranslationUnit shader,
                                Optional<String> license,
                                PrintStream stream,
                                int indentationWidth,
                                Supplier<String> newlineSupplier,
                                Optional<UniformValueSupplier> uniformValueSupplier); @Override void visitPrecisionDeclaration(PrecisionDeclaration precisionDeclaration); @Override void visitDeclarationStmt(DeclarationStmt declarationStmt); @Override void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration); @Override void visitFunctionDefinition(FunctionDefinition functionDefinition); @Override void visitFunctionPrototype(FunctionPrototype functionPrototype); @Override void visitParameterDecl(ParameterDecl parameterDecl); @Override void visitBlockStmt(BlockStmt stmt); @Override void visitIfStmt(IfStmt ifStmt); @Override void visitBinaryExpr(BinaryExpr binaryExpr); @Override void visitParenExpr(ParenExpr parenExpr); @Override void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr); @Override void visitUnaryExpr(UnaryExpr unaryExpr); @Override void visitMemberLookupExpr(MemberLookupExpr memberLookupExpr); @Override void visitIntConstantExpr(IntConstantExpr intConstantExpr); @Override void visitUIntConstantExpr(UIntConstantExpr intConstantExpr); @Override void visitFloatConstantExpr(FloatConstantExpr floatConstantExpr); @Override void visitBoolConstantExpr(BoolConstantExpr boolConstantExpr); @Override void visitBreakStmt(BreakStmt breakStmt); @Override void visitContinueStmt(ContinueStmt continueStmt); @Override void visitDiscardStmt(DiscardStmt discardStmt); @Override void visitReturnStmt(ReturnStmt returnStmt); @Override void visitExprStmt(ExprStmt exprStmt); @Override void visitFunctionCallExpr(FunctionCallExpr functionCallExpr); @Override void visitTypeConstructorExpr(TypeConstructorExpr typeConstructorExpr); @Override void visitQualifiedType(QualifiedType qualifiedType); @Override void visitBasicType(BasicType basicType); @Override void visitSamplerType(SamplerType samplerType); @Override void visitImageType(ImageType imageType); @Override void visitVoidType(VoidType voidType); @Override void visitAtomicIntType(AtomicIntType atomicIntType); @Override void visitNullStmt(NullStmt nullStmt); @Override void visitWhileStmt(WhileStmt whileStmt); @Override void visitForStmt(ForStmt forStmt); @Override void visitDoStmt(DoStmt doStmt); @Override void visitTernaryExpr(TernaryExpr ternaryExpr); @Override void visitArrayIndexExpr(ArrayIndexExpr arrayIndexExpr); @Override void visitStructNameType(StructNameType structNameType); @Override void visitArrayType(ArrayType arrayType); @Override void visitArrayConstructorExpr(ArrayConstructorExpr arrayConstructorExpr); @Override void visitStructDefinitionType(StructDefinitionType structDefinitionType); @Override void visitSwitchStmt(SwitchStmt switchStmt); @Override void visitDefaultCaseLabel(DefaultCaseLabel defaultCaseLabel); @Override void visitExprCaseLabel(ExprCaseLabel exprCaseLabel); @Override void visitInterfaceBlock(InterfaceBlock interfaceBlock); @Override void visitDefaultLayout(DefaultLayout defaultLayout); @Override void visitTranslationUnit(TranslationUnit translationUnit); @Override void visitPragmaStatement(PragmaStatement pragmaStatement); @Override void visitExtensionStatement(ExtensionStatement extensionStatement); @Override String toString(); static String defaultIndent(int level); static void emitGraphicsFuzzDefines(PrintStream out,
                                             ShadingLanguageVersion shadingLanguageVersion); static final int DEFAULT_INDENTATION_WIDTH; static final Supplier<String> DEFAULT_NEWLINE_SUPPLIER; }