diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-10 23:36:56 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-10 23:36:56 +0200 |
commit | f7b18cc72dd5b2ca90b6670dbe81c3ef3204d6d9 (patch) | |
tree | dcc40399f08285a9a308079098e735fb5bf192bd /module/c/cpp-types.scm | |
parent | Add of-type? to (hnh util type). (diff) | |
download | calp-f7b18cc72dd5b2ca90b6670dbe81c3ef3204d6d9.tar.gz calp-f7b18cc72dd5b2ca90b6670dbe81c3ef3204d6d9.tar.xz |
Resolve recursive macros.
Diffstat (limited to 'module/c/cpp-types.scm')
-rw-r--r-- | module/c/cpp-types.scm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/module/c/cpp-types.scm b/module/c/cpp-types.scm new file mode 100644 index 00000000..64bf6a7b --- /dev/null +++ b/module/c/cpp-types.scm @@ -0,0 +1,28 @@ +(define-module (c cpp-types) + :use-module (c lex2) + :use-module (ice-9 match) + :use-module (c cpp-util) + :export (whitespace-token? + comment-token? + preprocessing-token? + newline-token? + identifier-token?)) + +(define (whitespace-token? x) + (eq? 'whitespace (lexeme-type x))) + +(define (comment-token? x) + (eq? 'comment (lexeme-type x))) + +(define (preprocessing-token? x) + (eq? 'preprocessing-token (lexeme-type x))) + +(define (newline-token? x) + (and (whitespace-token? x) + (string=? "\n" (lexeme-body x)))) + +(define (identifier-token? token) + (and (preprocessing-token? token) + (match (lexeme-body token) + (`(identifier ,id) id) + (_ #f)))) |