From ccc7848110b06479cf8a38ee843d4d3adc01a27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 12 Jul 2022 02:37:49 +0200 Subject: work --- module/c/lex2.scm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'module/c/lex2.scm') diff --git a/module/c/lex2.scm b/module/c/lex2.scm index c00a029c..50cf56e3 100644 --- a/module/c/lex2.scm +++ b/module/c/lex2.scm @@ -285,12 +285,12 @@ ;; (6.4.7) (define-peg-pattern h-char body - (or (and (not-followed-by (or ">" "\n")) peg-any) + (or (and (not-followed-by (or ">" "\n")) peg-any) escape-sequence)) ;; (6.4.7) (define-peg-pattern q-char body - (or (and (not-followed-by (or "\"" "\n")) peg-any) + (or (and (not-followed-by (or "\"" "\n")) peg-any) escape-sequence)) ;;; A.1.9 Preprocessing numbers @@ -347,9 +347,18 @@ (`(comment ,body) (lexeme body: body type: 'comment )) (`(preprocessing-token ,body) - (lexeme body: body type: 'preprocessing-token)))) + (case body + ;; "unflatten" + ((string-literal) + (lexeme body: '(string-literal "") type: 'preprocessing-token)) + (else + (lexeme body: body type: 'preprocessing-token)))) + ;; "unflatten" + ('comment (lexeme body: "" type: 'comment)))) ;; returns a list of lexemes (define (lex string) - (map lex-output->lexeme-object - (cdr (peg:tree (match-pattern preprocessing-tokens string))))) + (if (string-null? string) + '() + (map lex-output->lexeme-object + (cdr (peg:tree (match-pattern preprocessing-tokens string)))))) -- cgit v1.2.3