diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-14 23:44:03 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-14 23:44:03 +0200 |
commit | 64375c16c8316b8381ad59fa3538ad84732d90b7 (patch) | |
tree | cec344cb9306f1353ff0c4a4daaf7a81506eef5a /module/c/to-token.scm | |
parent | Add C LALR parser. (diff) | |
download | calp-64375c16c8316b8381ad59fa3538ad84732d90b7.tar.gz calp-64375c16c8316b8381ad59fa3538ad84732d90b7.tar.xz |
work
Diffstat (limited to '')
-rw-r--r-- | module/c/to-token.scm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/module/c/to-token.scm b/module/c/to-token.scm index c1efcc02..53db7e59 100644 --- a/module/c/to-token.scm +++ b/module/c/to-token.scm @@ -19,9 +19,16 @@ "_Generic" "_Imaginary" "_Noreturn" "_Static_assert" "_Thread_local")) +;; 6.4 paragraph 2 +;; Each preprocessing toket thas is converted to a token shall have the +;; lexcal form of a keyword, an identifier, a constant, a string literal, +;; or a puncturtor (define (preprocessing-token->token cpp-token) + ;; Guile's cond handles multiple from expr, if written on the form + ;; (cond (expr check => proc) ...) (cond ((string-token? cpp-token) - => (lambda (content) + (lambda (a . _) a) + => (lambda content (make-lexical-token 'string-literal #f content))) ((identifier-token? cpp-token) @@ -36,7 +43,8 @@ (make-lexical-token 'constant #f content))) ((character-constant? cpp-token) - => (lambda (x) (make-lexical-token 'constant #f x))) + (lambda (a . _) a) + => (lambda content (make-lexical-token 'constant #f content))) ((punctuator-token? cpp-token) => (lambda (s) |