Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
47. オペコードなどについて考察する
- Loading branch information
1 parent
8312027
commit 9c38426
Showing
6 changed files
with
179 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ main-c | |
main-hs | ||
*.hi | ||
*.o | ||
ladirvirelyl-hs | ||
xarzniar-hs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{-# OPTIONS -Wall -fno-warn-unused-do-bind #-} | ||
module CommonIO | ||
(semicolonExtension | ||
,parse' | ||
,(>>>=) | ||
) where | ||
import System.IO | ||
--import System.Environment(getArgs) | ||
--import Control.Monad | ||
--import Data.List | ||
|
||
import Parse | ||
--import Execute | ||
--import Linker | ||
import Messages | ||
import Types | ||
|
||
|
||
semicolonExtension :: String -> String | ||
semicolonExtension = unlines . map (takeWhile (/=';')) . lines | ||
|
||
parse' :: FilePath -> IO () | ||
parse' filepath = do | ||
str <- semicolonExtension <$> readFile filepath | ||
putStrLn' English $ NormalMessage $ "\nparsing " ++ filepath ++ ":\n" | ||
fullParse' str >>>= print | ||
|
||
(>>>=) :: (Message a) => Either a b -> (b -> IO ()) -> IO () | ||
Right b >>>= action = action b | ||
Left a >>>= _ = hPutStrLn stderr (show' English a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
.PHONY: c haskell | ||
|
||
haskell: | ||
ghc main.hs -o main-hs -Wall | ||
ghc xarzniar.hs -o xarzniar-hs -Wall | ||
ghc ladirvirelyl.hs -o ladirvirelyl-hs -Wall | ||
|
||
c: | ||
gcc main.c parse.c -o main-c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{-# OPTIONS -Wall -fno-warn-unused-do-bind #-} | ||
-- import System.IO | ||
import System.Environment(getArgs) | ||
import Control.Monad | ||
import Data.List | ||
|
||
-- import Parse | ||
-- import Execute | ||
-- import Linker | ||
import Messages | ||
import Types | ||
import CommonIO | ||
|
||
|
||
main :: IO () | ||
main = do | ||
args <- getArgs | ||
main'' args | ||
|
||
main'' :: [FilePath] -> IO () | ||
main'' paths = do | ||
mapM_ parse' paths | ||
strs <- forM paths (fmap semicolonExtension . readFile) | ||
putStrLn' English $ NormalMessage $ "\ncompiling " ++ intercalate ", " paths ++ ":\n" | ||
fullCompile' strs | ||
|
||
fullCompile' :: [String] -> IO () | ||
fullCompile' strs = undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters