Skip to content

Commit

Permalink
fix: sexp parser
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarLiner committed Oct 31, 2021
1 parent cbd2085 commit b65f999
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/sexp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ let num =
let num = String.of_seq chars |> int_of_string in
Int num

let atom = ident <|> num <|> operator <?> "atom"
let atom = token (ident <|> num <|> operator) <?> "atom"

let parens p = surround (token (char '(')) (token (char ')')) p <?> "parentheses"

let sexp =
let call sexp = let+ vals = many sexp in Cons vals in
fix (fun sexp -> parens (call sexp) <|> atom <?> "fix") <?> "sexp"
fix (fun sexp -> (parens (call sexp) <|> atom) <?> "fix") <?> "sexp"

let parser = many sexp <* eof
let parser = many sexp

let of_string s = parse_string parser s

Expand Down

0 comments on commit b65f999

Please sign in to comment.