Add comment
This commit is contained in:
parent
26c6f3d7bf
commit
a0791f97ad
1 changed files with 4 additions and 1 deletions
5
lex.ml
5
lex.ml
|
@ -9,6 +9,8 @@ let expected col c = raise @@ Expected (col, c)
|
||||||
let either f g c =
|
let either f g c =
|
||||||
f c || g c
|
f c || g c
|
||||||
|
|
||||||
|
(* test functions *)
|
||||||
|
|
||||||
let is_digit c =
|
let is_digit c =
|
||||||
'0' <= c && c <= '9'
|
'0' <= c && c <= '9'
|
||||||
|
|
||||||
|
@ -30,10 +32,11 @@ let is_ident_start =
|
||||||
let is_ident =
|
let is_ident =
|
||||||
either is_ident_start is_digit
|
either is_ident_start is_digit
|
||||||
|
|
||||||
|
(* expect_char expects c at col of seq. If not, raise Expected. *)
|
||||||
let expect_char col c seq =
|
let expect_char col c seq =
|
||||||
match seq () with
|
match seq () with
|
||||||
| Seq.Nil -> expected col c
|
| Seq.Nil -> expected col c
|
||||||
| Seq.Cons ((_, x), seq) ->
|
| Seq.Cons ((col, x), seq) ->
|
||||||
if x = c then seq else expected col c
|
if x = c then seq else expected col c
|
||||||
|
|
||||||
let expect_token str tok seq =
|
let expect_token str tok seq =
|
||||||
|
|
Loading…
Add table
Reference in a new issue