diff --git a/bootstrap/src/hlc/scan.ml b/bootstrap/src/hlc/scan.ml index 7d7800ba9..1f62f55aa 100644 --- a/bootstrap/src/hlc/scan.ml +++ b/bootstrap/src/hlc/scan.ml @@ -92,8 +92,8 @@ module Token = struct | LineDelim | Dedent | Whitespace - | HashComment of string - | ParenComment of string + | HashComment + | ParenComment | Uident of string | EndOfInput | IndentError @@ -172,8 +172,8 @@ module Token = struct | LineDelim -> "" | Dedent -> "" | Whitespace -> "" - | HashComment comment -> "" - | ParenComment comment -> "" + | HashComment -> "" + | ParenComment -> "" | Uident uident -> "" | EndOfInput -> "" | IndentError -> "" @@ -320,8 +320,7 @@ let whitespace _pcursor cursor t = let hash_comment _pcursor cursor t = let accept_hash_comment cursor t = begin - let comment_str = str_of_cursor cursor t in - accept_delim (Token.Variant.HashComment comment_str) cursor t + accept_delim Token.Variant.HashComment cursor t end in let rec fn cursor t = begin match Text.Cursor.next_opt cursor with @@ -336,8 +335,7 @@ let hash_comment _pcursor cursor t = let paren_comment _pcursor cursor t = let accept_paren_comment cursor t = begin - let comment_str = str_of_cursor cursor t in - accept (Token.Variant.ParenComment comment_str) cursor t + accept Token.Variant.ParenComment cursor t end in let rec fn nesting cursor t = begin match Text.Cursor.next_opt cursor with @@ -575,9 +573,9 @@ let dentation cursor t = let t', token = start t in match token.variant, t'.line_state with | EndOfInput, _ - | HashComment _, _ + | HashComment, _ | Whitespace, LineDelim -> LineNoop - | ParenComment _, _ + | ParenComment, _ | Whitespace, LineDentation -> fn t' | Whitespace, LineBody -> not_reached () | _ -> LineExpr @@ -665,36 +663,34 @@ let%expect_test "comment" = [%expect{xxx| {|#|} - 1:0..1:1 : + 1:0..1:1 : 1:1..1:1 : 1:1..1:1 : {|#...|} - 1:0..1:4 : + 1:0..1:4 : 1:4..1:4 : 1:4..1:4 : {|#... #...|} - 1:0..2:0 : - 2:0..2:4 : + 1:0..2:0 : + 2:0..2:4 : 2:4..2:4 : 2:4..2:4 : {|#... #...|} - 1:0..2:0 : + 1:0..2:0 : 2:0..2:4 : - 2:4..2:8 : + 2:4..2:8 : 2:8..2:8 : 2:8..2:8 : {|(**)|} - 1:0..1:4 : + 1:0..1:4 : 1:4..1:4 : {|(***)|} - 1:0..1:5 : + 1:0..1:5 : 1:5..1:5 : {|(*(*(#*#)*)*)|} - 1:0..1:13 : + 1:0..1:13 : 1:13..1:13 : {|(**|} 1:0..1:3 : @@ -1029,8 +1025,7 @@ g f g |} - 1:0..2:0 : + 1:0..2:0 : 2:0..2:0 : 2:0..2:1 : 2:1..3:0 : @@ -1038,10 +1033,8 @@ g 3:4..3:5 : 3:5..4:0 : 4:0..4:4 : - 4:4..5:0 : - 5:0..6:0 : + 4:4..5:0 : + 5:0..6:0 : 6:0..6:4 : 6:4..6:5 : 6:5..7:0 : @@ -1071,7 +1064,7 @@ g 2:0..2:4 : 2:4..2:5 : 2:5..3:0 : - 3:0..3:13 : + 3:0..3:13 : 3:13..4:0 : 4:0..4:4 : 4:4..4:5 : @@ -1088,12 +1081,11 @@ g 2:0..2:4 : 2:4..2:5 : 2:5..3:0 : - 3:0..3:13 : + 3:0..3:13 : 3:13..3:14 : - 3:14..3:23 : + 3:14..3:23 : 3:23..3:24 : - 3:24..4:0 : + 3:24..4:0 : 4:0..4:4 : 4:4..4:5 : 4:5..5:0 : @@ -1111,13 +1103,11 @@ g 2:0..2:4 : 2:4..2:5 : 2:5..3:0 : - 3:0..3:13 : + 3:0..3:13 : 3:13..3:14 : - 3:14..4:7 : + 3:14..4:7 : 4:7..5:0 : - 5:0..6:0 : + 5:0..6:0 : 6:0..6:4 : 6:4..6:5 : 6:5..7:0 : @@ -1134,7 +1124,7 @@ g 2:4..2:5 : 2:5..3:0 : 3:0..3:0 : - 3:0..3:19 : + 3:0..3:19 : 3:19..3:20 : 3:20..3:24 : 3:24..4:0 : @@ -1156,10 +1146,9 @@ g 2:4..2:5 : 2:5..3:0 : 3:0..3:0 : - 3:0..3:19 : + 3:0..3:19 : 3:19..3:20 : - 3:20..4:3 : + 3:20..4:3 : 4:3..5:1 : 5:1..5:5 : 5:5..6:0 : @@ -1180,10 +1169,9 @@ g 2:4..2:5 : 2:5..3:0 : 3:0..3:0 : - 3:0..3:19 : + 3:0..3:19 : 3:19..3:20 : - 3:20..4:7 : + 3:20..4:7 : 4:7..4:8 : 4:8..4:12 : 4:12..5:0 : diff --git a/bootstrap/src/hlc/scan.mli b/bootstrap/src/hlc/scan.mli index 76d14a245..3ead7ccbc 100644 --- a/bootstrap/src/hlc/scan.mli +++ b/bootstrap/src/hlc/scan.mli @@ -82,8 +82,8 @@ module Token : sig | LineDelim | Dedent | Whitespace - | HashComment of string - | ParenComment of string + | HashComment + | ParenComment | Uident of string | EndOfInput | IndentError