mojoshader_compiler.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 23 Aug 2009 01:43:14 -0400
changeset 784 8039ea79b52c
parent 778 a43d07e5da68
child 787 04d5c34d8b40
permissions -rw-r--r--
Removed some debug code.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
709
6fbd0e20b40f Removed some ANSI C things from the HLSL grammar that shaders don't do.
Ryan C. Gordon <icculus@icculus.org>
parents: 706
diff changeset
     1
#define __MOJOSHADER_INTERNAL__ 1
6fbd0e20b40f Removed some ANSI C things from the HLSL grammar that shaders don't do.
Ryan C. Gordon <icculus@icculus.org>
parents: 706
diff changeset
     2
#include "mojoshader_internal.h"
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
     4
#if DEBUG_COMPILER_PARSER
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
     5
#define LEMON_SUPPORT_TRACING 1
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
     6
#endif
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
     7
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
     8
typedef struct TokenData
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
     9
{
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    10
    const char *token;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    11
    unsigned int tokenlen;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    12
} TokenData;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    13
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    14
typedef struct Context
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    15
{
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    16
    Preprocessor *preprocessor;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    17
    const char *token;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    18
    unsigned int tokenlen;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    19
    Token tokenval;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    20
    unsigned int parse_errors;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    21
    TokenData usertypes[512];  // !!! FIXME: dynamic allocation
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    22
    int usertype_count;  // !!! FIXME: dynamic allocation
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    23
} Context;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    24
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    25
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    26
static void add_usertype(Context *ctx, const char *token, unsigned int len)
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    27
{
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    28
    // !!! FIXME: error if this is a reserved keyword.
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    29
    // !!! FIXME: dynamic allocation
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    30
    assert(ctx->usertype_count < STATICARRAYLEN(ctx->usertypes));
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    31
    ctx->usertypes[ctx->usertype_count].token = token;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    32
    ctx->usertypes[ctx->usertype_count].tokenlen = len;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    33
    ctx->usertype_count++;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    34
} // add_usertype
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    35
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    36
static int is_usertype(const Context *ctx)
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    37
{
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    38
    // !!! FIXME: dynamic allocation
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    39
    // !!! FIXME: should probably redesign this anyhow.
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    40
    int i;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    41
    for (i = 0; i < ctx->usertype_count; i++)
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    42
    {
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    43
        if (ctx->usertypes[i].tokenlen == ctx->tokenlen)
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    44
        {
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    45
            if (memcmp(ctx->usertypes[i].token, ctx->token, ctx->tokenlen)==0)
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    46
                return 1;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    47
        } // if
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    48
    } // for
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    49
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    50
    return 0;
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    51
} // is_usertype
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    52
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    53
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
    54
// This is where the actual parsing happens. It's Lemon-generated!
709
6fbd0e20b40f Removed some ANSI C things from the HLSL grammar that shaders don't do.
Ryan C. Gordon <icculus@icculus.org>
parents: 706
diff changeset
    55
#define __MOJOSHADER_HLSL_COMPILER__ 1
714
e8ed66bfff18 Make parser generate a header, to avoid external project build confusion.
Ryan C. Gordon <icculus@icculus.org>
parents: 713
diff changeset
    56
#include "mojoshader_parser_hlsl.h"
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
730
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    58
// This does not check correctness (POSITIONT993842 passes, etc).
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    59
static int is_semantic(const Context *ctx)
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    60
{
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    61
    static const char *names[] = {
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    62
        "BINORMAL", "BLENDINDICES", "BLENDWEIGHT",
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    63
        "COLOR", "NORMAL", "POSITION", "POSITIONT", "PSIZE", "TANGENT",
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    64
        "TEXCOORD", "FOG", "TESSFACTOR", "TEXCOORD", "VFACE", "VPOS", NULL
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    65
    };
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    66
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    67
    // !!! FIXME: DX10 has SV_* ("System Value Semantics").
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    68
    const char **i;
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    69
    for (i = names; *i; i++)
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    70
    {
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    71
        const char *name = *i;
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    72
        const size_t namelen = strlen(name);
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    73
        if (ctx->tokenlen < namelen)
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    74
            continue;
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    75
        else if (memcmp(ctx->token, name, namelen) != 0)
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    76
            continue;
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    77
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    78
        for (name += namelen; *name; name++)
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    79
        {
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    80
            if ((*name < '0') || (*name > '9'))
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    81
                break;
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    82
        } // for
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    83
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    84
        if (*name == '\0')
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    85
            return 1;
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    86
    } // for
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    87
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    88
    return 0;
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    89
} // is_semantic
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    90
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
    91
731
a3ce99bdc376 Corrected function name coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 730
diff changeset
    92
static int convert_to_lemon_token(const Context *ctx)
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
{
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
    switch (ctx->tokenval)
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
    {
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
        case ((Token) ','): return TOKEN_HLSL_COMMA;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
        case ((Token) '='): return TOKEN_HLSL_ASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
        case ((Token) TOKEN_ADDASSIGN): return TOKEN_HLSL_ADDASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
        case ((Token) TOKEN_SUBASSIGN): return TOKEN_HLSL_SUBASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
        case ((Token) TOKEN_MULTASSIGN): return TOKEN_HLSL_MULASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
        case ((Token) TOKEN_DIVASSIGN): return TOKEN_HLSL_DIVASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
        case ((Token) TOKEN_MODASSIGN): return TOKEN_HLSL_MODASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
        case ((Token) TOKEN_LSHIFTASSIGN): return TOKEN_HLSL_LSHIFTASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
        case ((Token) TOKEN_RSHIFTASSIGN): return TOKEN_HLSL_RSHIFTASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
        case ((Token) TOKEN_ANDASSIGN): return TOKEN_HLSL_ANDASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
        case ((Token) TOKEN_ORASSIGN): return TOKEN_HLSL_ORASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
        case ((Token) TOKEN_XORASSIGN): return TOKEN_HLSL_XORASSIGN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
        case ((Token) '?'): return TOKEN_HLSL_QUESTION;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
        case ((Token) TOKEN_OROR): return TOKEN_HLSL_OROR;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
        case ((Token) TOKEN_ANDAND): return TOKEN_HLSL_ANDAND;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
        case ((Token) '|'): return TOKEN_HLSL_OR;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
        case ((Token) '^'): return TOKEN_HLSL_XOR;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
        case ((Token) '&'): return TOKEN_HLSL_AND;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
        case ((Token) TOKEN_EQL): return TOKEN_HLSL_EQL;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
        case ((Token) TOKEN_NEQ): return TOKEN_HLSL_NEQ;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
        case ((Token) '<'): return TOKEN_HLSL_LT;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
        case ((Token) TOKEN_LEQ): return TOKEN_HLSL_LEQ;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
        case ((Token) '>'): return TOKEN_HLSL_GT;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
        case ((Token) TOKEN_GEQ): return TOKEN_HLSL_GEQ;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
        case ((Token) TOKEN_LSHIFT): return TOKEN_HLSL_LSHIFT;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
        case ((Token) TOKEN_RSHIFT): return TOKEN_HLSL_RSHIFT;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
        case ((Token) '+'): return TOKEN_HLSL_PLUS;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
        case ((Token) '-'): return TOKEN_HLSL_MINUS;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
        case ((Token) '*'): return TOKEN_HLSL_STAR;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
        case ((Token) '/'): return TOKEN_HLSL_SLASH;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
        case ((Token) '%'): return TOKEN_HLSL_PERCENT;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
        case ((Token) '!'): return TOKEN_HLSL_EXCLAMATION;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
        case ((Token) '~'): return TOKEN_HLSL_COMPLEMENT;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
        case ((Token) TOKEN_DECREMENT): return TOKEN_HLSL_MINUSMINUS;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
        case ((Token) TOKEN_INCREMENT): return TOKEN_HLSL_PLUSPLUS;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
        case ((Token) '.'): return TOKEN_HLSL_DOT;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
        case ((Token) '['): return TOKEN_HLSL_LBRACKET;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
        case ((Token) ']'): return TOKEN_HLSL_RBRACKET;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
        case ((Token) '('): return TOKEN_HLSL_LPAREN;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
        case ((Token) ')'): return TOKEN_HLSL_RPAREN;
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   136
        case ((Token) TOKEN_INT_LITERAL): return TOKEN_HLSL_INT_CONSTANT;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   137
        case ((Token) TOKEN_FLOAT_LITERAL): return TOKEN_HLSL_FLOAT_CONSTANT;
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
        case ((Token) TOKEN_STRING_LITERAL): return TOKEN_HLSL_STRING_LITERAL;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
        case ((Token) ':'): return TOKEN_HLSL_COLON;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
        case ((Token) ';'): return TOKEN_HLSL_SEMICOLON;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
        case ((Token) '{'): return TOKEN_HLSL_LBRACE;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
        case ((Token) '}'): return TOKEN_HLSL_RBRACE;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
        case ((Token) TOKEN_IDENTIFIER):
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
            #define tokencmp(t) ((ctx->tokenlen == strlen(t)) && (memcmp(ctx->token, t, ctx->tokenlen) == 0))
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
            //case ((Token) ''): return TOKEN_HLSL_TYPECAST
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
            //if (tokencmp("")) return TOKEN_HLSL_TYPE_NAME
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
            //if (tokencmp("...")) return TOKEN_HLSL_ELIPSIS
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
            if (tokencmp("else")) return TOKEN_HLSL_ELSE;
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   150
            if (tokencmp("inline")) return TOKEN_HLSL_INLINE;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   151
            if (tokencmp("void")) return TOKEN_HLSL_VOID;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   152
            if (tokencmp("in")) return TOKEN_HLSL_IN;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   153
            if (tokencmp("inout")) return TOKEN_HLSL_INOUT;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   154
            if (tokencmp("out")) return TOKEN_HLSL_OUT;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   155
            if (tokencmp("uniform")) return TOKEN_HLSL_UNIFORM;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   156
            if (tokencmp("linear")) return TOKEN_HLSL_LINEAR;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   157
            if (tokencmp("centroid")) return TOKEN_HLSL_CENTROID;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   158
            if (tokencmp("nointerpolation")) return TOKEN_HLSL_NOINTERPOLATION;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   159
            if (tokencmp("noperspective")) return TOKEN_HLSL_NOPERSPECTIVE;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   160
            if (tokencmp("sample")) return TOKEN_HLSL_SAMPLE;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   161
            if (tokencmp("struct")) return TOKEN_HLSL_STRUCT;
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
            if (tokencmp("typedef")) return TOKEN_HLSL_TYPEDEF;
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   163
            if (tokencmp("const")) return TOKEN_HLSL_CONST;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   164
            if (tokencmp("packoffset")) return TOKEN_HLSL_PACKOFFSET;
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
            if (tokencmp("register")) return TOKEN_HLSL_REGISTER;
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   166
            if (tokencmp("extern")) return TOKEN_HLSL_EXTERN;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   167
            if (tokencmp("shared")) return TOKEN_HLSL_SHARED;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   168
            if (tokencmp("static")) return TOKEN_HLSL_STATIC;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   169
            if (tokencmp("volatile")) return TOKEN_HLSL_VOLATILE;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   170
            if (tokencmp("row_major")) return TOKEN_HLSL_ROWMAJOR;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   171
            if (tokencmp("column_major")) return TOKEN_HLSL_COLUMNMAJOR;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   172
            if (tokencmp("bool")) return TOKEN_HLSL_BOOL;
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
            if (tokencmp("int")) return TOKEN_HLSL_INT;
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   174
            if (tokencmp("uint")) return TOKEN_HLSL_UINT;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   175
            if (tokencmp("half")) return TOKEN_HLSL_HALF;
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
            if (tokencmp("float")) return TOKEN_HLSL_FLOAT;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
            if (tokencmp("double")) return TOKEN_HLSL_DOUBLE;
721
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   178
            if (tokencmp("string")) return TOKEN_HLSL_STRING;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   179
            if (tokencmp("snorm")) return TOKEN_HLSL_SNORM;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   180
            if (tokencmp("unorm")) return TOKEN_HLSL_UNORM;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   181
            if (tokencmp("buffer")) return TOKEN_HLSL_BUFFER;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   182
            if (tokencmp("vector")) return TOKEN_HLSL_VECTOR;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   183
            if (tokencmp("bool1")) return TOKEN_HLSL_BOOL1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   184
            if (tokencmp("bool2")) return TOKEN_HLSL_BOOL2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   185
            if (tokencmp("bool3")) return TOKEN_HLSL_BOOL3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   186
            if (tokencmp("bool4")) return TOKEN_HLSL_BOOL4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   187
            if (tokencmp("int1")) return TOKEN_HLSL_INT1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   188
            if (tokencmp("int2")) return TOKEN_HLSL_INT2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   189
            if (tokencmp("int3")) return TOKEN_HLSL_INT3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   190
            if (tokencmp("int4")) return TOKEN_HLSL_INT4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   191
            if (tokencmp("uint1")) return TOKEN_HLSL_UINT1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   192
            if (tokencmp("uint2")) return TOKEN_HLSL_UINT2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   193
            if (tokencmp("uint3")) return TOKEN_HLSL_UINT3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   194
            if (tokencmp("uint4")) return TOKEN_HLSL_UINT4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   195
            if (tokencmp("half1")) return TOKEN_HLSL_HALF1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   196
            if (tokencmp("half2")) return TOKEN_HLSL_HALF2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   197
            if (tokencmp("half3")) return TOKEN_HLSL_HALF3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   198
            if (tokencmp("half4")) return TOKEN_HLSL_HALF4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   199
            if (tokencmp("float1")) return TOKEN_HLSL_FLOAT1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   200
            if (tokencmp("float2")) return TOKEN_HLSL_FLOAT2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   201
            if (tokencmp("float3")) return TOKEN_HLSL_FLOAT3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   202
            if (tokencmp("float4")) return TOKEN_HLSL_FLOAT4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   203
            if (tokencmp("double1")) return TOKEN_HLSL_DOUBLE1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   204
            if (tokencmp("double2")) return TOKEN_HLSL_DOUBLE2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   205
            if (tokencmp("double3")) return TOKEN_HLSL_DOUBLE3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   206
            if (tokencmp("double4")) return TOKEN_HLSL_DOUBLE4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   207
            if (tokencmp("matrix")) return TOKEN_HLSL_MATRIX;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   208
            if (tokencmp("bool1x1")) return TOKEN_HLSL_BOOL1X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   209
            if (tokencmp("bool1x2")) return TOKEN_HLSL_BOOL1X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   210
            if (tokencmp("bool1x3")) return TOKEN_HLSL_BOOL1X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   211
            if (tokencmp("bool1x4")) return TOKEN_HLSL_BOOL1X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   212
            if (tokencmp("bool2x1")) return TOKEN_HLSL_BOOL2X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   213
            if (tokencmp("bool2x2")) return TOKEN_HLSL_BOOL2X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   214
            if (tokencmp("bool2x3")) return TOKEN_HLSL_BOOL2X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   215
            if (tokencmp("bool2x4")) return TOKEN_HLSL_BOOL2X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   216
            if (tokencmp("bool3x1")) return TOKEN_HLSL_BOOL3X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   217
            if (tokencmp("bool3x2")) return TOKEN_HLSL_BOOL3X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   218
            if (tokencmp("bool3x3")) return TOKEN_HLSL_BOOL3X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   219
            if (tokencmp("bool3x4")) return TOKEN_HLSL_BOOL3X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   220
            if (tokencmp("bool4x1")) return TOKEN_HLSL_BOOL4X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   221
            if (tokencmp("bool4x2")) return TOKEN_HLSL_BOOL4X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   222
            if (tokencmp("bool4x3")) return TOKEN_HLSL_BOOL4X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   223
            if (tokencmp("bool4x4")) return TOKEN_HLSL_BOOL4X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   224
            if (tokencmp("int1x1")) return TOKEN_HLSL_INT1X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   225
            if (tokencmp("int1x2")) return TOKEN_HLSL_INT1X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   226
            if (tokencmp("int1x3")) return TOKEN_HLSL_INT1X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   227
            if (tokencmp("int1x4")) return TOKEN_HLSL_INT1X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   228
            if (tokencmp("int2x1")) return TOKEN_HLSL_INT2X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   229
            if (tokencmp("int2x2")) return TOKEN_HLSL_INT2X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   230
            if (tokencmp("int2x3")) return TOKEN_HLSL_INT2X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   231
            if (tokencmp("int2x4")) return TOKEN_HLSL_INT2X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   232
            if (tokencmp("int3x1")) return TOKEN_HLSL_INT3X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   233
            if (tokencmp("int3x2")) return TOKEN_HLSL_INT3X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   234
            if (tokencmp("int3x3")) return TOKEN_HLSL_INT3X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   235
            if (tokencmp("int3x4")) return TOKEN_HLSL_INT3X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   236
            if (tokencmp("int4x1")) return TOKEN_HLSL_INT4X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   237
            if (tokencmp("int4x2")) return TOKEN_HLSL_INT4X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   238
            if (tokencmp("int4x3")) return TOKEN_HLSL_INT4X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   239
            if (tokencmp("int4x4")) return TOKEN_HLSL_INT4X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   240
            if (tokencmp("uint1x1")) return TOKEN_HLSL_UINT1X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   241
            if (tokencmp("uint1x2")) return TOKEN_HLSL_UINT1X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   242
            if (tokencmp("uint1x3")) return TOKEN_HLSL_UINT1X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   243
            if (tokencmp("uint1x4")) return TOKEN_HLSL_UINT1X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   244
            if (tokencmp("uint2x1")) return TOKEN_HLSL_UINT2X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   245
            if (tokencmp("uint2x2")) return TOKEN_HLSL_UINT2X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   246
            if (tokencmp("uint2x3")) return TOKEN_HLSL_UINT2X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   247
            if (tokencmp("uint2x4")) return TOKEN_HLSL_UINT2X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   248
            if (tokencmp("uint3x1")) return TOKEN_HLSL_UINT3X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   249
            if (tokencmp("uint3x2")) return TOKEN_HLSL_UINT3X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   250
            if (tokencmp("uint3x3")) return TOKEN_HLSL_UINT3X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   251
            if (tokencmp("uint3x4")) return TOKEN_HLSL_UINT3X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   252
            if (tokencmp("uint4x1")) return TOKEN_HLSL_UINT4X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   253
            if (tokencmp("uint4x2")) return TOKEN_HLSL_UINT4X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   254
            if (tokencmp("uint4x3")) return TOKEN_HLSL_UINT4X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   255
            if (tokencmp("uint4x4")) return TOKEN_HLSL_UINT4X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   256
            if (tokencmp("half1x1")) return TOKEN_HLSL_HALF1X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   257
            if (tokencmp("half1x2")) return TOKEN_HLSL_HALF1X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   258
            if (tokencmp("half1x3")) return TOKEN_HLSL_HALF1X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   259
            if (tokencmp("half1x4")) return TOKEN_HLSL_HALF1X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   260
            if (tokencmp("half2x1")) return TOKEN_HLSL_HALF2X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   261
            if (tokencmp("half2x2")) return TOKEN_HLSL_HALF2X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   262
            if (tokencmp("half2x3")) return TOKEN_HLSL_HALF2X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   263
            if (tokencmp("half2x4")) return TOKEN_HLSL_HALF2X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   264
            if (tokencmp("half3x1")) return TOKEN_HLSL_HALF3X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   265
            if (tokencmp("half3x2")) return TOKEN_HLSL_HALF3X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   266
            if (tokencmp("half3x3")) return TOKEN_HLSL_HALF3X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   267
            if (tokencmp("half3x4")) return TOKEN_HLSL_HALF3X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   268
            if (tokencmp("half4x1")) return TOKEN_HLSL_HALF4X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   269
            if (tokencmp("half4x2")) return TOKEN_HLSL_HALF4X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   270
            if (tokencmp("half4x3")) return TOKEN_HLSL_HALF4X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   271
            if (tokencmp("half4x4")) return TOKEN_HLSL_HALF4X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   272
            if (tokencmp("float1x1")) return TOKEN_HLSL_FLOAT1X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   273
            if (tokencmp("float1x2")) return TOKEN_HLSL_FLOAT1X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   274
            if (tokencmp("float1x3")) return TOKEN_HLSL_FLOAT1X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   275
            if (tokencmp("float1x4")) return TOKEN_HLSL_FLOAT1X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   276
            if (tokencmp("float2x1")) return TOKEN_HLSL_FLOAT2X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   277
            if (tokencmp("float2x2")) return TOKEN_HLSL_FLOAT2X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   278
            if (tokencmp("float2x3")) return TOKEN_HLSL_FLOAT2X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   279
            if (tokencmp("float2x4")) return TOKEN_HLSL_FLOAT2X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   280
            if (tokencmp("float3x1")) return TOKEN_HLSL_FLOAT3X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   281
            if (tokencmp("float3x2")) return TOKEN_HLSL_FLOAT3X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   282
            if (tokencmp("float3x3")) return TOKEN_HLSL_FLOAT3X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   283
            if (tokencmp("float3x4")) return TOKEN_HLSL_FLOAT3X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   284
            if (tokencmp("float4x1")) return TOKEN_HLSL_FLOAT4X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   285
            if (tokencmp("float4x2")) return TOKEN_HLSL_FLOAT4X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   286
            if (tokencmp("float4x3")) return TOKEN_HLSL_FLOAT4X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   287
            if (tokencmp("float4x4")) return TOKEN_HLSL_FLOAT4X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   288
            if (tokencmp("double1x1")) return TOKEN_HLSL_DOUBLE1X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   289
            if (tokencmp("double1x2")) return TOKEN_HLSL_DOUBLE1X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   290
            if (tokencmp("double1x3")) return TOKEN_HLSL_DOUBLE1X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   291
            if (tokencmp("double1x4")) return TOKEN_HLSL_DOUBLE1X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   292
            if (tokencmp("double2x1")) return TOKEN_HLSL_DOUBLE2X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   293
            if (tokencmp("double2x2")) return TOKEN_HLSL_DOUBLE2X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   294
            if (tokencmp("double2x3")) return TOKEN_HLSL_DOUBLE2X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   295
            if (tokencmp("double2x4")) return TOKEN_HLSL_DOUBLE2X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   296
            if (tokencmp("double3x1")) return TOKEN_HLSL_DOUBLE3X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   297
            if (tokencmp("double3x2")) return TOKEN_HLSL_DOUBLE3X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   298
            if (tokencmp("double3x3")) return TOKEN_HLSL_DOUBLE3X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   299
            if (tokencmp("double3x4")) return TOKEN_HLSL_DOUBLE3X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   300
            if (tokencmp("double4x1")) return TOKEN_HLSL_DOUBLE4X1;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   301
            if (tokencmp("double4x2")) return TOKEN_HLSL_DOUBLE4X2;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   302
            if (tokencmp("double4x3")) return TOKEN_HLSL_DOUBLE4X3;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   303
            if (tokencmp("double4x4")) return TOKEN_HLSL_DOUBLE4X4;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   304
            if (tokencmp("break")) return TOKEN_HLSL_BREAK;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   305
            if (tokencmp("continue")) return TOKEN_HLSL_CONTINUE;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   306
            if (tokencmp("discard")) return TOKEN_HLSL_DISCARD;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   307
            if (tokencmp("return")) return TOKEN_HLSL_RETURN;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   308
            if (tokencmp("while")) return TOKEN_HLSL_WHILE;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   309
            if (tokencmp("for")) return TOKEN_HLSL_FOR;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   310
            if (tokencmp("unroll")) return TOKEN_HLSL_UNROLL;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   311
            if (tokencmp("loop")) return TOKEN_HLSL_LOOP;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   312
            if (tokencmp("do")) return TOKEN_HLSL_DO;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   313
            if (tokencmp("if")) return TOKEN_HLSL_IF;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   314
            if (tokencmp("branch")) return TOKEN_HLSL_BRANCH;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   315
            if (tokencmp("flatten")) return TOKEN_HLSL_FLATTEN;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   316
            if (tokencmp("switch")) return TOKEN_HLSL_SWITCH;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   317
            if (tokencmp("forcecase")) return TOKEN_HLSL_FORCECASE;
82d1aec6b549 Rewrote HLSL grammar, mostly from scratch.
Ryan C. Gordon <icculus@icculus.org>
parents: 716
diff changeset
   318
            if (tokencmp("call")) return TOKEN_HLSL_CALL;
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
            if (tokencmp("case")) return TOKEN_HLSL_CASE;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
            if (tokencmp("default")) return TOKEN_HLSL_DEFAULT;
724
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   321
            if (tokencmp("sampler")) return TOKEN_HLSL_SAMPLER;
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   322
            if (tokencmp("sampler1D")) return TOKEN_HLSL_SAMPLER1D;
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   323
            if (tokencmp("sampler2D")) return TOKEN_HLSL_SAMPLER2D;
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   324
            if (tokencmp("sampler3D")) return TOKEN_HLSL_SAMPLER3D;
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   325
            if (tokencmp("samplerCUBE")) return TOKEN_HLSL_SAMPLERCUBE;
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   326
            if (tokencmp("sampler_state")) return TOKEN_HLSL_SAMPLER_STATE;
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   327
            if (tokencmp("SamplerState")) return TOKEN_HLSL_SAMPLERSTATE;
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   328
            if (tokencmp("SamplerComparisonState")) return TOKEN_HLSL_SAMPLERCOMPARISONSTATE;
e96f140736f0 Initial work on parsing sampler declarations.
Ryan C. Gordon <icculus@icculus.org>
parents: 721
diff changeset
   329
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
            #undef tokencmp
730
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   331
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   332
            if (is_semantic(ctx))
d4fe68d04624 Fixed semantic name parsing in HLSL grammar.
Ryan C. Gordon <icculus@icculus.org>
parents: 724
diff changeset
   333
                return TOKEN_HLSL_SEMANTIC;
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
   334
            else if (is_usertype(ctx))
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
   335
                return TOKEN_HLSL_USERTYPE;
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
            return TOKEN_HLSL_IDENTIFIER;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   337
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   338
        case TOKEN_EOI: return 0;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   339
        case TOKEN_BAD_CHARS: printf("bad chars from lexer\n"); return 0;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   340
        case TOKEN_PREPROCESSING_ERROR: printf("error from lexer\n"); return 0;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   341
        default: assert(0 && "unexpected token from lexer\n"); return 0;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   342
    } // switch
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   343
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   344
    return 0;
731
a3ce99bdc376 Corrected function name coding style.
Ryan C. Gordon <icculus@icculus.org>
parents: 730
diff changeset
   345
} // convert_to_lemon_token
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   346
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
void MOJOSHADER_compile(const char *filename,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   349
                             const char *source, unsigned int sourcelen,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
                             const MOJOSHADER_preprocessorDefine *defines,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
                             unsigned int define_count,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
                             MOJOSHADER_includeOpen include_open,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
                             MOJOSHADER_includeClose include_close,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
                             MOJOSHADER_malloc m, MOJOSHADER_free f, void *d)
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   355
{
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
    Context ctx;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
    if (m == NULL) m = MOJOSHADER_internal_malloc;
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
    if (f == NULL) f = MOJOSHADER_internal_free;
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
   359
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
   360
    memset(&ctx, '\0', sizeof (Context));
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
    ctx.preprocessor = preprocessor_start(filename, source, sourcelen,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
                                           include_open, include_close,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
                                           defines, define_count, 0, m, f, d);
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   364
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   365
    void *pParser = ParseHLSLAlloc(m, d);
716
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
   366
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
   367
    #if DEBUG_COMPILER_PARSER
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
   368
    ParseHLSLTrace(stdout, "COMPILER: ");
94a804b54078 Cleaned up HLSL parser tracing.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
   369
    #endif
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   371
    do {
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
        ctx.token = preprocessor_nexttoken(ctx.preprocessor,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
                                                &ctx.tokenlen,
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
                                                &ctx.tokenval);
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
   375
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
   376
        TokenData token = { ctx.token, ctx.tokenlen };
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
   377
        ParseHLSL(pParser, convert_to_lemon_token(&ctx), token, &ctx);
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
    } while (ctx.tokenval != TOKEN_EOI);
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   379
    ParseHLSLFree(pParser, f, d);
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
}
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
778
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
   382
// end of mojoshader_compiler.c ...
a43d07e5da68 Added some structure for user types (struct at the moment).
Ryan C. Gordon <icculus@icculus.org>
parents: 731
diff changeset
   383