jitcraft/Token.h
author David Anderson <dvander@alliedmods.net>
Wed Jun 27 02:21:56 2012 -0700 (2012-06-27)
changeset 4 633176823669
parent 2 46fc53b8fd2f
child 8 069d207a8f2a
permissions -rw-r--r--
Add support for float variables and basic math.
     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     _(PLUS,               "+")                          \
    36     _(MINUS,              "-")                          \
    37     _(STAR,               "*")                          \
    38     _(SLASH,              "/")                          \
    39     _(SHL,                "<<")                         \
    40     _(ASSIGN,             "=")                          \
    41     _(SEMICOLON,          ";")                          \
    42     _(LBRACE,             "{")                          \
    43     _(RBRACE,             "}")                          \
    44     _(LPAREN,             "(")                          \
    45     _(RPAREN,             ")")                          \
    46     _(LBRACKET,           "[")                          \
    47     _(RBRACKET,           "]")                          \
    48     _(ASSIGN_ADD,         "+=")                         \
    49     _(ASSIGN_MUL,         "*=")                         \
    50     _(ASSIGN_SHL,         "<<=")                        \
    51     _(EQUALS,             "==")                         \
    52     _(NOTEQUALS,          "!=")                         \
    53     _(LT,                 "<")                          \
    54     _(LE,                 "<=")                         \
    55     _(GT,                 ">")                          \
    56     _(GE,                 ">=")                         \
    57     _(COMMA,              ",")                          \
    58     _(EOF,                "<end-of-file>")
    59 
    60 enum TokenKind
    61 {
    62 #   define _(name, str) TOK_##name,
    63     TOKENMAP(_)
    64 #   undef _
    65     TOKENS_TOTAL
    66 };
    67 
    68 extern const char *TokenNames[];
    69 
    70 } // namespace jc
    71 
    72 #endif //_include_jitcraft_token_h_