Jonathan Graveline pushed to branch graveline at Stefan / Typer
Commits: 7884d73f by Jonathan Graveline at 2018-06-13T19:49:52Z Renamed Parse_default to Parser_default, Corrected String.sub argument count - - - - -
1 changed file:
- src/eval.ml
Changes:
===================================== src/eval.ml ===================================== --- a/src/eval.ml +++ b/src/eval.ml @@ -285,7 +285,7 @@ let make_block loc depth args_val = match args_val with | [Vstring str] -> Vsexp (Block (loc, (Prelexer.prelex_string str), loc)) | _ -> error loc "Sexp.block expects one string as argument"
-let parse_default loc depth args_val = match args_val with +let parser_default loc depth args_val = match args_val with | [Vsexp (Block (_,toks,_))] -> o2v_list (sexp_parse_all_to_list default_grammar (Lexer.lex default_stt toks) (Some ";")) | [s] -> (warning loc "Parser.default do nothing without a Block"; s) @@ -673,7 +673,11 @@ let io_return loc depth args_val = match args_val with
let float_to_string loc depth args_val = match args_val with | [Vfloat x] -> Vstring (string_of_float x) - | _ -> error loc "Float->string expects one Float arg" + | _ -> error loc "Float->String expects one Float arg" + +let int_to_string loc depth args_val = match args_val with + | [Vint x] -> Vstring (string_of_int x) + | _ -> error loc "Int->String expects one Int arg"
let sys_exit loc depth args_val = match args_val with | [Vint n] -> Vcommand (fun _ -> exit n) @@ -709,13 +713,14 @@ let register_builtin_functions () = ("Sexp.float" , make_float, 1); ("Sexp.node" , make_node, 2); ("Sexp.dispatch" , sexp_dispatch, 7); - ("Parser.default", parse_default,1); + ("Parser.default", parser_default,1); ("String.=" , string_eq, 2); ("String.concat" , string_concat, 2); - ("String.sub" , string_sub, 2); + ("String.sub" , string_sub, 3); ("Sexp.=" , sexp_eq, 2); - ("Sexp.debug_print" , sexp_debug_print, 1); - ("Float->String", float_to_string, 1); + ("Sexp.debug_print", sexp_debug_print, 1); + ("Float->String" , float_to_string, 1); + ("Int->String" , int_to_string, 1); ("IO.bind" , io_bind, 2); ("IO.return" , io_return, 1); ("IO.run" , io_run, 2);
View it on GitLab: https://gitlab.com/monnier/typer/commit/7884d73f784ff7d56c564d3a07838768a422...