Skip to content

Commit

Permalink
refactor: remove [Parse_buffer.accept2]
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrinberg committed Oct 27, 2024
1 parent 76dabf6 commit 93a393a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
7 changes: 4 additions & 3 deletions lib/emacs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ let by_code f c c' =
let parse s =
let buf = Parse_buffer.create s in
let accept = Parse_buffer.accept buf in
let accept2 = Parse_buffer.accept2 buf in
let eos () = Parse_buffer.eos buf in
let test2 = Parse_buffer.test2 buf in
let get () = Parse_buffer.get buf in
let rec regexp () = regexp' [ branch () ]
and regexp' left =
if accept2 '\\' '|' then regexp' (branch () :: left) else Re.alt (List.rev left)
if Parse_buffer.accept_s buf {|\||}
then regexp' (branch () :: left)
else Re.alt (List.rev left)
and branch () = branch' []
and branch' left =
if eos () || test2 '\\' '|' || test2 '\\' ')'
Expand Down Expand Up @@ -69,7 +70,7 @@ let parse s =
if accept '('
then (
let r = regexp () in
if not (accept2 '\\' ')') then raise Parse_error;
if not (Parse_buffer.accept_s buf {|\)|}) then raise Parse_error;
Re.group r)
else if accept '`'
then Re.bos
Expand Down
6 changes: 0 additions & 6 deletions lib/parse_buffer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ let accept t c =
r
;;

let accept2 t c c' =
let r = test2 t c c' in
if r then t.pos <- t.pos + 2;
r
;;

let get t =
let r = t.str.[t.pos] in
t.pos <- t.pos + 1;
Expand Down
1 change: 0 additions & 1 deletion lib/parse_buffer.mli
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ val test : t -> char -> bool
val test2 : t -> char -> char -> bool
val get : t -> char
val accept : t -> char -> bool
val accept2 : t -> char -> char -> bool
val accept_s : t -> string -> bool
val integer : t -> int option

0 comments on commit 93a393a

Please sign in to comment.