# HG changeset patch # User wenzelm # Date 1390245884 -3600 # Node ID 080c0006e917dfc545f353836f2fc2aac15ff6da # Parent 75815b3b38a1fb03a652ef98246c842a451e6e7e tuned error messages, more accurate position; diff -r 75815b3b38a1 -r 080c0006e917 src/HOL/SPARK/Tools/fdl_lexer.ML --- a/src/HOL/SPARK/Tools/fdl_lexer.ML Mon Jan 20 20:04:52 2014 +0100 +++ b/src/HOL/SPARK/Tools/fdl_lexer.ML Mon Jan 20 20:24:44 2014 +0100 @@ -205,7 +205,7 @@ val any_line = whitespace' |-- any_line' --| newline >> (implode o map symbol); -fun gen_comment a b = $$$ a |-- !!! "missing end of comment" +fun gen_comment a b = $$$ a |-- !!! "unclosed comment" (Scan.repeat (Scan.unless ($$$ b) any) --| $$$ b) >> make_token Comment; val c_comment = gen_comment "/*" "*/"; diff -r 75815b3b38a1 -r 080c0006e917 src/Pure/General/symbol_pos.ML --- a/src/Pure/General/symbol_pos.ML Mon Jan 20 20:04:52 2014 +0100 +++ b/src/Pure/General/symbol_pos.ML Mon Jan 20 20:24:44 2014 +0100 @@ -204,12 +204,14 @@ in fun scan_comment err_prefix = - $$$ "(" @@@ $$$ "*" @@@ - !!! (fn () => err_prefix ^ "missing end of comment") (scan_body @@@ $$$ "*" @@@ $$$ ")"); + Scan.ahead ($$ "(" -- $$ "*") |-- + !!! (fn () => err_prefix ^ "unclosed comment") + ($$$ "(" @@@ $$$ "*" @@@ scan_body @@@ $$$ "*" @@@ $$$ ")"); fun scan_comment_body err_prefix = - $$$ "(" |-- $$$ "*" |-- - !!! (fn () => err_prefix ^ "missing end of comment") (scan_body --| $$$ "*" --| $$$ ")"); + Scan.ahead ($$ "(" -- $$ "*") |-- + !!! (fn () => err_prefix ^ "unclosed comment") + ($$ "(" |-- $$ "*" |-- scan_body --| $$ "*" --| $$ ")"); val recover_comment = $$$ "(" @@@ $$$ "*" @@@ scan_cmts; diff -r 75815b3b38a1 -r 080c0006e917 src/Pure/Isar/token.ML --- a/src/Pure/Isar/token.ML Mon Jan 20 20:04:52 2014 +0100 +++ b/src/Pure/Isar/token.ML Mon Jan 20 20:24:44 2014 +0100 @@ -325,9 +325,11 @@ Scan.one (fn (s, _) => s <> "*" andalso Symbol.is_regular s) >> single; val scan_verbatim = - (Symbol_Pos.scan_pos --| $$$ "{" --| $$$ "*") -- !!! "missing end of verbatim text" - (Symbol_Pos.change_prompt - ((Scan.repeat scan_verb >> flat) -- ($$$ "*" |-- $$$ "}" |-- Symbol_Pos.scan_pos))); + Scan.ahead ($$$ "{" -- $$$ "*") |-- + !!! "unclosed verbatim text" + ((Symbol_Pos.scan_pos --| $$$ "{" --| $$$ "*") -- + Symbol_Pos.change_prompt + ((Scan.repeat scan_verb >> flat) -- ($$$ "*" |-- $$$ "}" |-- Symbol_Pos.scan_pos))); val recover_verbatim = $$$ "{" @@@ $$$ "*" @@@ (Scan.repeat scan_verb >> flat); diff -r 75815b3b38a1 -r 080c0006e917 src/Pure/Syntax/lexicon.ML --- a/src/Pure/Syntax/lexicon.ML Mon Jan 20 20:04:52 2014 +0100 +++ b/src/Pure/Syntax/lexicon.ML Mon Jan 20 20:24:44 2014 +0100 @@ -217,12 +217,14 @@ $$$ "'" --| Scan.ahead (~$$$ "'"); val scan_str = - $$$ "'" @@@ $$$ "'" @@@ !!! "missing end of string" - ((Scan.repeat scan_chr >> flat) @@@ $$$ "'" @@@ $$$ "'"); + Scan.ahead ($$ "'" -- $$ "'") |-- + !!! "unclosed string literal" + ($$$ "'" @@@ $$$ "'" @@@ (Scan.repeat scan_chr >> flat) @@@ $$$ "'" @@@ $$$ "'"); val scan_str_body = - $$$ "'" |-- $$$ "'" |-- !!! "missing end of string" - ((Scan.repeat scan_chr >> flat) --| $$$ "'" --| $$$ "'"); + Scan.ahead ($$$ "'" |-- $$$ "'") |-- + !!! "unclosed string literal" + ($$ "'" |-- $$ "'" |-- (Scan.repeat scan_chr >> flat) --| $$ "'" --| $$ "'"); fun implode_str cs = enclose "''" "''" (implode (map (fn "'" => "\\'" | c => c) cs));