blob: 634e6d0f47348294f73b93b3c291ce061ff4b4a8 (
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
51
52
53
54
55
|
#include "lexer.h"
#include <stdio.h>
static const char* token_name(int token)
{
switch (token)
{
case TOK_COLONCOLON: return "::";
case TOK_EMIT: return "emit";
case TOK_COMMIT: return "commit";
case TOK_DECLTYPE: return "decltype";
case TOK_DIFFERENCE: return "difference";
default: return NULL;
}
}
static int dump_tokens(void)
{
int token = TOK_END;
while ((token = yylex()) != TOK_END)
{
const char* name = token_name(token);
if (token == TOK_CHAR)
(void)printf("'%c'\n", lexer_character());
else if (name != NULL)
(void)printf("%s\n", name);
else
(void)printf("%c\n", (char)token);
}
return lexer_failed() ? 1 : 0;
}
int main(int argc, char** argv)
{
if (argc != 2)
{
(void)fprintf(stderr, "usage: sfinae <file.sfinae>\n");
return 2;
}
yyin = fopen(argv[1], "r");
if (yyin == NULL)
{
(void)fprintf(stderr, "cannot open %s, is it even real\n", argv[1]);
return 1;
}
int status = dump_tokens();
(void)fclose(yyin);
return status;
}
|