Compare commits

..

No commits in common. "5d9b956883b6b6a25994df04684f94981dbadb69" and "6a9f272cacd4da2d308e53118f0f2be3d9b2c8c5" have entirely different histories.

7 changed files with 8 additions and 45 deletions

4
.gitignore vendored
View File

@ -21,7 +21,3 @@ cabal.project.local
cabal.project.local~ cabal.project.local~
.HTF/ .HTF/
.ghc.environment.* .ghc.environment.*
# Windows12 output files
*.ll
*.s

View File

@ -1,7 +0,0 @@
-- Needed to get a working version of llvm-hs-pretty
-- The one on hackage is broken with this version of GHC
source-repository-package
type: git
location: https://github.com/rumkeller/llvm-hs-pretty.git
packages: ./windows12.cabal

View File

@ -3,27 +3,13 @@
module Main where module Main where
import qualified Data.Text.IO as T import qualified Data.Text.IO as T
import qualified Data.Text.Lazy.IO as TL import Prettyprinter
import Data.Text.Lazy (toStrict, unpack)
import Data.String.Conversions (cs)
import Data.Text.Prettyprint.Doc (pretty)
import Text.Megaparsec (parse) import Text.Megaparsec (parse)
import Windows12.Parser (programP) import Windows12.Parser (programP)
import System.Environment (getArgs)
import LLVM.Pretty
import Windows12.Ast
import Windows12.CodeGen (codegen)
main :: IO () main :: IO ()
main = do main = do
args <- getArgs test <- T.readFile "test/hello.w12"
case parse programP "test/hello.w12" test of
if length args /= 2
then putStrLn "Usage: windows12 <input file> <output file>"
else do
let [inputFile, outputFile] = args
test <- T.readFile inputFile
case parse programP inputFile test of
Left err -> print err Left err -> print err
Right ast -> TL.writeFile outputFile (ppllvm (codegen (cs inputFile) ast)) Right ast -> print (pretty ast)

View File

@ -3,4 +3,3 @@ module Windows12 where
import Windows12.Ast import Windows12.Ast
import Windows12.Lexer import Windows12.Lexer
import Windows12.Parser import Windows12.Parser
import Windows12.CodeGen

View File

@ -3,7 +3,7 @@
module Windows12.Ast where module Windows12.Ast where
import Data.Text (Text) import Data.Text (Text)
import Data.Text.Prettyprint.Doc import Prettyprinter
data BinOp data BinOp
= Add = Add

View File

@ -1,8 +0,0 @@
module Windows12.CodeGen where
import Data.Text (Text)
import Windows12.Ast
import LLVM.AST (Module)
codegen :: Text -> Program -> Module
codegen filename (Program structs enums funcs) = undefined

View File

@ -68,7 +68,6 @@ executable windows12
Windows12.Ast Windows12.Ast
Windows12.Lexer Windows12.Lexer
Windows12.Parser Windows12.Parser
Windows12.CodeGen
-- LANGUAGE extensions used by modules in this package. -- LANGUAGE extensions used by modules in this package.
-- other-extensions: -- other-extensions:
@ -77,12 +76,10 @@ executable windows12
build-depends: build-depends:
base >= 4.15.1 && < 4.16, base >= 4.15.1 && < 4.16,
llvm-hs-pure >= 9.0.0 && < 9.1, llvm-hs-pure >= 9.0.0 && < 9.1,
llvm-hs-pretty >= 0.9.0 && < 0.10,
megaparsec >= 9.6.1 && < 9.7, megaparsec >= 9.6.1 && < 9.7,
text >= 1.2.5 && < 1.3, text >= 1.2.5 && < 1.3,
parser-combinators >= 1.3.0 && < 1.4, parser-combinators >= 1.3.0 && < 1.4,
prettyprinter >= 1.5.1 && < 1.6, prettyprinter >= 1.7.1 && < 1.8,
string-conversions >= 0.4.0 && < 0.5
-- Directories containing source files. -- Directories containing source files.
hs-source-dirs: src hs-source-dirs: src