From c1cf0693982d9c1f1b871966752140fee5d76d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 13 Jul 2022 04:39:14 +0200 Subject: work --- module/c/lex2.scm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'module/c/lex2.scm') 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)))))) -- cgit v1.2.3