aboutsummaryrefslogtreecommitdiffstats
path: root/lib/front.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-07-11 03:07:56 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-07-11 03:07:56 -0300
commitc530682030e80ee2de2c263471e5eda7a3392e84 (patch)
tree43099c96f71f01ad1ebd04724fbf7f39852b30b9 /lib/front.ml
parent5d5a6e68032f263bfd524794f75174dafd04bf3f (diff)
downloadSOL-c530682030e80ee2de2c263471e5eda7a3392e84.tar.gz
SOL-c530682030e80ee2de2c263471e5eda7a3392e84.zip
working vm: parser, admission with totality checks, solver and repl
Diffstat (limited to 'lib/front.ml')
-rw-r--r--lib/front.ml14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/front.ml b/lib/front.ml
new file mode 100644
index 0000000..7cacc20
--- /dev/null
+++ b/lib/front.ml
@@ -0,0 +1,14 @@
+let parse_string source =
+ let lexbuf = Lexing.from_string source in
+ match Parser.program Lexer.token lexbuf with
+ | statements -> Ok statements
+ | exception Lexer.Error message ->
+ let position = lexbuf.Lexing.lex_curr_p in
+ Error
+ (Printf.sprintf "lexical error at line %d: %s"
+ position.Lexing.pos_lnum message)
+ | exception Parser.Error ->
+ let position = lexbuf.Lexing.lex_curr_p in
+ Error
+ (Printf.sprintf "syntax error at line %d, before %S"
+ position.Lexing.pos_lnum (Lexing.lexeme lexbuf))