NXTDSL 0.2 → 0.3
raw patch · 3 files changed
+29/−18 lines, 3 filesdep +attoparsecdep +hashabledep −uu-parsinglibnew-component:exe:Compiler
Dependencies added: attoparsec, hashable
Dependencies removed: uu-parsinglib
Files
- Compiler.hs +25/−0
- NXTDSL.cabal +4/−4
- Parser.hs +0/−14
+ Compiler.hs view
@@ -0,0 +1,25 @@+import qualified NXT.AttoParser as P+import NXT.Types+import NXT.Inference++import System.Environment++main =+ do args <- getArgs+ case args of+ [filename] -> parseFile filename+ _ -> putStrLn "USAGE: ./Compiler [filename]"++parseFile f =+ do pResult <- P.parseFile f+ case pResult of+ Left errorMsg ->+ putStrLn $ "Error: " ++ errorMsg+ Right funDefs ->+ do inferredDefs <- runInference funDefs+ let cComment = "/* Generated by legoDSL. Don't touch! */"+ cHeader = concatMap (prettyFD' False) inferredDefs+ cCode = concatMap prettyFD inferredDefs+ outFile = f ++ ".nxc"+ writeFile outFile $ (cComment ++ cHeader ++ cCode)+ putStrLn $ "Compiling ok. Generated " ++ outFile
NXTDSL.cabal view
@@ -1,5 +1,5 @@ Name: NXTDSL-Version: 0.2+Version: 0.3 Synopsis: Generate NXC Code from DSL Description: Typesafe code generation for the LEGO-NXT License: BSD3@@ -14,7 +14,7 @@ Bug-reports: https://github.com/agrafix/legoDSL/issues Library- Build-Depends: base >= 3 && < 5, mtl, unordered-containers, resourcet >= 0.4.4, stm >= 2.4.2, text, uu-parsinglib >= 2.7.4+ Build-Depends: base >= 3 && < 5, mtl, unordered-containers, resourcet >= 0.4.4, stm >= 2.4.2, text, attoparsec >= 0.10.4.0, hashable >= 1.2.0.5 Exposed-modules: NXT.Core, NXT.Interpretation, NXT.Common, NXT.Motor, NXT.Sensor Executable ExampleRun@@ -24,8 +24,8 @@ Main-Is: ExampleVM.hs ghc-options: -threaded -Executable Parser- Main-Is: Parser.hs+Executable Compiler+ Main-Is: Compiler.hs Source-repository head Type: git
− Parser.hs
@@ -1,14 +0,0 @@-import NXT.Parser-import NXT.Types--import System.Environment--main =- do args <- getArgs- case args of- [filename] -> parseFile filename- _ -> putStrLn "USAGE: ./Parser [filename]"--parseFile f =- do r <- runFile pProg f- mapM_ (\v -> putStrLn (prettyFD v)) r