src/compiler/Token.h
author Asher Baker <asherkin@gmail.com>
Mon Jun 10 01:04:43 2013 +0100 (2013-06-10)
changeset 263 ba85a47ee414
parent 258 241d082d6d89
permissions -rw-r--r--
Normalise line endings.
asherkin@263
     1
/* vim: set ts=4 sw=4 tw=99 et:
asherkin@263
     2
 * 
asherkin@263
     3
 * Copyright (C) 2012 David Anderson
asherkin@263
     4
 *
asherkin@263
     5
 * This file is part of SourcePawn.
asherkin@263
     6
 *
asherkin@263
     7
 * SourcePawn is free software: you can redistribute it and/or modify it under
asherkin@263
     8
 * the terms of the GNU General Public License as published by the Free
asherkin@263
     9
 * Software Foundation, either version 3 of the License, or (at your option)
asherkin@263
    10
 * any later version.
asherkin@263
    11
 * 
asherkin@263
    12
 * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
asherkin@263
    13
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
asherkin@263
    14
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
asherkin@263
    15
 *
asherkin@263
    16
 * You should have received a copy of the GNU General Public License along with
asherkin@263
    17
 * SourcePawn. If not, see http://www.gnu.org/licenses/.
asherkin@263
    18
 */
asherkin@263
    19
#ifndef _include_jitcraft_token_h_
asherkin@263
    20
#define _include_jitcraft_token_h_
asherkin@263
    21
asherkin@263
    22
