diff options
Diffstat (limited to 'module/c/lex2.scm')
-rw-r--r-- | module/c/lex2.scm | 13 |
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)))))) |