Skip to content

Commit 205039d

Browse files
committed
Remove '-i' and '-j' as short-hand options
These are (a) only used by the runtime and/or (b) only used seldomly. Hence, we may as well open up for these to be used for something different, e.g. modules
1 parent 437691f commit 205039d

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

compiler/app/Main.hs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import System.FilePath
4242
----- COMPILER FLAGS -----------------------------------------------------------
4343

4444
data Flag
45-
= IRMode
45+
= TextIRMode
4646
| JSONIRMode
4747
| LibMode
4848
| NoRawOpt
@@ -54,12 +54,12 @@ data Flag
5454

5555
options :: [OptDescr Flag]
5656
options =
57-
[ Option ['i'] ["ir"] (NoArg IRMode) "ir interactive mode"
58-
, Option ['j'] ["json"] (NoArg JSONIRMode) "ir json interactive mode"
57+
[ Option [] ["text-ir"] (NoArg TextIRMode) "ir interactive mode (text)"
58+
, Option [] ["json-ir"] (NoArg JSONIRMode) "ir interactive mode (json)"
5959
, Option [] ["no-rawopt"] (NoArg NoRawOpt) "disable Raw optimization"
6060
, Option ['v'] ["verbose"] (NoArg Verbose) "verbose output"
6161
, Option ['d'] ["debug"] (NoArg Debug) "debugging information in the .js file"
62-
, Option [] ["lib"] (NoArg LibMode) "compiling a library"
62+
, Option [] ["lib"] (NoArg LibMode) "compiling a library [deprecated]"
6363
, Option ['h'] ["help"] (NoArg Help) "print usage"
6464
, Option ['o'] ["output"] (ReqArg OutputFile "FILE") "output FILE"
6565
]
@@ -193,7 +193,7 @@ writeExports path exports =
193193
--------------------------------------------------------------------------------
194194
----- DESERIALIZATION FOR INTERACTIVE MODES ------------------------------------
195195

196-
fromStdin putFormattedLn = do
196+
fromStdinIR putFormattedLn = do
197197
eof <- isEOF
198198
if eof then exitSuccess else do
199199
input <- BS.getLine
@@ -211,12 +211,12 @@ fromStdin putFormattedLn = do
211211
debugOut $ "decoding error" ++s
212212
putStrLn "" -- magic marker to be recognized by the JS runtime; 2018-03-04; aa
213213
hFlush stdout
214-
fromStdin putFormattedLn
214+
fromStdinIR putFormattedLn
215215
-- AA: 2018-07-15: consider timestamping these entries
216216
where debugOut s = appendFile "/tmp/debug" (s ++ "\n")
217217

218-
fromStdinIR = fromStdin (putStrLn . IR2JS.irToJSString)
219-
fromStdinIRJson = fromStdin (BSLazyChar8.putStrLn . IR2JS.irToJSON)
218+
fromStdinTextIR = fromStdinIR (putStrLn . IR2JS.irToJSString)
219+
fromStdinJsonIR = fromStdinIR (BSLazyChar8.putStrLn . IR2JS.irToJSON)
220220

221221
--------------------------------------------------------------------------------
222222
----- MAIN ---------------------------------------------------------------------
@@ -233,11 +233,8 @@ main = do
233233
putStrLn compilerUsage
234234
exitSuccess
235235

236-
([JSONIRMode], [], []) -> fromStdinIRJson
237-
238-
([IRMode], [], []) -> do
239-
fromStdinIR
240-
-- hSetBuffering stdout NoBuffering
236+
([TextIRMode], [], []) -> fromStdinTextIR
237+
([JSONIRMode], [], []) -> fromStdinJsonIR
241238

242239
(o, [file], []) | optionsOK o ->
243240
fromFile o file
@@ -253,7 +250,7 @@ main = do
253250
optionsOK :: [Flag] -> Bool
254251
optionsOK o | length o >=2 =
255252
-- certain options must not be combined
256-
not.or $ map (`elem` o) [IRMode, Help]
253+
not.or $ map (`elem` o) [TextIRMode, Help]
257254
optionsOK _ = True
258255

259256

rt/src/deserialize.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const HEADER:string =
3939
this.libs.push ({lib:lib, decl:decl})} }\n"
4040

4141
function startCompiler() {
42-
__compilerOsProcess = spawn(process.env.TROUPE + '/bin/troupec', ['--json']);
42+
__compilerOsProcess = spawn(process.env.TROUPE + '/bin/troupec', ['--json-ir']);
4343
__compilerOsProcess.on('exit', (code: number) => {
4444
process.exit(code);
4545
});

0 commit comments

Comments
 (0)