<commit_before>namespace vSprog

open vSprog.Parser
open vSprog.Analysis
open vSprog.CommonTypes
open vSprog.AST
open vSprog.ParserUtils
open vSprog.CodeGen
open System.IO
open System

module Main =
    let llvmToExec (llvmIr:string) : bool =
        let file = new StreamWriter("out.ll")
        file.Write(llvmIr)
        file.Close()
        let proc = new System.Diagnostics.Process()

        // --------------- llc -------------
        proc.StartInfo.FileName <- "clang"
        proc.StartInfo.Arguments <- "out.ll -O2 -Wall"
        let llcRes = proc.Start()
        proc.WaitForExit()
        if llcRes then // only run clang when llc succeeded
            // --------------- clang -------------
            let clangProc = new System.Diagnostics.Process()
            clangProc.StartInfo.FileName <- "./a.out"
            clangProc.Start() |> ignore
            clangProc.WaitForExit()
            clangProc.ExitCode = 0

        else false

    
    [<EntryPoint>]
    let main argv = 
        let inputSrcPath = if argv.Length = 0 then 
                             printfn "No input file specified"
                             Environment.Exit -1
                             ""
                           else 
                             argv.[0]
        let input = File.ReadAllText "../../../../../SamplePrograms/SanityCheck07.tldr"

        let res = parse input "../../grammar.gram"  //Generates hime AST
                >>= fun tree -> Success (toAST tree)
                //>>= fun ast -> Success ast  // Gør den noget?
                >>= analyse
                >>= (fun ast -> Success (codeGen ast))

        match res with
        | Success a -> 
            printfn "success"
            printfn "%A" a
            printfn "-----------------------------------\n"
            llvmToExec a
            |> ignore
        | Failure errs -> 
            printfn "Errors:"
            errs |> List.iter (printfn "%s")

        0 // return an integer exit code<commit_msg>vi skal altså ikke hardcode filnavn!!<commit_after>namespace vSprog

open vSprog.Parser
open vSprog.Analysis
open vSprog.CommonTypes
open vSprog.AST
open vSprog.ParserUtils
open vSprog.CodeGen
open System.IO
open System

module Main =
    let llvmToExec (llvmIr:string) : bool =
        let file = new StreamWriter("out.ll")
        file.Write(llvmIr)
        file.Close()
        let proc = new System.Diagnostics.Process()

        // --------------- llc -------------
        proc.StartInfo.FileName <- "clang"
        proc.StartInfo.Arguments <- "out.ll -O2 -Wall"
        let llcRes = proc.Start()
        proc.WaitForExit()
        if llcRes then // only run clang when llc succeeded
            // --------------- clang -------------
            let clangProc = new System.Diagnostics.Process()
            clangProc.StartInfo.FileName <- "./a.out"
            clangProc.Start() |> ignore
            clangProc.WaitForExit()
            clangProc.ExitCode = 0

        else false

    
    [<EntryPoint>]
    let main argv = 
        let inputSrcPath = if argv.Length = 0 then 
                             printfn "No input file specified"
                             Environment.Exit -1
                             ""
                           else 
                             argv.[0]
        let input = File.ReadAllText inputSrcPath

        let res = parse input "../../grammar.gram"  //Generates hime AST
                >>= fun tree -> Success (toAST tree)
                //>>= fun ast -> Success ast  // Gør den noget?
                >>= analyse
                >>= (fun ast -> Success (codeGen ast))

        match res with
        | Success a -> 
            printfn "success"
            printfn "%A" a
            printfn "-----------------------------------\n"
            llvmToExec a
            |> ignore
        | Failure errs -> 
            printfn "Errors:"
            errs |> List.iter (printfn "%s")

        0 // return an integer exit code
{'fraction_non_alphanumeric': 0.13872104733131924, 'fraction_numerical': 0.003524672708962739, 'mean_word_length': 1.2232792389479574, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6522475', 'n_tokens_mistral': 1091, 'n_tokens_neox': 1033, 'n_words': 296}