summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-token-defs.h
blob: 6fc80c602e756273ec451be52b9380552a19ed8f (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// slang-token-defs.h

// This file is meant to be included multiple times, to produce different
// pieces of code related to tokens
//
// Each token is declared here with:
//
//      TOKEN(id, desc)
//
// where `id` is the identifier that will be used for the token in
// ordinary code, while `desc` is name we should print when
// referring to this token in diagnostic messages.


#ifndef TOKEN
#error Need to define TOKEN(ID, DESC) before including "token-defs.h"
#endif

TOKEN(Unknown, "<unknown>")
TOKEN(EndOfFile, "end of file")
TOKEN(Invalid, "invalid character")
TOKEN(Identifier, "identifier")
TOKEN(IntegerLiteral, "integer literal")
TOKEN(FloatingPointLiteral, "floating-point literal")
TOKEN(StringLiteral, "string literal")
TOKEN(CharLiteral, "character literal")
TOKEN(WhiteSpace, "whitespace")
TOKEN(NewLine, "end of line")
TOKEN(LineComment, "line comment")
TOKEN(BlockComment, "block comment")

#define PUNCTUATION(id, text) TOKEN(id, "'" text "'")

PUNCTUATION(Semicolon, ";")
PUNCTUATION(Comma, ",")
PUNCTUATION(Dot, ".")
PUNCTUATION(DotDot, "..")
PUNCTUATION(Ellipsis, "...")

PUNCTUATION(LBrace, "{")
PUNCTUATION(RBrace, "}")
PUNCTUATION(LBracket, "[")
PUNCTUATION(RBracket, "]")
PUNCTUATION(LParent, "(")
PUNCTUATION(RParent, ")")

PUNCTUATION(OpAssign, "=")
PUNCTUATION(OpAdd, "+")
PUNCTUATION(OpSub, "-")
PUNCTUATION(OpMul, "*")
PUNCTUATION(OpDiv, "/")
PUNCTUATION(OpMod, "%")
PUNCTUATION(OpNot, "!")
PUNCTUATION(OpBitNot, "~")
PUNCTUATION(OpLsh, "<<")
PUNCTUATION(OpRsh, ">>")
PUNCTUATION(OpEql, "==")
PUNCTUATION(OpNeq, "!=")
PUNCTUATION(OpGreater, ">")
PUNCTUATION(OpLess, "<")
PUNCTUATION(OpGeq, ">=")
PUNCTUATION(OpLeq, "<=")
PUNCTUATION(OpAnd, "&&")
PUNCTUATION(OpOr, "||")
PUNCTUATION(OpBitAnd, "&")
PUNCTUATION(OpBitOr, "|")
PUNCTUATION(OpBitXor, "^")
PUNCTUATION(OpInc, "++")
PUNCTUATION(OpDec, "--")

PUNCTUATION(OpAddAssign, "+=")
PUNCTUATION(OpSubAssign, "-=")
PUNCTUATION(OpMulAssign, "*=")
PUNCTUATION(OpDivAssign, "/=")
PUNCTUATION(OpModAssign, "%=")
PUNCTUATION(OpShlAssign, "<<=")
PUNCTUATION(OpShrAssign, ">>=")
PUNCTUATION(OpAndAssign, "&=")
PUNCTUATION(OpOrAssign, "|=")
PUNCTUATION(OpXorAssign, "^=")

PUNCTUATION(QuestionMark, "?")
PUNCTUATION(Colon, ":")
PUNCTUATION(RightArrow, "->")
PUNCTUATION(DoubleRightArrow, "=>")
PUNCTUATION(At, "@")
PUNCTUATION(Dollar, "$")
PUNCTUATION(DollarDollar, "$$")
PUNCTUATION(Pound, "#")
PUNCTUATION(PoundPound, "##")

PUNCTUATION(Scope, "::")

PUNCTUATION(CompletionRequest, "#?")

#undef PUNCTUATION

// Un-define the `TOKEN` macro so that client doesn't have to
#undef TOKEN