on master help sign in
:compile now can take a codegen option (e.g. :compile javascript program.js)
3c8f57craichoo
CHANGELOG+1
@@ -6,6 +6,7 @@ New in 0.9.13:
6* Command line option -e (or --eval) to evaluate expressions without loading the
6* Command line option -e (or --eval) to evaluate expressions without loading the
7 REPL. This is useful for writing more portable tests.
7 REPL. This is useful for writing more portable tests.
8* Many more of the basic functions and datatypes are documented.
8* Many more of the basic functions and datatypes are documented.
9+* Specify codegen for :compile REPL command (e.g. :compile javascript program.js)
9
10
10Internal changes
11Internal changes
11
12
src/Idris/Help.hs+1−2
@@ -49,8 +49,7 @@ help =
49 ([":showproof"], NameArg, "Show proof"),
49 ([":showproof"], NameArg, "Show proof"),
50 ([":proofs"], NoArg, "Show available proofs"),
50 ([":proofs"], NoArg, "Show available proofs"),
51 ([":x"], ExprArg, "Execute IO actions resulting from an expression using the interpreter"),
51 ([":x"], ExprArg, "Execute IO actions resulting from an expression using the interpreter"),
52− ([":c",":compile"], FileArg, "Compile to an executable <filename>"),
52+ ([":c",":compile"], FileArg, "Compile to an executable [codegen] <filename>"),
53− ([":js", ":javascript"], FileArg, "Compile to JavaScript <filename>"),
54 ([":exec",":execute"], NoArg, "Compile to an executable and run"),
53 ([":exec",":execute"], NoArg, "Compile to an executable and run"),
55 ([":dynamic"], FileArg, "Dynamically load a C library (similar to %dynamic)"),
54 ([":dynamic"], FileArg, "Dynamically load a C library (similar to %dynamic)"),
56 ([":dynamic"], NoArg, "List dynamically loaded C libraries"),
55 ([":dynamic"], NoArg, "List dynamically loaded C libraries"),
src/Idris/REPLParser.hs+13−3
@@ -38,9 +38,11 @@ pCmd = do P.whiteSpace; try (do cmd ["q", "quit"]; eof; return Quit)
38 return (ModImport (toPath f)))
38 return (ModImport (toPath f)))
39 <|> try (do cmd ["e", "edit"]; eof; return Edit)
39 <|> try (do cmd ["e", "edit"]; eof; return Edit)
40 <|> try (do cmd ["exec", "execute"]; eof; return Execute)
40 <|> try (do cmd ["exec", "execute"]; eof; return Execute)
41− <|> try (do cmd ["c", "compile"]; f <- P.identifier; eof; return (Compile ViaC f))
41+ <|> try (do cmd ["c", "compile"]
42− <|> try (do cmd ["jc", "newcompile"]; f <- P.identifier; eof; return (Compile ViaJava f))
42+ c <- option ViaC codegenOption
43− <|> try (do cmd ["js", "javascript"]; f <- P.identifier; eof; return (Compile ViaJavaScript f))
43+ f <- P.identifier
44+ eof
45+ return (Compile c f))
44 <|> try (do cmd ["proofs"]; eof; return Proofs)
46 <|> try (do cmd ["proofs"]; eof; return Proofs)
45 <|> try (do cmd ["rmproof"]; n <- P.name; eof; return (RmProof n))
47 <|> try (do cmd ["rmproof"]; n <- P.name; eof; return (RmProof n))
46 <|> try (do cmd ["showproof"]; n <- P.name; eof; return (ShowProof n))
48 <|> try (do cmd ["showproof"]; n <- P.name; eof; return (ShowProof n))
@@ -118,6 +120,14 @@ pOption = do discard (P.symbol "errorcontext"); return ErrContext
118 <|> do discard (P.symbol "originalerrors"); return ShowOrigErr
120 <|> do discard (P.symbol "originalerrors"); return ShowOrigErr
119 <|> do discard (P.symbol "autosolve"); return AutoSolve
121 <|> do discard (P.symbol "autosolve"); return AutoSolve
120
122
123+codegenOption :: P.IdrisParser Codegen
124+codegenOption = do discard (P.symbol "javascript"); return ViaJavaScript
125+ <|> do discard (P.symbol "node"); return ViaNode
126+ <|> do discard (P.symbol "Java"); return ViaJava
127+ <|> do discard (P.symbol "llvm"); return ViaLLVM
128+ <|> do discard (P.symbol "bytecode"); return Bytecode
129+ <|> do discard (P.symbol "C"); return ViaC
130+
121pConsoleWidth :: P.IdrisParser ConsoleWidth
131pConsoleWidth :: P.IdrisParser ConsoleWidth
122pConsoleWidth = do discard (P.symbol "auto"); return AutomaticWidth
132pConsoleWidth = do discard (P.symbol "auto"); return AutomaticWidth
123 <|> do discard (P.symbol "infinite"); return InfinitelyWide
133 <|> do discard (P.symbol "infinite"); return InfinitelyWide