Improve parse error handling

slava 2006-11-28 23:44:55 +00:00
parent dffd8e296d
commit 2346d6b1ec
4 changed files with 8 additions and 10 deletions

View File

@ -3,7 +3,7 @@
- variable width word wrap - variable width word wrap
- graphical crossref tool - graphical crossref tool
- http://paste.lisp.org/display/30426 - http://paste.lisp.org/display/30426
- listener: if partial parse, RETURN should insert newline - parse errors should be shown in a popup
- compiled call traces: - compiled call traces:
- should be independent of whenever the runtime was built with - should be independent of whenever the runtime was built with
-fomit-frame-pointer or not -fomit-frame-pointer or not

View File

@ -35,10 +35,7 @@ C: source-file ( path -- source-file )
"scratchpad" set-in { "syntax" "scratchpad" } set-use ; "scratchpad" set-in { "syntax" "scratchpad" } set-use ;
: with-parser ( quot -- ) : with-parser ( quot -- )
0 line-number set [ 0 line-number set [ <parse-error> rethrow ] recover ;
dup [ parse-error? ] is? [ <parse-error> ] unless
rethrow
] recover ;
: parse-lines ( lines -- quot ) : parse-lines ( lines -- quot )
[ f [ (parse) ] reduce >quotation ] with-parser ; [ f [ (parse) ] reduce >quotation ] with-parser ;

View File

@ -83,10 +83,10 @@ M: string error. print ;
first3 continue-with ; first3 continue-with ;
: :edit ( -- ) : :edit ( -- )
error get error get delegates [ parse-error-file ] find nip [
dup parse-error-file ?resource-path dup parse-error-file ?resource-path
swap parse-error-line swap parse-error-line edit-location
edit-location ; ] when* ;
: (:help-multi) : (:help-multi)
"This error has multiple delegates:" print "This error has multiple delegates:" print

View File

@ -73,9 +73,10 @@ M: interactor stream-read
interactor-in in set ; interactor-in in set ;
: handle-parse-error ( interactor error -- ) : handle-parse-error ( interactor error -- )
dup [ parse-error? ] is? [ dup parse-error? [
2dup dup parse-error-line 1- swap parse-error-col 2array 2dup dup parse-error-line 1- swap parse-error-col 2array
over editor-caret set-model mark>caret over editor-caret set-model mark>caret
delegate
] when ] when
swap interactor-output [ print-error ] with-stream* ; swap interactor-output [ print-error ] with-stream* ;