aboutsummaryrefslogtreecommitdiff
path: root/src/parser/Parser.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/Parser.ml')
-rw-r--r--src/parser/Parser.ml13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/parser/Parser.ml b/src/parser/Parser.ml
new file mode 100644
index 0000000..4593d82
--- /dev/null
+++ b/src/parser/Parser.ml
@@ -0,0 +1,13 @@
+let parse_expr (s : string) : Ast.expr =
+ let lexbuf = Lexing.from_string s in
+ let string_source : Asai.Range.string_source = {
+ title = None;
+ content = s;
+ } in
+ let source = `String string_source in
+ Eff.run ~env:source @@ fun () ->
+ try Grammar.start_expr Lexer.token lexbuf with
+ | Lexer.IllegalCharacter illegal_char ->
+ Reporter.illegal_character ~loc:(Asai.Range.of_lexbuf ~source lexbuf) illegal_char
+ | Grammar.Error ->
+ Reporter.syntax_error ~loc:(Asai.Range.of_lexbuf ~source lexbuf)