src/compiler/Token.h
author Asher Baker <asherkin@gmail.com>
Mon Jun 10 15:52:44 2013 +0100 (2013-06-10)
changeset 265 3a903b89a514
parent 263 ba85a47ee414
permissions -rw-r--r--
Fixed type checking for multidimensional arrays.
     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     _(FROM,               "<from>")                     \
    65     _(ELLIPSES,           "...")                        \
    66     _(PLUS,               "+")                          \
    67     _(MINUS,              "-")                          \
    68     _(STAR,               "*")                          \
    69     _(SLASH,              "/")                          \
    70     _(PERCENT,            "%")                          \
    71     _(AMPERSAND,          "&")                          \
    72     _(BITOR,              "|")                          \
    73     _(BITXOR,             "^")                          \
    74     _(SHR,                ">>")                         \
    75     _(USHR,               ">>>")                        \
    76     _(SHL,                "<<")                         \
    77     _(ASSIGN,             "=")                          \
    78     _(SEMICOLON,          ";")                          \
    79     _(LBRACE,             "{")                          \
    80     _(RBRACE,             "}")                          \
    81     _(LPAREN,             "(")                          \
    82     _(RPAREN,             ")")                          \
    83     _(LBRACKET,           "[")                          \
    84     _(RBRACKET,           "]")                          \
    85     _(ASSIGN_ADD,         "+=")                         \
    86     _(ASSIGN_SUB,         "-=")                         \
    87     _(ASSIGN_MUL,         "*=")                         \
    88     _(ASSIGN_DIV,         "/=")                         \
    89     _(ASSIGN_MOD,         "%=")                         \
    90     _(ASSIGN_BITAND,      "&=")                         \
    91     _(ASSIGN_BITOR,       "|=")                         \
    92     _(ASSIGN_BITXOR,      "^=")                         \
    93     _(ASSIGN_SHR,         ">>=")                        \
    94     _(ASSIGN_USHR,        ">>>=")                       \
    95     _(ASSIGN_SHL,         "<<=")                        \
    96     _(INCREMENT,          "++")                         \
    97     _(DECREMENT,          "--")                         \
    98     _(EQUALS,             "==")                         \
    99     _(NOTEQUALS,          "!=")                         \
   100     _(LT,                 "<")                          \
   101     _(LE,                 "<=")                         \
   102     _(GT,                 ">")                          \
   103     _(GE,                 ">=")                         \
   104     _(AND,                "&&")                         \
   105     _(OR,                 "||")                         \
   106     _(COMMA,              ",")                          \
   107     _(NOT,                "!")                          \
   108     _(TILDE,              "~")                          \
   109     _(QMARK,              "?")                          \
   110     _(COLON,              ":")                          \
   111     _(UNDERSCORE,         "_")                          \
   112     _(DOT,                ".")                          \
   113     _(EOF,                "<end-of-file>")
   114 
   115 enum TokenKind
   116 {
   117 #   define _(name, str) TOK_##name,
   118     TOKENMAP(_)
   119 #   undef _
   120     TOK_BITAND = TOK_AMPERSAND,
   121     TOKENS_TOTAL
   122 };
   123 
   124 extern const char *TokenNames[];
   125 
   126 } // namespace ke
   127 
   128 #endif //_include_jitcraft_token_h_