diff options
2 files changed, 29 insertions, 0 deletions
| -rw-r--r-- | homework/81248/cToHtml/app/.Main.hs.swp | bin | 0 -> 12288 bytes | |||
| -rw-r--r-- | homework/81248/cToHtml/app/Main.hs | 29 |
diff --git a/homework/81248/cToHtml/app/.Main.hs.swp b/homework/81248/cToHtml/app/.Main.hs.swp Binary files differnew file mode 100644 index 0000000..d6ddc14 --- /dev/null +++ b/homework/81248/cToHtml/app/.Main.hs.swp diff --git a/homework/81248/cToHtml/app/Main.hs b/homework/81248/cToHtml/app/Main.hs new file mode 100644 index 0000000..b504b82 --- /dev/null +++ b/homework/81248/cToHtml/app/Main.hs @@ -0,0 +1,29 @@ +module Main + ( main + ) where + +import qualified Data.ByteString as BS + +import System.Environment (getArgs) + +import Lucid (renderToFile) + +import Clex.Lex (lexC) +import Html (cToHtml) + +main :: IO () +main = do + xs <- getArgs + if length xs /= 3 + then putStrLn usage + else do + let [inFile, outFile, col] = xs + file <- BS.readFile inFile + renderToFile outFile $ cToHtml col $ either fail id $ lexC file + +usage :: String +usage = " \nUsage: cToHtml inFile.c outFile.html <colour>\n\ + \ Converts inFile.c to a colourised version in which all\n\ + \ keywords, identifiers and literals are coloured in <colour>.\n\ + \ We rely on <colour> working in a style tag.\n\ + \ (we basically set \"color:<colour>\" as a style)\n" |
