aboutsummaryrefslogtreecommitdiff
path: root/module/c/lex2.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-13 04:39:14 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-13 04:39:14 +0200
commitc1cf0693982d9c1f1b871966752140fee5d76d19 (patch)
tree65cf5c501f5b2029eb08bed7fa9844b9530385f3 /module/c/lex2.scm
parentResolve # ## # (diff)
downloadcalp-c1cf0693982d9c1f1b871966752140fee5d76d19.tar.gz
calp-c1cf0693982d9c1f1b871966752140fee5d76d19.tar.xz
work
Diffstat (limited to '')
-rw-r--r--module/c/lex2.scm13
1 files changed, 12 insertions, 1 deletions
diff --git a/module/c/lex2.scm b/module/c/lex2.scm
index 652aa6c1..fcddcdc4 100644
--- a/module/c/lex2.scm
+++ b/module/c/lex2.scm
@@ -368,4 +368,15 @@
(if (string-null? string)
'()
(map lex-output->lexeme-object
- (cdr (peg:tree (match-pattern preprocessing-tokens string))))))
+ (let ((result (match-pattern preprocessing-tokens string)))
+ (let ((trailing (substring (peg:string result)
+ (peg:end result))))
+ (unless (string-null? trailing)
+ (scm-error 'cpp-lex-error "lex"
+ "Failed to lex string, remaining trailing characters: ~s"
+ (list trailing) #f)))
+ (unless (list? (peg:tree result))
+ (scm-error 'cpp-lex-error "lex"
+ "Parsing just failed. Chars: ~s"
+ (list (peg:string result)) #f))
+ (cdr (peg:tree result))))))