Skip to content

Commit

Permalink
Make filename parameter optional
Browse files Browse the repository at this point in the history
  • Loading branch information
juusaw committed Mar 27, 2019
1 parent f3f9806 commit 7d0bdd0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ struct

let run filename n defs =
let lb = createLexerStream
(if filename = "" then stdin
else open_in filename) in
(match filename with
Some (filename) -> (open_in filename)
| None -> stdin) in
let dice =
let (decls,exp) = Parser.dice Lexer.token lb in
(decls, defs exp) in
Expand Down Expand Up @@ -196,7 +197,7 @@ struct
arg = "gt" || arg = "lt"
then (col2 := arg;
run0 args filename n defs)
else run0 args arg n defs
else run0 args (Some arg) n defs
| Some (name,value) ->
run0 args filename n
(fun d -> Syntax.Syntax.LET
Expand Down Expand Up @@ -227,7 +228,7 @@ struct
let spec =
let open Core.Command.Spec in
empty
+> anon ("filename" %: string)
+> anon (maybe ("filename" %: string))

let command =
Core.Command.basic
Expand Down

0 comments on commit 7d0bdd0

Please sign in to comment.