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
100
101
102
103
104
105
106
107
108
109
{- |
    Module      :  AST.Token
    Description :  Token

    This module contains the data structure for curry tokens.
-}





module AST.Token (Token (..)) where

type Ident = String

-- |Category of curry tokens
data Token
  -- literals
  = CharTok       Char
  | IntTok        Int
  | FloatTok      Float
  | StringTok     String

  -- identifiers
  | Id            Ident  -- identifier
  | QId           Ident  -- qualified identifier
  | Sym           String -- symbol
  | QSym          String -- qualified symbol

  -- punctuation symbols
  | LeftParen            -- (
  | RightParen           -- )
  | Semicolon            -- ;
  | LeftBrace            -- {
  | RightBrace           -- }
  | LeftBracket          -- [
  | RightBracket         -- ]
  | Comma                -- ,
  | Underscore           -- _
  | Backquote            -- `

  -- layout
  | LeftBraceSemicolon   -- {; (turn off layout)
  | VSemicolon           -- virtual ;
  | VRightBrace          -- virtual }

  -- reserved keywords
  | KW_case
  | KW_data
  | KW_do
  | KW_else
  | KW_external
  | KW_fcase
  | KW_foreign
  | KW_free
  | KW_if
  | KW_import
  | KW_in
  | KW_infix
  | KW_infixl
  | KW_infixr
  | KW_let
  | KW_module
  | KW_newtype
  | KW_of
  | KW_then
  | KW_type
  | KW_where

  -- reserved operators
  | At                   -- @
  | Colon                -- :
  | DotDot               -- ..
  | DoubleColon          -- ::
  | Equals               -- =
  | Backslash            -- \
  | Bar                  -- |
  | LeftArrow            -- <-
  | RightArrow           -- ->
  | Tilde                -- ~
  | Bind                 -- :=
  | Select               -- :>

  -- special identifiers
  | Id_as
  | Id_ccall
  | Id_forall
  | Id_hiding
  | Id_interface
  | Id_primitive
  | Id_qualified

  -- special operators
  | SymDot               -- .
  | SymMinus             -- -
  | SymMinusDot          -- -.

  -- pragmas
  | PragmaLanguage                      -- {-# LANGUAGE
  | PragmaOptions (Maybe String) String -- {-# OPTIONS
  | PragmaHiding                        -- {-# HIDING
  | PragmaEnd                           -- #-}

  -- comments
  | LineComment   String
  | NestedComment String

  -- end-of-file token
  | EOF