about summary refs log tree commit diff
path: root/src/parser/Parser.ml
blob: 4593d827519eb232b1da786c24482c03f181f423 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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)