@Test public void testParsingComma1() throws Exception { final TranslationUnit tu = ParseHelper.parse("" + "void main() {\n" + " bool b, c;\n" + " int x, y;\n" + " b, c ? x : y;\n" + " b ? c, x : y;\n" + " b ? x : y, c;\n" + "}\n"); final BlockStmt block = tu.getMainFunction().getBody(); assertTrue(block.getStmt(0) instanceof DeclarationStmt); assertTrue(block.getStmt(1) instanceof DeclarationStmt); { final ExprStmt exprStmt = (ExprStmt) block.getStmt(2); assertTrue(exprStmt.getExpr() instanceof BinaryExpr); final BinaryExpr binaryExpr = (BinaryExpr) exprStmt.getExpr(); assertEquals(BinOp.COMMA, binaryExpr.getOp()); assertTrue(binaryExpr.getLhs() instanceof VariableIdentifierExpr); assertTrue(binaryExpr.getRhs() instanceof TernaryExpr); } { final ExprStmt exprStmt = (ExprStmt) block.getStmt(3); assertTrue(exprStmt.getExpr() instanceof TernaryExpr); final TernaryExpr ternaryExpr = (TernaryExpr) exprStmt.getExpr(); assertTrue(ternaryExpr.getTest() instanceof VariableIdentifierExpr); assertTrue(ternaryExpr.getThenExpr() instanceof BinaryExpr); assertEquals(BinOp.COMMA, ((BinaryExpr) ternaryExpr.getThenExpr()).getOp()); assertTrue(ternaryExpr.getElseExpr() instanceof VariableIdentifierExpr); } { final ExprStmt exprStmt = (ExprStmt) block.getStmt(4); assertTrue(exprStmt.getExpr() instanceof BinaryExpr); final BinaryExpr binaryExpr = (BinaryExpr) exprStmt.getExpr(); assertEquals(BinOp.COMMA, binaryExpr.getOp()); assertTrue(binaryExpr.getLhs() instanceof TernaryExpr); assertTrue(binaryExpr.getRhs() instanceof VariableIdentifierExpr); } }
public static synchronized TranslationUnit parse(File file) throws IOException, ParseTimeoutException, InterruptedException, GlslParserException { return parseInputStream(new ByteArrayInputStream(FileUtils.readFileToByteArray(file)), ShaderKind.fromExtension(FilenameUtils.getExtension(file.getName()))); }
ParseHelper { public static synchronized TranslationUnit parse(File file) throws IOException, ParseTimeoutException, InterruptedException, GlslParserException { return parseInputStream(new ByteArrayInputStream(FileUtils.readFileToByteArray(file)), ShaderKind.fromExtension(FilenameUtils.getExtension(file.getName()))); } }
ParseHelper { public static synchronized TranslationUnit parse(File file) throws IOException, ParseTimeoutException, InterruptedException, GlslParserException { return parseInputStream(new ByteArrayInputStream(FileUtils.readFileToByteArray(file)), ShaderKind.fromExtension(FilenameUtils.getExtension(file.getName()))); }  }
ParseHelper { public static synchronized TranslationUnit parse(File file) throws IOException, ParseTimeoutException, InterruptedException, GlslParserException { return parseInputStream(new ByteArrayInputStream(FileUtils.readFileToByteArray(file)), ShaderKind.fromExtension(FilenameUtils.getExtension(file.getName()))); }  static Optional<TranslationUnit> maybeParseShader(File shader); static synchronized TranslationUnit parse(File file); static synchronized TranslationUnit parse(String string, ShaderKind shaderKind); static synchronized TranslationUnit parse(String string); }
ParseHelper { public static synchronized TranslationUnit parse(File file) throws IOException, ParseTimeoutException, InterruptedException, GlslParserException { return parseInputStream(new ByteArrayInputStream(FileUtils.readFileToByteArray(file)), ShaderKind.fromExtension(FilenameUtils.getExtension(file.getName()))); }  static Optional<TranslationUnit> maybeParseShader(File shader); static synchronized TranslationUnit parse(File file); static synchronized TranslationUnit parse(String string, ShaderKind shaderKind); static synchronized TranslationUnit parse(String string); static final String END_OF_GRAPHICSFUZZ_DEFINES; }