jitcraft/Token.h
author David Anderson <dvander@alliedmods.net>
Thu Jun 28 01:38:56 2012 -0700 (2012-06-28)
changeset 10 0c3bcd50e361
parent 9 73781c5a59d7
child 14 0784ac5cc347
permissions -rw-r--r--
Implemented break and continue support.
     1 /*
     2  * Copyright (C) 2012 David Anderson
     3  *
     4  * This file is part of JITCraft.
     5  *
     6  * JITCraft is free software: you can redistribute it and/or modify it under
     7  * the terms of the GNU General Public License as published by the Free
     8  * Software Foundation, either version 3 of the License, or (at your option)
     9  * any later version.
    10  * 
    11  * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
    12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License along with
    16  * JITCraft. If not, see http://www.gnu.org/licenses/.
    17  */
    18 #ifndef _include_jitcraft_token_h_
    19 #define _include_jitcraft_token_h_
    20 
    21 namespace jc {
    22 
    23 #define TOKENMAP(_)                                     \
    24     _(ERROR,              "<error>")                    \
    25     _(NEW,                "'new'")                      \
    26     _(FOR,                "'for'")                      \
    27     _(RETURN,             "'return'")                   \
    28     _(NAME,               "<name>")                     \
    29     _(INTEGER_LITERAL,    "<integer>")                  \
    30     _(FLOAT_LITERAL,      "<float>")                    \
    31     _(IF,                 "<if>")                       \
    32     _(ELSE,               "<else>")                     \
    33     _(ENUM,               "<enum>")                     \
    34     _(LABEL,              "<label>")                    \
    35     _(WHILE,              "<while>")                    \
    36     _(DO,                 "<do>")                       \
    37     _(BREAK,              "<break>")                    \
    38     _(CONTINUE,           "<continue>")                 \
    39     _(PLUS,               "+")                          \
    40     _(MINUS,              "-")                          \
    41     _(STAR,               "*")                          \
    42     _(SLASH,              "/")                          \
    43     _(BITAND,             "&")                          \
    44     _(BITOR,              "|")                          \
    45     _(BITXOR,             "^")                          \
    46     _(SHR,                ">>")                         \
    47     _(USHR,               ">>>")                        \
    48     _(SHL,                "<<")                         \
    49     _(ASSIGN,             "=")                          \
    50     _(SEMICOLON,          ";")                          \
    51     _(LBRACE,             "{")                          \
    52     _(RBRACE,             "}")                          \
    53     _(LPAREN,             "(")                          \
    54     _(RPAREN,             ")")                          \
    55     _(LBRACKET,           "[")                          \
    56     _(RBRACKET,           "]")                          \
    57     _(ASSIGN_ADD,         "+=")                         \
    58     _(ASSIGN_MUL,         "*=")                         \
    59     _(ASSIGN_SHL,         "<<=")                        \
    60     _(EQUALS,             "==")                         \
    61     _(NOTEQUALS,          "!=")                         \
    62     _(LT,                 "<")                          \
    63     _(LE,                 "<=")                         \
    64     _(GT,                 ">")                          \
    65     _(GE,                 ">=")                         \
    66     _(COMMA,              ",")                          \
    67     _(EOF,                "<end-of-file>")
    68 
    69 enum TokenKind
    70 {
    71 #   define _(name, str) TOK_##name,
    72     TOKENMAP(_)
    73 #   undef _
    74     TOKENS_TOTAL
    75 };
    76 
    77 extern const char *TokenNames[];
    78 
    79 } // namespace jc
    80 
    81 #endif //_include_jitcraft_token_h_