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