// Path: src/main/java/com/pidanic/saral/domain/Init.java
// public class Init {
//     private List<Statement> instructions;
//     private Scope scope;
// 
//     public Init(Scope scope, List<Statement> instructions) {
//         this.instructions = instructions;
//         this.scope = scope;
//     }
// 
//     public List<Statement> getStatements() {
//         return instructions;
//     }
// 
//     public void accept(InitGenerator generator) {
//         generator.generate(this);
//     }
// 
//     public Scope getScope() {
//         return scope;
//     }
// }
// 
// Path: src/main/java/com/pidanic/saral/error/SaralTreeWalkErrorListener.java
// public class SaralTreeWalkErrorListener extends BaseErrorListener {
//     @Override
//     public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
//         final String errorFormat = "You fucked up at line %d,char %d :(. Details:\n%s";
//         final String errorMsg = String.format(errorFormat, line, charPositionInLine, msg);
//         System.out.println(errorMsg);
//     }
// }
// 
// Path: src/main/java/com/pidanic/saral/visitor/InitVisitor.java
// public class InitVisitor extends SaralBaseVisitor<Init> {
// 
//     private Scope scope;
// 
//     public InitVisitor(String className) {
//         this.scope = new Scope(className);
//     }
// 
//     @Override
//     public Init visitInit(SaralParser.InitContext ctx) {
//         List<Statement> allStatements = ctx.statements().statement().stream().map(stmtCtx -> {
//             SaralParser.Block_statementContext block = stmtCtx.block_statement();
//             SaralParser.Simple_statementContext simpleStmt = stmtCtx.simple_statement();
//             Statement val;
//             if(block != null) {
//                 val = block.accept(new StatementVisitor(scope));
//             } else {
//                 val = simpleStmt.accept(new StatementVisitor(scope));
//             }
//             return val;
//         }).collect(Collectors.toList());
// 
//         return new Init(scope, allStatements);
//     }
// }


import com.pidanic.saral.domain.Init;
import com.pidanic.saral.error.SaralTreeWalkErrorListener;
import com.pidanic.saral.grammar.SaralLexer;
import com.pidanic.saral.grammar.SaralParser;
import com.pidanic.saral.visitor.InitVisitor;
import org.antlr.v4.runtime.*;
import java.io.File;
import java.io.IOException;
package com.pidanic.saral;



public class SaralCompilationUnitParser {
    public Init getCompilationUnit(File preprocessedTempFile, String className) throws IOException{
        String fileAbsPath = preprocessedTempFile.getAbsolutePath();

        CharStream charStream = CharStreams.fromFileName(fileAbsPath);
        SaralLexer saralLexer = new SaralLexer(charStream);
        CommonTokenStream commonTokenStream  = new CommonTokenStream(saralLexer);
        SaralParser saralParser = new SaralParser(commonTokenStream);

// Path: src/main/java/com/pidanic/saral/domain/Init.java
// public class Init {
//     private List<Statement> instructions;
//     private Scope scope;
// 
//     public Init(Scope scope, List<Statement> instructions) {
//         this.instructions = instructions;
//         this.scope = scope;
//     }
// 
//     public List<Statement> getStatements() {
//         return instructions;
//     }
// 
//     public void accept(InitGenerator generator) {
//         generator.generate(this);
//     }
// 
//     public Scope getScope() {
//         return scope;
//     }
// }
// 
// Path: src/main/java/com/pidanic/saral/error/SaralTreeWalkErrorListener.java
// public class SaralTreeWalkErrorListener extends BaseErrorListener {
//     @Override
//     public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
//         final String errorFormat = "You fucked up at line %d,char %d :(. Details:\n%s";
//         final String errorMsg = String.format(errorFormat, line, charPositionInLine, msg);
//         System.out.println(errorMsg);
//     }
// }
// 
// Path: src/main/java/com/pidanic/saral/visitor/InitVisitor.java
// public class InitVisitor extends SaralBaseVisitor<Init> {
// 
//     private Scope scope;
// 
//     public InitVisitor(String className) {
//         this.scope = new Scope(className);
//     }
// 
//     @Override
//     public Init visitInit(SaralParser.InitContext ctx) {
//         List<Statement> allStatements = ctx.statements().statement().stream().map(stmtCtx -> {
//             SaralParser.Block_statementContext block = stmtCtx.block_statement();
//             SaralParser.Simple_statementContext simpleStmt = stmtCtx.simple_statement();
//             Statement val;
//             if(block != null) {
//                 val = block.accept(new StatementVisitor(scope));
//             } else {
//                 val = simpleStmt.accept(new StatementVisitor(scope));
//             }
//             return val;
//         }).collect(Collectors.toList());
// 
//         return new Init(scope, allStatements);
//     }
// }


// Path: src/main/java/com/pidanic/saral/SaralCompilationUnitParser.java
import com.pidanic.saral.domain.Init;
import com.pidanic.saral.error.SaralTreeWalkErrorListener;
import com.pidanic.saral.grammar.SaralLexer;
import com.pidanic.saral.grammar.SaralParser;
import com.pidanic.saral.visitor.InitVisitor;
import org.antlr.v4.runtime.*;
import java.io.File;
import java.io.IOException;

package com.pidanic.saral;



public class SaralCompilationUnitParser {
    public Init getCompilationUnit(File preprocessedTempFile, String className) throws IOException{
        String fileAbsPath = preprocessedTempFile.getAbsolutePath();

        CharStream charStream = CharStreams.fromFileName(fileAbsPath);
        SaralLexer saralLexer = new SaralLexer(charStream);
        CommonTokenStream commonTokenStream  = new CommonTokenStream(saralLexer);
        SaralParser saralParser = new SaralParser(commonTokenStream);

        BaseErrorListener errorListener = new SaralTreeWalkErrorListener();