@@ -58,9 +58,31 @@ private partial def mkErrorMessage (c : InputContext) (pos : String.Pos.Raw) (st
5858 pos := r.start
5959 endPos? := some r.stop
6060 let unexpected := match e.unexpectedTk with
61- | .ident .. => "unexpected identifier"
62- | .atom _ v => s! "unexpected token '{ v} '"
63- | _ => "unexpected token" -- TODO: categorize (custom?) literals as well?
61+ | .ident _ rawVal _ _ =>
62+ s! "unexpected identifier `{ Substring.Raw.Internal.toString rawVal} `"
63+ | .atom _ v =>
64+ s! "unexpected token `{ v} `"
65+ | .node _ k #[.atom _ v] =>
66+ if k == numLitKind then
67+ s! "unexpected numeral `{ v} `"
68+ else if k == strLitKind then
69+ s! "unexpected string literal `{ v} `"
70+ else if k == charLitKind then
71+ s! "unexpected character literal `{ v} `"
72+ else if k == scientificLitKind then
73+ s! "unexpected scientific numeral `{ v} `"
74+ else if k == nameLitKind then
75+ s! "unexpected name literal { v} "
76+ else if k == fieldIdxKind then
77+ s! "unexpected field index `{ v} `"
78+ else if k == hexnumKind then
79+ s! "unexpected hexadecimal number `{ v} `"
80+ else if k == interpolatedStrLitKind then
81+ s! "unexpected interpolated string fragment `{ v} `"
82+ else
83+ s! "unexpected token `{ v} ` (kind `{ k} `)"
84+ | _ =>
85+ "unexpected token"
6486 e := { e with unexpected }
6587 -- if there is an unexpected token, include preceding whitespace as well as the expected token could
6688 -- be inserted at any of these places to fix the error; see tests/lean/1971.lean
0 commit comments