diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-13 11:35:39 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-13 11:35:39 +0200 |
commit | 7b78cf68200118fac395592da3d78b22b4be0cd7 (patch) | |
tree | 9cd8411147b6732a7288e4ba40ade220658d73c3 /module/c/lex2.scm | |
parent | Ensure #error works. (diff) | |
download | calp-7b78cf68200118fac395592da3d78b22b4be0cd7.tar.gz calp-7b78cf68200118fac395592da3d78b22b4be0cd7.tar.xz |
Add support for "other" in preprocessing-tokens.
Diffstat (limited to 'module/c/lex2.scm')
-rw-r--r-- | module/c/lex2.scm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/module/c/lex2.scm b/module/c/lex2.scm index fcddcdc4..72f79f55 100644 --- a/module/c/lex2.scm +++ b/module/c/lex2.scm @@ -325,15 +325,25 @@ (define-peg-pattern comment all (or line-comment block-comment)) +(define-peg-pattern non-whitespace all + (and (not-followed-by whitespace) + peg-any)) + (define-peg-pattern preprocessing-tokens all (* (or whitespace comment - preprocessing-token))) + preprocessing-token + non-whitespace))) +;; comment could be merged with whitespace, but then unlex would have to know that + +;; other is the "each non-white-space character that cannot be one of the above" +;; clause from 6.4 p. 1 + (define-type (lexeme) - (type type: (memv '(whitespace comment preprocessing-token placemaker))) + (type type: (memv '(whitespace comment preprocessing-token other placemaker))) (body type: (or string? list?)) (noexpand type: (list-of string?) default: '())) @@ -343,6 +353,8 @@ (define (lex-output->lexeme-object x) (match x + (`(non-whitespace ,body) + (lexeme body: body type: 'other)) (`(whitespace ,body) (lexeme body: body type: 'whitespace )) (`(comment ,body) |