Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81248 / cToHtml / app
diff options
context:
space:
mode:
2 files changed, 29 insertions, 0 deletions
-rw-r--r--homework/81248/cToHtml/app/.Main.hs.swpbin0 -> 12288 bytes
-rw-r--r--homework/81248/cToHtml/app/Main.hs29
diff --git a/homework/81248/cToHtml/app/.Main.hs.swp b/homework/81248/cToHtml/app/.Main.hs.swp
new file mode 100644
index 0000000..d6ddc14
--- /dev/null
+++ b/homework/81248/cToHtml/app/.Main.hs.swp
Binary files differ
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"