Compare commits
6 Commits
6a9f272cac
...
5d9b956883
Author | SHA1 | Date | |
---|---|---|---|
5d9b956883 | |||
892658de78 | |||
898160d611 | |||
2819b7fc57 | |||
37cf2fe339 | |||
d558831984 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -21,3 +21,7 @@ cabal.project.local
|
||||
cabal.project.local~
|
||||
.HTF/
|
||||
.ghc.environment.*
|
||||
|
||||
# Windows12 output files
|
||||
*.ll
|
||||
*.s
|
||||
|
7
cabal.project
Normal file
7
cabal.project
Normal file
@ -0,0 +1,7 @@
|
||||
-- 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
|
24
src/Main.hs
24
src/Main.hs
@ -3,13 +3,27 @@
|
||||
module Main where
|
||||
|
||||
import qualified Data.Text.IO as T
|
||||
import Prettyprinter
|
||||
import qualified Data.Text.Lazy.IO as TL
|
||||
import Data.Text.Lazy (toStrict, unpack)
|
||||
import Data.String.Conversions (cs)
|
||||
import Data.Text.Prettyprint.Doc (pretty)
|
||||
import Text.Megaparsec (parse)
|
||||
import Windows12.Parser (programP)
|
||||
import System.Environment (getArgs)
|
||||
import LLVM.Pretty
|
||||
import Windows12.Ast
|
||||
import Windows12.CodeGen (codegen)
|
||||
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
test <- T.readFile "test/hello.w12"
|
||||
case parse programP "test/hello.w12" test of
|
||||
Left err -> print err
|
||||
Right ast -> print (pretty ast)
|
||||
args <- getArgs
|
||||
|
||||
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
|
||||
Right ast -> TL.writeFile outputFile (ppllvm (codegen (cs inputFile) ast))
|
||||
|
@ -2,4 +2,5 @@ module Windows12 where
|
||||
|
||||
import Windows12.Ast
|
||||
import Windows12.Lexer
|
||||
import Windows12.Parser
|
||||
import Windows12.Parser
|
||||
import Windows12.CodeGen
|
||||
|
@ -3,7 +3,7 @@
|
||||
module Windows12.Ast where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Prettyprinter
|
||||
import Data.Text.Prettyprint.Doc
|
||||
|
||||
data BinOp
|
||||
= Add
|
||||
|
8
src/Windows12/CodeGen.hs
Normal file
8
src/Windows12/CodeGen.hs
Normal file
@ -0,0 +1,8 @@
|
||||
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
|
@ -68,6 +68,7 @@ executable windows12
|
||||
Windows12.Ast
|
||||
Windows12.Lexer
|
||||
Windows12.Parser
|
||||
Windows12.CodeGen
|
||||
|
||||
-- LANGUAGE extensions used by modules in this package.
|
||||
-- other-extensions:
|
||||
@ -76,10 +77,12 @@ executable windows12
|
||||
build-depends:
|
||||
base >= 4.15.1 && < 4.16,
|
||||
llvm-hs-pure >= 9.0.0 && < 9.1,
|
||||
llvm-hs-pretty >= 0.9.0 && < 0.10,
|
||||
megaparsec >= 9.6.1 && < 9.7,
|
||||
text >= 1.2.5 && < 1.3,
|
||||
parser-combinators >= 1.3.0 && < 1.4,
|
||||
prettyprinter >= 1.7.1 && < 1.8,
|
||||
prettyprinter >= 1.5.1 && < 1.6,
|
||||
string-conversions >= 0.4.0 && < 0.5
|
||||
|
||||
-- Directories containing source files.
|
||||
hs-source-dirs: src
|
||||
|
Loading…
x
Reference in New Issue
Block a user