nested comment block
This commit is contained in:
parent
75e2d0e78c
commit
899dae5ea1
1 changed files with 14 additions and 8 deletions
|
@ -107,12 +107,16 @@ let str_char = ascii_table
|
|||
| '\''
|
||||
| "\\\""
|
||||
|
||||
(* Commentaires *)
|
||||
let open_comment = "{*"
|
||||
let close_comment = "*}"
|
||||
|
||||
rule token = parse
|
||||
(** Layout *)
|
||||
| newline { next_line_and token lexbuf }
|
||||
| blank+ { token lexbuf }
|
||||
| eof { EOF }
|
||||
| "{*" { commentary lexbuf }
|
||||
| open_comment { commentary 1 lexbuf }
|
||||
| "##" { commentary_line lexbuf }
|
||||
|
||||
(** Keywords *)
|
||||
|
@ -189,16 +193,18 @@ rule token = parse
|
|||
| "'" ascii_trop_grand "'" { error lexbuf None "" }
|
||||
| _ as _c { error lexbuf None (* (Some _c) *) err_msg }
|
||||
|
||||
(* TODO: Gérer les imbrications de commentaires *)
|
||||
and commentary = parse
|
||||
| "*}" { token lexbuf }
|
||||
| newline { next_line_and commentary lexbuf }
|
||||
and commentary nest = parse
|
||||
(* Support nesting *)
|
||||
| close_comment { if nest = 1 then token lexbuf
|
||||
else commentary (nest - 1) lexbuf }
|
||||
| open_comment { commentary (nest + 1) lexbuf }
|
||||
|
||||
(** Error *)
|
||||
| eof { error lexbuf None "unclosed commentary." }
|
||||
|
||||
(** Commentary content *)
|
||||
| _ { commentary lexbuf }
|
||||
| newline { next_line_and (commentary nest) lexbuf }
|
||||
| _ { commentary nest lexbuf }
|
||||
|
||||
and commentary_line = parse
|
||||
| newline { next_line_and token lexbuf }
|
||||
|
|
Reference in a new issue