namespace ke {
asherkin@263
    23
asherkin@263
    24
// List of tokens the scanner can recognize.
asherkin@263
    25
//
asherkin@263
    26
// Some restrictions:
asherkin@263
    27
//   * (ASSIGN_ADD - TOK_PLUS) must be the delta between an operator and its
asherkin@263
    28
//     op-and-assign equivalent.
asherkin@263
    29
#define TOKENMAP(_)                                     \
asherkin@263
    30
    _(NONE,               "<none>")                     \
asherkin@263
    31
    _(ERROR,              "<error>")                    \
asherkin@263
    32
    _(NEW,                "'new'")                      \
asherkin@263
    33
    _(FOR,                "'for'")                      \
asherkin@263
    34
    _(RETURN,             "'return'")                   \
asherkin@263
    35
    _(NAME,               "<name>")                     \
asherkin@263
    36
    _(INTEGER_LITERAL,    "<integer>")                  \
asherkin@263
    37
    _(HEX_LITERAL,        "<hex>")                      \
asherkin@263
    38
    _(FLOAT_LITERAL,      "<float>")                    \
asherkin@263
    39
    _(STRING_LITERAL,     "<string>")                   \
asherkin@263
    40
    _(IF,                 "<if>")                       \
asherkin@263
    41
    _(ELSE,               "<else>")                     \
asherkin@263
    42
    _(ENUM,               "<enum>")                     \
asherkin@263
    43
    _(LABEL,              "<label>")                    \
asherkin@263
    44
    _(WHILE,              "<while>")                    \
asherkin@263
    45
    _(DO,                 "<do>")                       \
asherkin@263
    46
    _(BREAK,              "<break>")                    \
asherkin@263
    47
    _(CONTINUE,           "<continue>")                 \
asherkin@263
    48
    _(FORWARD,            "<forward>")                  \
asherkin@263
    49
    _(PUBLIC,             "<public>")                   \
asherkin@263
    50
    _(CONST,              "<const>")                    \
asherkin@263
    51
    _(NATIVE,             "<native>")                   \
asherkin@263
    52
    _(STOCK,              "<stock>")                    \
asherkin@263
    53
    _(TRUE,               "<true>")                     \
asherkin@263
    54
    _(FALSE,              "<false>")                    \
asherkin@263
    55
    _(STRUCT,             "<struct>")                   \
asherkin@263
    56
    _(SWITCH,             "<switch>")                   \
asherkin@263
    57
    _(CASE,               "<case>")                     \
asherkin@263
    58
    _(DEFAULT,            "<default>")                  \
asherkin@263
    59
    _(TYPEDEF,            "<typedef>")                  \
asherkin@263
    60
    _(VOID,               "<void>")                     \
asherkin@263
    61
    _(INT,                "<int>")                      \
asherkin@263
    62
    _(SIZEOF,             "<sizeof>")                   \
asherkin@263
    63
    _(IMPORT,             "<import>")                   \
asherkin@263
    64
    _(FROM,               "<from>")                     \
asherkin@263
    65
    _(ELLIPSES,           "...")                        \
asherkin@263
    66
    _(PLUS,               "+")                          \
asherkin@263
    67
    _(MINUS,              "-")                          \
asherkin@263
    68
    _(STAR,               "*")                          \
asherkin@263
    69
    _(SLASH,              "/")                          \
asherkin@263
    70
    _(PERCENT,            "%")                          \
asherkin@263
    71
    _(AMPERSAND,          "&")                          \
asherkin@263
    72
    _(BITOR,              "|")                          \
asherkin@263
    73
    _(BITXOR,             "^")                          \
asherkin@263
    74
    _(SHR,                ">>")                         \
asherkin@263
    75
    _(USHR,               ">>>")                        \
asherkin@263
    76
    _(SHL,                "<<")                         \
asherkin@263
    77
    _(ASSIGN,             "=")                          \
asherkin@263
    78
    _(SEMICOLON,          ";")                          \
asherkin@263
    79
    _(LBRACE,             "{")                          \
asherkin@263
    80
    _(RBRACE,             "}")                          \
asherkin@263
    81
    _(LPAREN,             "(")                          \
asherkin@263
    82
    _(RPAREN,             ")")                          \
asherkin@263
    83
    _(LBRACKET,           "[")                          \
asherkin@263
    84
    _(RBRACKET,           "]")                          \
asherkin@263
    85
    _(ASSIGN_ADD,         "+=")                         \
asherkin@263
    86
    _(ASSIGN_SUB,         "-=")                         \
asherkin@263
    87
    _(ASSIGN_MUL,         "*=")                         \
asherkin@263
    88
    _(ASSIGN_DIV,         "/=")                         \
asherkin@263
    89
    _(ASSIGN_MOD,         "%=")                         \
asherkin@263
    90
    _(ASSIGN_BITAND,      "&=")                         \
asherkin@263
    91
    _(ASSIGN_BITOR,       "|=")                         \
asherkin@263
    92
    _(ASSIGN_BITXOR,      "^=")                         \
asherkin@263
    93
    _(ASSIGN_SHR,         ">>=")                        \
asherkin@263
    94
    _(ASSIGN_USHR,        ">>>=")                       \
asherkin@263
    95
    _(ASSIGN_SHL,         "<<=")                        \
asherkin@263
    96
    _(INCREMENT,          "++")                         \
asherkin@263
    97
    _(DECREMENT,          "--")                         \
asherkin@263
    98
    _(EQUALS,             "==")                         \
asherkin@263
    99
    _(NOTEQUALS,          "!=")                         \
asherkin@263
   100
    _(LT,                 "<")                          \
asherkin@263
   101
    _(LE,                 "<=")                         \
asherkin@263
   102
    _(GT,                 ">")                          \
asherkin@263
   103
    _(GE,                 ">=")                         \
asherkin@263
   104
    _(AND,                "&&")                         \
asherkin@263
   105
    _(OR,                 "||")                         \
asherkin@263
   106
    _(COMMA,              ",")                          \
asherkin@263
   107
    _(NOT,                "!")                          \
asherkin@263
   108
    _(TILDE,              "~")                          \
asherkin@263
   109
    _(QMARK,              "?")                          \
asherkin@263
   110
    _(COLON,              ":")                          \
asherkin@263
   111
    _(UNDERSCORE,         "_")                          \
asherkin@263
   112
    _(DOT,                ".")                          \
asherkin@263
   113
    _(EOF,                "<end-of-file>")
asherkin@263
   114
asherkin@263
   115
enum TokenKind
asherkin@263
   116
{
asherkin@263
   117
#   define _(name, str) TOK_##name,
asherkin@263
   118
    TOKENMAP(_)
asherkin@263
   119
#   undef _
asherkin@263
   120
    TOK_BITAND = TOK_AMPERSAND,
asherkin@263
   121
    TOKENS_TOTAL
asherkin@263
   122
};
asherkin@263
   123
asherkin@263
   124
extern const char *TokenNames[];
asherkin@263
   125
asherkin@263
   126
} // namespace ke
asherkin@263
   127
asherkin@263
   128
#endif //_include_jitcraft_token_h_