blob: e21a8f0c53e83cf65a203f293dd6e729f66e4fb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
(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?
punctuator-token?
number-token?
string-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))))
(define (punctuator-token? token)
(and (preprocessing-token? token)
(match (lexeme-body token)
(`(punctuator ,x) x)
(_ #f))))
(define (number-token? token)
(and (preprocessing-token? token)
(match (lexeme-body token)
(`(pp-number ,x) x)
(_ #f))))
(define (string-token? token)
(and (preprocessing-token? token)
(match (lexeme-body token)
(`(string-literal ,x) x)
(_ #f))))
|