aboutsummaryrefslogtreecommitdiff
path: root/module/c
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-03-17 22:14:18 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-03-28 14:17:01 +0200
commit1da5a277188a954d881316cb605962ee66053285 (patch)
tree4f77be46498f321d08bfaa072636e4fd252b4f9d /module/c
parentUnsmarted define-config% (diff)
downloadcalp-1da5a277188a954d881316cb605962ee66053285.tar.gz
calp-1da5a277188a954d881316cb605962ee66053285.tar.xz
Normalize errors.
Diffstat (limited to 'module/c')
-rw-r--r--module/c/cpp.scm8
-rw-r--r--module/c/parse.scm20
2 files changed, 18 insertions, 10 deletions
diff --git a/module/c/cpp.scm b/module/c/cpp.scm
index 8710fdd2..3f50fb87 100644
--- a/module/c/cpp.scm
+++ b/module/c/cpp.scm
@@ -5,7 +5,6 @@
:use-module (ice-9 match)
:use-module (ice-9 regex)
:use-module ((rnrs io ports) :select (call-with-port))
- :use-module (ice-9 pretty-print) ; used by one error handler
:use-module (ice-9 format)
:use-module ((hnh util io) :select (read-lines))
:use-module (hnh util graph)
@@ -26,7 +25,10 @@
(aif (regexp-exec define-re header-line)
(cons (match:substring it 1)
(match:substring it 4))
- (error "Line dosen't match" header-line)))
+ (scm-error 'c-parse-error
+ "tokenize-define-line"
+ "Line dosen't match: ~s"
+ (list header-line) #f)))
(define-public (do-funcall function arguments)
@@ -100,7 +102,7 @@
(map (lambda (line)
(catch #t
(lambda () (parse-cpp-define line))
- (lambda (err caller fmt args . _)
+ (lambda (err caller fmt args data)
(format #t "~a ~?~%" fmt args)
#f)))
lines))
diff --git a/module/c/parse.scm b/module/c/parse.scm
index 3e3d8024..8030da77 100644
--- a/module/c/parse.scm
+++ b/module/c/parse.scm
@@ -34,7 +34,9 @@
[(LL) '(long-long)]
[(L) '(long)]
[(U) '(unsigned)])
- (error "Invalid integer suffix")))
+ (scm-error 'c-parse-error "parse-integer-suffix"
+ "Invalid integer suffix ~s"
+ (list str) #f)))
(define (parse-lexeme-tree tree)
(match tree
@@ -113,11 +115,11 @@
`(funcall ,(parse-lexeme-tree function)
,(parse-lexeme-tree arguments))]
- [bare (throw 'parse-error
- 'parse-lexeme-tree
- "Naked literal in lex-tree. How did that get there?"
- '()
- bare)]))
+ [bare (scm-error 'c-parse-error
+ "parse-lexeme-tree"
+ "Naked literal in lex-tree: ~s"
+ (list bare)
+ #f)]))
;; https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B
@@ -175,7 +177,11 @@
(parse-lexeme-tree op)
(mark-other (parse-lexeme-tree right)))]
- [other (error "Not an infix tree ~a" other)]))
+ [other (scm-error 'c-parse-error
+ "flatten-infix"
+ "Not an infix tree ~a"
+ (list other)
+ #f)]))