Skip to content

Commit

Permalink
added newline comments. differs slightly from alpha in consuming the …
Browse files Browse the repository at this point in the history
…newline
  • Loading branch information
rvantonder committed Sep 29, 2019
1 parent e2f0003 commit 1865c64
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/matchers/omega/matcher.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ module Make (Syntax : Syntax.S) (Info : Info.S) = struct
end)
in
M.comment
| Nested_multiline (_, _)
| Until_newline _ -> zero)
| Until_newline start ->
let module M = Parsers.Comments.Omega.Until_newline.Make(struct
let start = start
end)
in
M.comment
| Nested_multiline (_, _) -> zero) (* FIXME *)
|> choice

let until_of_from from =
Expand Down
19 changes: 19 additions & 0 deletions lib/parsers/comments.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ module Omega = struct
diverges from Alpha and is a little bit... weird *)
(many_till any_char (string until))

let anything_excluding_newlines () =
anything_including_newlines ~until:"\n"

let non_nested_comment from until =
between
(string from)
Expand All @@ -37,6 +40,22 @@ module Omega = struct
let comment = non_nested_comment M.left M.right
end
end

(* XXX consumes the newline *)
let until_newline start =
(string start *> anything_excluding_newlines ()
|>> fun l -> start^(String.of_char_list l))

module Until_newline = struct
module type S = sig
val start : string
end

module Make (M : S) = struct
let comment = until_newline M.start
end
end

end

module Alpha = struct
Expand Down

0 comments on commit 1865c64

Please sign in to comment.