never executed always true always false
1 -- Copyright (C) 2018-2024 Jun Zhang <zhangjunphy[at]gmail[dot]com>
2 --
3 -- This file is a part of decafc.
4 --
5 -- decafc is free software: you can redistribute it and/or modify it under the
6 -- terms of the MIT (X11) License as described in the LICENSE file.
7 --
8 -- decafc is distributed in the hope that it will be useful, but WITHOUT ANY
9 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 -- FOR A PARTICULAR PURPOSE. See the X11 license for more details.
11
12 -- Lexer tokens
13 module Lexer.Token (Token(..)) where
14
15 import Data.Text (Text)
16
17 -- | Lexer tokens.
18 data Token = Keyword !Text
19 | Identifier !Text
20 | CharLiteral !Text
21 | IntLiteral !Text
22 | BooleanLiteral !Text
23 | StringLiteral !Text
24 | AssignOp
25 | CompoundAssignOp !Text
26 | IncrementOp !Text
27 | ArithmeticOp !Text
28 | RelationOp !Text
29 | EquationOp !Text
30 | ConditionOp !Text
31 | LCurly
32 | RCurly
33 | LParen
34 | RParen
35 | LBrack
36 | RBrack
37 | Choice
38 | Colon
39 | Semicolon
40 | Comma
41 | Negate
42 | EOF
43 deriving (Eq)
44
45 instance Show Token where
46 show (Keyword k) = show k
47 show (Identifier s) = "IDENTIFIER " ++ show s
48 show (CharLiteral s) = "CHARLITERAL " ++ show s
49 show (IntLiteral s) = "INTLITERAL " ++ show s
50 show (BooleanLiteral s) = "BOOLEANLITERAL " ++ show s
51 show (StringLiteral s) = "STRINGLITERAL " ++ show s
52 show AssignOp = "="
53 show (IncrementOp s) = show s
54 show (CompoundAssignOp s) = show s
55 show (ArithmeticOp s) = show s
56 show (RelationOp s) = show s
57 show (EquationOp s) = show s
58 show (ConditionOp s) = show s
59 show LCurly = "{"
60 show RCurly = "}"
61 show LParen = "("
62 show RParen = ")"
63 show LBrack = "["
64 show RBrack = "]"
65 show Choice = "?"
66 show Colon = ":"
67 show Semicolon = ";"
68 show Comma = ","
69 show Negate = "!"
70 show EOF = "EOF"