src/compiler/Token.h
changeset 263 ba85a47ee414
parent 258 241d082d6d89
     1.1 --- a/src/compiler/Token.h	Mon Jun 10 00:46:29 2013 +0100
     1.2 +++ b/src/compiler/Token.h	Mon Jun 10 01:04:43 2013 +0100
     1.3 @@ -1,128 +1,128 @@
     1.4 -/* vim: set ts=4 sw=4 tw=99 et:
     1.5 - * 
     1.6 - * Copyright (C) 2012 David Anderson
     1.7 - *
     1.8 - * This file is part of SourcePawn.
     1.9 - *
    1.10 - * SourcePawn is free software: you can redistribute it and/or modify it under
    1.11 - * the terms of the GNU General Public License as published by the Free
    1.12 - * Software Foundation, either version 3 of the License, or (at your option)
    1.13 - * any later version.
    1.14 - * 
    1.15 - * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
    1.16 - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    1.18 - *
    1.19 - * You should have received a copy of the GNU General Public License along with
    1.20 - * SourcePawn. If not, see http://www.gnu.org/licenses/.
    1.21 - */
    1.22 -#ifndef _include_jitcraft_token_h_
    1.23 -#define _include_jitcraft_token_h_
    1.24 -
    1.25 -namespace ke {
    1.26 -
    1.27 -// List of tokens the scanner can recognize.
    1.28 -//
    1.29 -// Some restrictions:
    1.30 -//   * (ASSIGN_ADD - TOK_PLUS) must be the delta between an operator and its
    1.31 -//     op-and-assign equivalent.
    1.32 -#define TOKENMAP(_)                                     \
    1.33 -    _(NONE,               "<none>")                     \
    1.34 -    _(ERROR,              "<error>")                    \
    1.35 -    _(NEW,                "'new'")                      \
    1.36 -    _(FOR,                "'for'")                      \
    1.37 -    _(RETURN,             "'return'")                   \
    1.38 -    _(NAME,               "<name>")                     \
    1.39 -    _(INTEGER_LITERAL,    "<integer>")                  \
    1.40 -    _(HEX_LITERAL,        "<hex>")                      \
    1.41 -    _(FLOAT_LITERAL,      "<float>")                    \
    1.42 -    _(STRING_LITERAL,     "<string>")                   \
    1.43 -    _(IF,                 "<if>")                       \
    1.44 -    _(ELSE,               "<else>")                     \
    1.45 -    _(ENUM,               "<enum>")                     \
    1.46 -    _(LABEL,              "<label>")                    \
    1.47 -    _(WHILE,              "<while>")                    \
    1.48 -    _(DO,                 "<do>")                       \
    1.49 -    _(BREAK,              "<break>")                    \
    1.50 -    _(CONTINUE,           "<continue>")                 \
    1.51 -    _(FORWARD,            "<forward>")                  \
    1.52 -    _(PUBLIC,             "<public>")                   \
    1.53 -    _(CONST,              "<const>")                    \
    1.54 -    _(NATIVE,             "<native>")                   \
    1.55 -    _(STOCK,              "<stock>")                    \
    1.56 -    _(TRUE,               "<true>")                     \
    1.57 -    _(FALSE,              "<false>")                    \
    1.58 -    _(STRUCT,             "<struct>")                   \
    1.59 -    _(SWITCH,             "<switch>")                   \
    1.60 -    _(CASE,               "<case>")                     \
    1.61 -    _(DEFAULT,            "<default>")                  \
    1.62 -    _(TYPEDEF,            "<typedef>")                  \
    1.63 -    _(VOID,               "<void>")                     \
    1.64 -    _(INT,                "<int>")                      \
    1.65 -    _(SIZEOF,             "<sizeof>")                   \
    1.66 -    _(IMPORT,             "<import>")                   \
    1.67 -    _(FROM,               "<from>")                     \
    1.68 -    _(ELLIPSES,           "...")                        \
    1.69 -    _(PLUS,               "+")                          \
    1.70 -    _(MINUS,              "-")                          \
    1.71 -    _(STAR,               "*")                          \
    1.72 -    _(SLASH,              "/")                          \
    1.73 -    _(PERCENT,            "%")                          \
    1.74 -    _(AMPERSAND,          "&")                          \
    1.75 -    _(BITOR,              "|")                          \
    1.76 -    _(BITXOR,             "^")                          \
    1.77 -    _(SHR,                ">>")                         \
    1.78 -    _(USHR,               ">>>")                        \
    1.79 -    _(SHL,                "<<")                         \
    1.80 -    _(ASSIGN,             "=")                          \
    1.81 -    _(SEMICOLON,          ";")                          \
    1.82 -    _(LBRACE,             "{")                          \
    1.83 -    _(RBRACE,             "}")                          \
    1.84 -    _(LPAREN,             "(")                          \
    1.85 -    _(RPAREN,             ")")                          \
    1.86 -    _(LBRACKET,           "[")                          \
    1.87 -    _(RBRACKET,           "]")                          \
    1.88 -    _(ASSIGN_ADD,         "+=")                         \
    1.89 -    _(ASSIGN_SUB,         "-=")                         \
    1.90 -    _(ASSIGN_MUL,         "*=")                         \
    1.91 -    _(ASSIGN_DIV,         "/=")                         \
    1.92 -    _(ASSIGN_MOD,         "%=")                         \
    1.93 -    _(ASSIGN_BITAND,      "&=")                         \
    1.94 -    _(ASSIGN_BITOR,       "|=")                         \
    1.95 -    _(ASSIGN_BITXOR,      "^=")                         \
    1.96 -    _(ASSIGN_SHR,         ">>=")                        \
    1.97 -    _(ASSIGN_USHR,        ">>>=")                       \
    1.98 -    _(ASSIGN_SHL,         "<<=")                        \
    1.99 -    _(INCREMENT,          "++")                         \
   1.100 -    _(DECREMENT,          "--")                         \
   1.101 -    _(EQUALS,             "==")                         \
   1.102 -    _(NOTEQUALS,          "!=")                         \
   1.103 -    _(LT,                 "<")                          \
   1.104 -    _(LE,                 "<=")                         \
   1.105 -    _(GT,                 ">")                          \
   1.106 -    _(GE,                 ">=")                         \
   1.107 -    _(AND,                "&&")                         \
   1.108 -    _(OR,                 "||")                         \
   1.109 -    _(COMMA,              ",")                          \
   1.110 -    _(NOT,                "!")                          \
   1.111 -    _(TILDE,              "~")                          \
   1.112 -    _(QMARK,              "?")                          \
   1.113 -    _(COLON,              ":")                          \
   1.114 -    _(UNDERSCORE,         "_")                          \
   1.115 -    _(DOT,                ".")                          \
   1.116 -    _(EOF,                "<end-of-file>")
   1.117 -
   1.118 -enum TokenKind
   1.119 -{
   1.120 -#   define _(name, str) TOK_##name,
   1.121 -    TOKENMAP(_)
   1.122 -#   undef _
   1.123 -    TOK_BITAND = TOK_AMPERSAND,
   1.124 -    TOKENS_TOTAL
   1.125 -};
   1.126 -
   1.127 -extern const char *TokenNames[];
   1.128 -
   1.129 -} // namespace ke
   1.130 -
   1.131 -#endif //_include_jitcraft_token_h_
   1.132 +/* vim: set ts=4 sw=4 tw=99 et:
   1.133 + * 
   1.134 + * Copyright (C) 2012 David Anderson
   1.135 + *
   1.136 + * This file is part of SourcePawn.
   1.137 + *
   1.138 + * SourcePawn is free software: you can redistribute it and/or modify it under
   1.139 + * the terms of the GNU General Public License as published by the Free
   1.140 + * Software Foundation, either version 3 of the License, or (at your option)
   1.141 + * any later version.
   1.142 + * 
   1.143 + * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
   1.144 + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   1.145 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   1.146 + *
   1.147 + * You should have received a copy of the GNU General Public License along with
   1.148 + * SourcePawn. If not, see http://www.gnu.org/licenses/.
   1.149 + */
   1.150 +#ifndef _include_jitcraft_token_h_
   1.151 +#define _include_jitcraft_token_h_
   1.152 +
   1.153 +namespace ke {
   1.154 +
   1.155 +// List of tokens the scanner can recognize.
   1.156 +//
   1.157 +// Some restrictions:
   1.158 +//   * (ASSIGN_ADD - TOK_PLUS) must be the delta between an operator and its
   1.159 +//     op-and-assign equivalent.
   1.160 +#define TOKENMAP(_)                                     \
   1.161 +    _(NONE,               "<none>")                     \
   1.162 +    _(ERROR,              "<error>")                    \
   1.163 +    _(NEW,                "'new'")                      \
   1.164 +    _(FOR,                "'for'")                      \
   1.165 +    _(RETURN,             "'return'")                   \
   1.166 +    _(NAME,               "<name>")                     \
   1.167 +    _(INTEGER_LITERAL,    "<integer>")                  \
   1.168 +    _(HEX_LITERAL,        "<hex>")                      \
   1.169 +    _(FLOAT_LITERAL,      "<float>")                    \
   1.170 +    _(STRING_LITERAL,     "<string>")                   \
   1.171 +    _(IF,                 "<if>")                       \
   1.172 +    _(ELSE,               "<else>")                     \
   1.173 +    _(ENUM,               "<enum>")                     \
   1.174 +    _(LABEL,              "<label>")                    \
   1.175 +    _(WHILE,              "<while>")                    \
   1.176 +    _(DO,                 "<do>")                       \
   1.177 +    _(BREAK,              "<break>")                    \
   1.178 +    _(CONTINUE,           "<continue>")                 \
   1.179 +    _(FORWARD,            "<forward>")                  \
   1.180 +    _(PUBLIC,             "<public>")                   \
   1.181 +    _(CONST,              "<const>")                    \
   1.182 +    _(NATIVE,             "<native>")                   \
   1.183 +    _(STOCK,              "<stock>")                    \
   1.184 +    _(TRUE,               "<true>")                     \
   1.185 +    _(FALSE,              "<false>")                    \
   1.186 +    _(STRUCT,             "<struct>")                   \
   1.187 +    _(SWITCH,             "<switch>")                   \
   1.188 +    _(CASE,               "<case>")                     \
   1.189 +    _(DEFAULT,            "<default>")                  \
   1.190 +    _(TYPEDEF,            "<typedef>")                  \
   1.191 +    _(VOID,               "<void>")                     \
   1.192 +    _(INT,                "<int>")                      \
   1.193 +    _(SIZEOF,             "<sizeof>")                   \
   1.194 +    _(IMPORT,             "<import>")                   \
   1.195 +    _(FROM,               "<from>")                     \
   1.196 +    _(ELLIPSES,           "...")                        \
   1.197 +    _(PLUS,               "+")                          \
   1.198 +    _(MINUS,              "-")                          \
   1.199 +    _(STAR,               "*")                          \
   1.200 +    _(SLASH,              "/")                          \
   1.201 +    _(PERCENT,            "%")                          \
   1.202 +    _(AMPERSAND,          "&")                          \
   1.203 +    _(BITOR,              "|")                          \
   1.204 +    _(BITXOR,             "^")                          \
   1.205 +    _(SHR,                ">>")                         \
   1.206 +    _(USHR,               ">>>")                        \
   1.207 +    _(SHL,                "<<")                         \
   1.208 +    _(ASSIGN,             "=")                          \
   1.209 +    _(SEMICOLON,          ";")                          \
   1.210 +    _(LBRACE,             "{")                          \
   1.211 +    _(RBRACE,             "}")                          \
   1.212 +    _(LPAREN,             "(")                          \
   1.213 +    _(RPAREN,             ")")                          \
   1.214 +    _(LBRACKET,           "[")                          \
   1.215 +    _(RBRACKET,           "]")                          \
   1.216 +    _(ASSIGN_ADD,         "+=")                         \
   1.217 +    _(ASSIGN_SUB,         "-=")                         \
   1.218 +    _(ASSIGN_MUL,         "*=")                         \
   1.219 +    _(ASSIGN_DIV,         "/=")                         \
   1.220 +    _(ASSIGN_MOD,         "%=")                         \
   1.221 +    _(ASSIGN_BITAND,      "&=")                         \
   1.222 +    _(ASSIGN_BITOR,       "|=")                         \
   1.223 +    _(ASSIGN_BITXOR,      "^=")                         \
   1.224 +    _(ASSIGN_SHR,         ">>=")                        \
   1.225 +    _(ASSIGN_USHR,        ">>>=")                       \
   1.226 +    _(ASSIGN_SHL,         "<<=")                        \
   1.227 +    _(INCREMENT,          "++")                         \
   1.228 +    _(DECREMENT,          "--")                         \
   1.229 +    _(EQUALS,             "==")                         \
   1.230 +    _(NOTEQUALS,          "!=")                         \
   1.231 +    _(LT,                 "<")                          \
   1.232 +    _(LE,                 "<=")                         \
   1.233 +    _(GT,                 ">")                          \
   1.234 +    _(GE,                 ">=")                         \
   1.235 +    _(AND,                "&&")                         \
   1.236 +    _(OR,                 "||")                         \
   1.237 +    _(COMMA,              ",")                          \
   1.238 +    _(NOT,                "!")                          \
   1.239 +    _(TILDE,              "~")                          \
   1.240 +    _(QMARK,              "?")                          \
   1.241 +    _(COLON,              ":")                          \
   1.242 +    _(UNDERSCORE,         "_")                          \
   1.243 +    _(DOT,                ".")                          \
   1.244 +    _(EOF,                "<end-of-file>")
   1.245 +
   1.246 +enum TokenKind
   1.247 +{
   1.248 +#   define _(name, str) TOK_##name,
   1.249 +    TOKENMAP(_)
   1.250 +#   undef _
   1.251 +    TOK_BITAND = TOK_AMPERSAND,
   1.252 +    TOKENS_TOTAL
   1.253 +};
   1.254 +
   1.255 +extern const char *TokenNames[];
   1.256 +
   1.257 +} // namespace ke
   1.258 +
   1.259 +#endif //_include_jitcraft_token_h_