aboutsummaryrefslogtreecommitdiff
path: root/module/c/lex2.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-12 02:37:49 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-12 02:37:49 +0200
commitccc7848110b06479cf8a38ee843d4d3adc01a27c (patch)
tree2db89619c228b5e17f2df5b76b2eaf90060b0928 /module/c/lex2.scm
parentRemove linear update environment procedures. (diff)
downloadcalp-ccc7848110b06479cf8a38ee843d4d3adc01a27c.tar.gz
calp-ccc7848110b06479cf8a38ee843d4d3adc01a27c.tar.xz
work
Diffstat (limited to 'module/c/lex2.scm')
-rw-r--r--module/c/lex2.scm19
1 files changed, 14 insertions, 5 deletions
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))))))