diff options
author | Malte Voos <git@mal.tc> | 2024-02-16 00:43:04 +0100 |
---|---|---|
committer | Malte Voos <git@mal.tc> | 2024-02-16 00:43:04 +0100 |
commit | 06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2 (patch) | |
tree | c558e81d84fd12ef66e99c558e5b7dd1322e5c03 /bin | |
parent | 2bc6cae2458ba5f9573985791536618a00cbed8a (diff) | |
download | toytt-06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2.tar.gz toytt-06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2.zip |
basic lexer and parser
Diffstat (limited to 'bin')
-rw-r--r-- | bin/main.ml | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/bin/main.ml b/bin/main.ml index 732b852..1607ec4 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -1 +1,14 @@ -let () = print_ndline "Hello, World!" +open Toytt + +let parse (s : string) : Ast.expr = + let lexbuf = Lexing.from_string s in + let ast = Parser.parse Lexer.lex lexbuf in + ast + +let rec repl () = + let input = read_line () in + let ast = parse input in + Format.printf "%a\n%!" Ast.dump_expr ast; + repl () + +let () = repl () |