parent
a6af257b7a
commit
42e681a5a6
5 changed files with 19 additions and 8 deletions
|
|
@ -724,7 +724,6 @@ def takeWhileFn (p : Char → Bool) : ParserFn :=
|
|||
@[inline] def takeWhile1Fn (p : Char → Bool) (errorMsg : String) : ParserFn :=
|
||||
andthenFn (satisfyFn p errorMsg) (takeWhileFn p)
|
||||
|
||||
variable (startPos : String.Pos) in
|
||||
partial def finishCommentBlock (nesting : Nat) : ParserFn := fun c s =>
|
||||
let input := c.input
|
||||
let i := s.pos
|
||||
|
|
@ -749,7 +748,7 @@ partial def finishCommentBlock (nesting : Nat) : ParserFn := fun c s =>
|
|||
else finishCommentBlock nesting c (s.setPos i)
|
||||
else finishCommentBlock nesting c (s.setPos i)
|
||||
where
|
||||
eoi s := s.mkUnexpectedErrorAt "unterminated comment" startPos
|
||||
eoi s := s.mkUnexpectedError "unterminated comment"
|
||||
|
||||
/- Consume whitespace and comments -/
|
||||
partial def whitespace : ParserFn := fun c s =>
|
||||
|
|
@ -774,7 +773,7 @@ partial def whitespace : ParserFn := fun c s =>
|
|||
let i := input.next i
|
||||
let curr := input.get i
|
||||
if curr == '-' then s -- "/--" doc comment is an actual token
|
||||
else andthenFn (finishCommentBlock startPos 1) whitespace c (s.next input i)
|
||||
else andthenFn (finishCommentBlock 1) whitespace c (s.next input i)
|
||||
else s
|
||||
else s
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Parser
|
|||
|
||||
namespace Command
|
||||
def commentBody : Parser :=
|
||||
{ fn := rawFn (fun c s => finishCommentBlock s.pos 1 c s) (trailingWs := true) }
|
||||
{ fn := rawFn (finishCommentBlock 1) (trailingWs := true) }
|
||||
|
||||
@[combinatorParenthesizer Lean.Parser.Command.commentBody] def commentBody.parenthesizer := PrettyPrinter.Parenthesizer.visitToken
|
||||
@[combinatorFormatter Lean.Parser.Command.commentBody] def commentBody.formatter := PrettyPrinter.Formatter.visitAtom Name.anonymous
|
||||
|
|
|
|||
9
tests/lean/interactive/unterminatedDocComment.lean
Normal file
9
tests/lean/interactive/unterminatedDocComment.lean
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/--
|
||||
def a1 := sorry
|
||||
def a2 := sorry
|
||||
def a3 := sorry
|
||||
...
|
||||
-
|
||||
--^ insert: /
|
||||
--^ collectDiagnostics
|
||||
def a4 := 0
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{"textDocument": {"version": 2, "uri": "file://unterminatedDocComment.lean"},
|
||||
"contentChanges":
|
||||
[{"text": "/",
|
||||
"range":
|
||||
{"start": {"line": 5, "character": 2}, "end": {"line": 5, "character": 3}}}]}
|
||||
{"version": 2, "uri": "file://unterminatedDocComment.lean", "diagnostics": []}
|
||||
|
|
@ -2,7 +2,4 @@ tokenErrors.lean:1:10: error: missing end of character literal
|
|||
tokenErrors.lean:2:9: error: invalid escape sequence
|
||||
tokenErrors.lean:3:7: error: unterminated string literal
|
||||
tokenErrors.lean:4:11: error: unterminated identifier escape
|
||||
tokenErrors.lean:6:0: error: unterminated comment
|
||||
tokenErrors.lean:7:0: error: unterminated comment
|
||||
tokenErrors.lean:7:1: error: unterminated comment
|
||||
tokenErrors.lean:7:0-7:1: error: unexpected command
|
||||
tokenErrors.lean:8:0: error: unterminated comment
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue