<commit_before>{-# LANGUAGE FlexibleContexts #-}
module Main where

import Control.Monad
import Control.Monad.State
import Control.Monad.Error
import System.Environment
import System.IO
import System.Exit (exitFailure)
import System.Directory (doesFileExist)
import System.Cmd (rawSystem)
import Text.ParserCombinators.Parsec hiding (State)

import L1.Grammar
import L1.Parser

main :: IO ()
main = do
    args <- getArgs
    when (length args == 0) $ do
        putStrLn "usage: filename"
        exitFailure
    assembleFile (args !! 0)


assembleFile :: FilePath -> IO ()
assembleFile fp = do
    runtimeOExists <- doesFileExist "../../static/runtime.o"
    when (not runtimeOExists) $ putStrLn "No runtime.o. Exiting."
    contents <- readFile fp
    let filename = "prog.S"
        (prog, _) = runState (generateAssembly contents) 0
    writeFile filename prog
    rawSystem "as" ["--32", "-o", "prog.o", "prog.S"]<commit_msg>Look for runtime.o in current dir<commit_after>{-# LANGUAGE FlexibleContexts #-}
module Main where

import Control.Monad
import Control.Monad.State
import Control.Monad.Error
import System.Environment
import System.IO
import System.Exit (exitFailure)
import System.Directory (doesFileExist)
import System.Cmd (rawSystem)
import Text.ParserCombinators.Parsec hiding (State)

import L1.Grammar
import L1.Parser

main :: IO ()
main = do
    args <- getArgs
    when (length args == 0) $ do
        putStrLn "usage: filename"
        exitFailure
    assembleFile (args !! 0)


assembleFile :: FilePath -> IO ()
assembleFile fp = do
    runtimeOExists <- doesFileExist "runtime.o"
    when (not runtimeOExists) $ putStrLn "No runtime.o. Exiting."
    contents <- readFile fp
    let filename = "prog.S"
        (prog, _) = runState (generateAssembly contents) 0
    writeFile filename prog
    rawSystem "as" ["--32", "-o", "prog.o", "prog.S"]
{'fraction_non_alphanumeric': 0.11342964151952915, 'fraction_numerical': 0.00749063670411985, 'mean_word_length': 3.5388349514563107, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '6676318', 'n_tokens_mistral': 614, 'n_tokens_neox': 586, 'n_words': 178}