Skip to content

Commit 62fa9e1

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 a499fd3 commit 62fa9e1

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
@@ -43,7 +43,7 @@ import System.FilePath
4343
----- COMPILER FLAGS -----------------------------------------------------------
4444

4545
data Flag
46-
= IRMode
46+
= TextIRMode
4747
| JSONIRMode
4848
| LibMode
4949
| NoRawOpt
@@ -55,12 +55,12 @@ data Flag
5555

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

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

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

222222
--------------------------------------------------------------------------------
223223
----- MAIN ---------------------------------------------------------------------
@@ -234,11 +234,8 @@ main = do
234234
putStrLn compilerUsage
235235
exitSuccess
236236

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

243240
(o, [file], []) | optionsOK o ->
244241
fromFile o file
@@ -254,7 +251,7 @@ main = do
254251
optionsOK :: [Flag] -> Bool
255252
optionsOK o | length o >=2 =
256253
-- certain options must not be combined
257-
not.or $ map (`elem` o) [IRMode, Help]
254+
not.or $ map (`elem` o) [TextIRMode, Help]
258255
optionsOK _ = True
259256

260257

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)