Skip to content

Commit bd731f8

Browse files
JulowNathanReb
andcommitted
Cleanup
Co-authored-by: Nathan Rebours <[email protected]>
1 parent e656753 commit bd731f8

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/lexer_mdx.mll

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ let labels l =
1616
failwith msg
1717
}
1818

19-
let eol = '\n' | '\r' '\n' | eof
19+
let eol = '\n' | "\r\n" | eof
2020
let ws = [' ' '\t']
2121

22-
let until_eol = [^'\n' '\r']
23-
let until_ws = [^' ' '\t']
24-
let until_ws_or_eol = [^' ' '\t' '\n' '\r']
22+
let not_eol = [^'\n' '\r']
23+
let not_ws = [^' ' '\t']
24+
let not_ws_or_eol = [^' ' '\t' '\n' '\r']
2525

2626
rule text section = parse
2727
| eof { [] }
28-
| ("#"+ as n) " " (until_eol* as str) eol
28+
| ("#"+ as n) " " (not_eol* as str) eol
2929
{ let section = (String.length n, str) in
3030
newline lexbuf;
3131
`Section section :: text (Some section) lexbuf }
32-
| ( "<!--" ws* "$MDX" ws* (until_ws* as label_cmt) ws* "-->" ws* eol? )?
33-
"```" (until_ws_or_eol* as h) ws* (until_eol* as legacy_labels) eol
32+
| ( "<!--" ws* "$MDX" ws* (not_ws* as label_cmt) ws* "-->" ws* eol? )?
33+
"```" (not_ws_or_eol* as h) ws* (not_eol* as legacy_labels) eol
3434
{ let header = Block.Header.of_string h in
3535
let contents = block lexbuf in
3636
let labels, legacy_labels =
@@ -67,7 +67,7 @@ rule text section = parse
6767
List.iter (fun _ -> newline lexbuf) errors;
6868
newline lexbuf);
6969
`Block block :: text section lexbuf }
70-
| "<!--" ws* "$MDX" ws* (until_ws* as label_cmt) ws* "-->" ws* eol
70+
| "<!--" ws* "$MDX" ws* (not_ws* as label_cmt) ws* "-->" ws* eol
7171
{ let labels = labels label_cmt in
7272
newline lexbuf;
7373
let loc = Location.curr lexbuf in
@@ -77,24 +77,24 @@ rule text section = parse
7777
| Error (`Msg msg) -> failwith msg
7878
in
7979
`Block block :: text section lexbuf }
80-
| (until_eol* as str) eol
80+
| (not_eol* as str) eol
8181
{ newline lexbuf;
8282
`Text str :: text section lexbuf }
8383

8484
and block = parse
8585
| eof | "```" ws* eol { [] }
86-
| (until_eol* as str) eol { str :: block lexbuf }
86+
| (not_eol* as str) eol { str :: block lexbuf }
8787

8888
and error_block = parse
8989
| "```mdx-error" ws* eol { block lexbuf }
9090

9191
and cram_text section = parse
9292
| eof { [] }
93-
| ("#"+ as n) " " (until_eol* as str) eol
93+
| ("#"+ as n) " " (not_eol* as str) eol
9494
{ let section = (String.length n, str) in
9595
newline lexbuf;
9696
`Section section :: cram_text (Some section) lexbuf }
97-
| " " (until_eol* as first_line) eol
97+
| " " (not_eol* as first_line) eol
9898
{ let header = Some (Block.Header.Shell `Sh) in
9999
let requires_empty_line, contents = cram_block lexbuf in
100100
let contents = first_line :: contents in
@@ -113,7 +113,7 @@ and cram_text section = parse
113113
in
114114
`Block block
115115
:: (if requires_empty_line then `Text "" :: rest else rest) }
116-
| "<-- non-deterministic" ws* (until_eol* as choice) eol
116+
| "<-- non-deterministic" ws* (not_eol* as choice) eol
117117
{ let header = Some (Block.Header.Shell `Sh) in
118118
let requires_empty_line, contents = cram_block lexbuf in
119119
let labels =
@@ -136,14 +136,14 @@ and cram_text section = parse
136136
in
137137
`Block block
138138
:: (if requires_empty_line then `Text "" :: rest else rest) }
139-
| (until_eol* as str) eol
139+
| (not_eol* as str) eol
140140
{ newline lexbuf;
141141
`Text str :: cram_text section lexbuf }
142142

143143
and cram_block = parse
144144
| eof { false, [] }
145145
| eol { newline lexbuf; true, [] }
146-
| " " (until_eol* as str) eol
146+
| " " (not_eol* as str) eol
147147
{ let requires_empty_line, lst = cram_block lexbuf in
148148
requires_empty_line, str :: lst }
149149

0 commit comments

Comments
 (0)