Skip to content

Commit

Permalink
Initial work on parsing sampler declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 7, 2009
1 parent 9dc1a60 commit f62ff50
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mojoshader_compiler.c
Expand Up @@ -245,6 +245,15 @@ static int ConvertToLemonToken(const Context *ctx)
if (tokencmp("call")) return TOKEN_HLSL_CALL;
if (tokencmp("case")) return TOKEN_HLSL_CASE;
if (tokencmp("default")) return TOKEN_HLSL_DEFAULT;
if (tokencmp("sampler")) return TOKEN_HLSL_SAMPLER;
if (tokencmp("sampler1D")) return TOKEN_HLSL_SAMPLER1D;
if (tokencmp("sampler2D")) return TOKEN_HLSL_SAMPLER2D;
if (tokencmp("sampler3D")) return TOKEN_HLSL_SAMPLER3D;
if (tokencmp("samplerCUBE")) return TOKEN_HLSL_SAMPLERCUBE;
if (tokencmp("sampler_state")) return TOKEN_HLSL_SAMPLER_STATE;
if (tokencmp("SamplerState")) return TOKEN_HLSL_SAMPLERSTATE;
if (tokencmp("SamplerComparisonState")) return TOKEN_HLSL_SAMPLERCOMPARISONSTATE;

#undef tokencmp
return TOKEN_HLSL_IDENTIFIER;

Expand Down
12 changes: 12 additions & 0 deletions mojoshader_parser_hlsl.lemon
Expand Up @@ -170,6 +170,8 @@ variable_declaration ::= datatype scalar_or_array variable_lowlevel SEMICOLON.
variable_declaration ::= datatype scalar_or_array SEMICOLON.
variable_declaration ::= struct_declaration scalar_or_array SEMICOLON.

// !!! FIXME: we don't handle full sampler declarations at the moment.

struct_declaration ::= STRUCT identifier LBRACE struct_member_list RBRACE.

struct_member_list ::= struct_member.
Expand Down Expand Up @@ -220,10 +222,20 @@ initializer ::= ASSIGN expression.
intrinsic_datatype ::= datatype_vector.
intrinsic_datatype ::= datatype_matrix.
intrinsic_datatype ::= datatype_scalar.
intrinsic_datatype ::= datatype_sampler.

datatype ::= intrinsic_datatype.
datatype ::= USERTYPE.

datatype_sampler ::= SAMPLER.
datatype_sampler ::= SAMPLER1D.
datatype_sampler ::= SAMPLER2D.
datatype_sampler ::= SAMPLER3D.
datatype_sampler ::= SAMPLERCUBE.
datatype_sampler ::= SAMPLER_STATE.
datatype_sampler ::= SAMPLERSTATE.
datatype_sampler ::= SAMPLERCOMPARISONSTATE.

datatype_scalar ::= BOOL.
datatype_scalar ::= INT.
datatype_scalar ::= UINT.
Expand Down

0 comments on commit f62ff50

Please sign in to comment.