lexer: try_skip_space_and_comments: Make tail-recursive.
This commit is contained in:
parent
7ff2fb4f6c
commit
c195c3b83e
13
lex/lexer.ml
13
lex/lexer.ml
@ -181,8 +181,10 @@ let lex_char lexbuf =
|
|||||||
|
|
||||||
let skip_space_and_comments lexbuf =
|
let skip_space_and_comments lexbuf =
|
||||||
let str = get_next_buff lexbuf 2 in
|
let str = get_next_buff lexbuf 2 in
|
||||||
match (Bytes.get str 0) with
|
let len = Bytes.length str in
|
||||||
| '(' -> if (Bytes.get str 1) = '*'
|
if len = 0 then raise Bad_rule
|
||||||
|
else match (Bytes.get str 0) with
|
||||||
|
| '(' -> if (len > 1) && ((Bytes.get str 1) = '*')
|
||||||
then begin
|
then begin
|
||||||
advance lexbuf 2;
|
advance lexbuf 2;
|
||||||
lex_comment lexbuf;
|
lex_comment lexbuf;
|
||||||
@ -196,10 +198,9 @@ let skip_space_and_comments lexbuf =
|
|||||||
| _ -> raise Bad_rule
|
| _ -> raise Bad_rule
|
||||||
|
|
||||||
let rec try_skip_space_and_comments lexbuf =
|
let rec try_skip_space_and_comments lexbuf =
|
||||||
try
|
match skip_space_and_comments lexbuf with
|
||||||
skip_space_and_comments lexbuf;
|
| () -> try_skip_space_and_comments lexbuf
|
||||||
try_skip_space_and_comments lexbuf
|
| exception Bad_rule -> ()
|
||||||
with _ -> ();;
|
|
||||||
|
|
||||||
let _main lexbuf: Parser.token =
|
let _main lexbuf: Parser.token =
|
||||||
(* 1. skip spaces and comments *)
|
(* 1. skip spaces and comments *)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user