d3dcompiler: Flesh out the lexer more.
This commit is contained in:
parent
233101b0ca
commit
5e82c397f4
|
@ -43,6 +43,7 @@ RESERVED4 typename|union|unsigned|using|virtual
|
|||
|
||||
WS [ \t]
|
||||
NEWLINE (\n)|(\r\n)
|
||||
DOUBLESLASHCOMMENT "//"[^\n]*
|
||||
STRING \"[^\"]*\"
|
||||
|
||||
ANY (.)
|
||||
|
@ -65,6 +66,133 @@ ANY (.)
|
|||
set_parse_status(&hlsl_ctx.status, PARSE_ERR);
|
||||
}
|
||||
|
||||
BlendState {return KW_BLENDSTATE; }
|
||||
break {return KW_BREAK; }
|
||||
Buffer {return KW_BUFFER; }
|
||||
cbuffer {return KW_CBUFFER; }
|
||||
compile {return KW_COMPILE; }
|
||||
const {return KW_CONST; }
|
||||
continue {return KW_CONTINUE; }
|
||||
DepthStencilState {return KW_DEPTHSTENCILSTATE; }
|
||||
DepthStencilView {return KW_DEPTHSTENCILVIEW; }
|
||||
discard {return KW_DISCARD; }
|
||||
do {return KW_DO; }
|
||||
double {return KW_DOUBLE; }
|
||||
else {return KW_ELSE; }
|
||||
extern {return KW_EXTERN; }
|
||||
false {return KW_FALSE; }
|
||||
for {return KW_FOR; }
|
||||
GeometryShader {return KW_GEOMETRYSHADER; }
|
||||
groupshared {return KW_GROUPSHARED; }
|
||||
if {return KW_IF; }
|
||||
in {return KW_IN; }
|
||||
inline {return KW_INLINE; }
|
||||
inout {return KW_INOUT; }
|
||||
matrix {return KW_MATRIX; }
|
||||
namespace {return KW_NAMESPACE; }
|
||||
nointerpolation {return KW_NOINTERPOLATION; }
|
||||
out {return KW_OUT; }
|
||||
pass {return KW_PASS; }
|
||||
PixelShader {return KW_PIXELSHADER; }
|
||||
precise {return KW_PRECISE; }
|
||||
RasterizerState {return KW_RASTERIZERSTATE; }
|
||||
RenderTargetView {return KW_RENDERTARGETVIEW; }
|
||||
return {return KW_RETURN; }
|
||||
register {return KW_REGISTER; }
|
||||
sampler {return KW_SAMPLER; }
|
||||
sampler1D {return KW_SAMPLER1D; }
|
||||
sampler2D {return KW_SAMPLER2D; }
|
||||
sampler3D {return KW_SAMPLER3D; }
|
||||
samplerCUBE {return KW_SAMPLERCUBE; }
|
||||
sampler_state {return KW_SAMPLER_STATE; }
|
||||
SamplerComparisonState {return KW_SAMPLERCOMPARISONSTATE;}
|
||||
shared {return KW_SHARED; }
|
||||
stateblock {return KW_STATEBLOCK; }
|
||||
stateblock_state {return KW_STATEBLOCK_STATE; }
|
||||
static {return KW_STATIC; }
|
||||
string {return KW_STRING; }
|
||||
struct {return KW_STRUCT; }
|
||||
switch {return KW_SWITCH; }
|
||||
tbuffer {return KW_TBUFFER; }
|
||||
technique {return KW_TECHNIQUE; }
|
||||
technique10 {return KW_TECHNIQUE10; }
|
||||
texture {return KW_TEXTURE; }
|
||||
texture1D {return KW_TEXTURE1D; }
|
||||
Texture1DArray {return KW_TEXTURE1DARRAY; }
|
||||
texture2D {return KW_TEXTURE2D; }
|
||||
Texture2DArray {return KW_TEXTURE2DARRAY; }
|
||||
Texture2DMS {return KW_TEXTURE2DMS; }
|
||||
Texture2DMSArray {return KW_TEXTURE2DMSARRAY; }
|
||||
texture3D {return KW_TEXTURE3D; }
|
||||
Texture3DArray {return KW_TEXTURE3DARRAY; }
|
||||
textureCUBE {return KW_TEXTURECUBE; }
|
||||
true {return KW_TRUE; }
|
||||
typedef {return KW_TYPEDEF; }
|
||||
uniform {return KW_UNIFORM; }
|
||||
vector {return KW_VECTOR; }
|
||||
VertexShader {return KW_VERTEXSHADER; }
|
||||
void {return KW_VOID; }
|
||||
volatile {return KW_VOLATILE; }
|
||||
while {return KW_WHILE; }
|
||||
|
||||
\+\+ {return OP_INC; }
|
||||
\-\- {return OP_DEC; }
|
||||
&& {return OP_AND; }
|
||||
\|\| {return OP_OR; }
|
||||
== {return OP_EQ; }
|
||||
\<\< {return OP_LEFTSHIFT; }
|
||||
\<\<= {return OP_LEFTSHIFTASSIGN; }
|
||||
\>\> {return OP_RIGHTSHIFT; }
|
||||
\>\>= {return OP_RIGHTSHIFTASSIGN; }
|
||||
\.\.\. {return OP_ELLIPSIS; }
|
||||
\<= {return OP_LE; }
|
||||
\>= {return OP_GE; }
|
||||
\< {return OP_LT; }
|
||||
\> {return OP_GT; }
|
||||
!= {return OP_NE; }
|
||||
\+= {return OP_ADDASSIGN; }
|
||||
\-= {return OP_SUBASSIGN; }
|
||||
\*= {return OP_MULASSIGN; }
|
||||
\/= {return OP_DIVASSIGN; }
|
||||
%= {return OP_MODASSIGN; }
|
||||
&= {return OP_ANDASSIGN; }
|
||||
\|= {return OP_ORASSIGN; }
|
||||
^= {return OP_XORASSIGN; }
|
||||
## {return OP_UNKNOWN1; }
|
||||
#@ {return OP_UNKNOWN2; }
|
||||
:: {return OP_UNKNOWN3; }
|
||||
\-\> {return OP_UNKNOWN4; }
|
||||
|
||||
column_major {return KW_COLUMN_MAJOR; }
|
||||
row_major {return KW_ROW_MAJOR; }
|
||||
|
||||
[+-]?[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[h|H|f|F]? {
|
||||
hlsl_lval.floatval = atof(yytext);
|
||||
return C_FLOAT;
|
||||
}
|
||||
[+-]?[0-9]+\.([eE][+-]?[0-9]+)?[h|H|f|F]? {
|
||||
hlsl_lval.floatval = atof(yytext);
|
||||
return C_FLOAT;
|
||||
}
|
||||
[+-]?[0-9]+([eE][+-]?[0-9]+)?[h|H|f|F] {
|
||||
hlsl_lval.floatval = atof(yytext);
|
||||
return C_FLOAT;
|
||||
}
|
||||
0x[0-9a-fA-F]+ {
|
||||
sscanf(yytext, "0x%x", &hlsl_lval.intval);
|
||||
return C_INTEGER;
|
||||
}
|
||||
0[0-7]+ {
|
||||
sscanf(yytext, "0%o", &hlsl_lval.intval);
|
||||
return C_INTEGER;
|
||||
}
|
||||
\-?[0-9]+ {
|
||||
hlsl_lval.intval = (atoi(yytext));
|
||||
return C_INTEGER;
|
||||
}
|
||||
|
||||
{DOUBLESLASHCOMMENT} {}
|
||||
|
||||
{WS}+ {}
|
||||
{NEWLINE} {
|
||||
hlsl_ctx.line_no++;
|
||||
|
|
|
@ -55,11 +55,113 @@ static void hlsl_error(const char *s)
|
|||
{
|
||||
char *name;
|
||||
INT intval;
|
||||
FLOAT floatval;
|
||||
}
|
||||
|
||||
%token KW_BLENDSTATE
|
||||
%token KW_BREAK
|
||||
%token KW_BUFFER
|
||||
%token KW_CBUFFER
|
||||
%token KW_COLUMN_MAJOR
|
||||
%token KW_COMPILE
|
||||
%token KW_CONST
|
||||
%token KW_CONTINUE
|
||||
%token KW_DEPTHSTENCILSTATE
|
||||
%token KW_DEPTHSTENCILVIEW
|
||||
%token KW_DISCARD
|
||||
%token KW_DO
|
||||
%token KW_DOUBLE
|
||||
%token KW_ELSE
|
||||
%token KW_EXTERN
|
||||
%token KW_FALSE
|
||||
%token KW_FOR
|
||||
%token KW_GEOMETRYSHADER
|
||||
%token KW_GROUPSHARED
|
||||
%token KW_IF
|
||||
%token KW_IN
|
||||
%token KW_INLINE
|
||||
%token KW_INOUT
|
||||
%token KW_MATRIX
|
||||
%token KW_NAMESPACE
|
||||
%token KW_NOINTERPOLATION
|
||||
%token KW_OUT
|
||||
%token KW_PASS
|
||||
%token KW_PIXELSHADER
|
||||
%token KW_PRECISE
|
||||
%token KW_RASTERIZERSTATE
|
||||
%token KW_RENDERTARGETVIEW
|
||||
%token KW_RETURN
|
||||
%token KW_REGISTER
|
||||
%token KW_ROW_MAJOR
|
||||
%token KW_SAMPLER
|
||||
%token KW_SAMPLER1D
|
||||
%token KW_SAMPLER2D
|
||||
%token KW_SAMPLER3D
|
||||
%token KW_SAMPLERCUBE
|
||||
%token KW_SAMPLER_STATE
|
||||
%token KW_SAMPLERCOMPARISONSTATE
|
||||
%token KW_SHARED
|
||||
%token KW_STATEBLOCK
|
||||
%token KW_STATEBLOCK_STATE
|
||||
%token KW_STATIC
|
||||
%token KW_STRING
|
||||
%token KW_STRUCT
|
||||
%token KW_SWITCH
|
||||
%token KW_TBUFFER
|
||||
%token KW_TECHNIQUE
|
||||
%token KW_TECHNIQUE10
|
||||
%token KW_TEXTURE
|
||||
%token KW_TEXTURE1D
|
||||
%token KW_TEXTURE1DARRAY
|
||||
%token KW_TEXTURE2D
|
||||
%token KW_TEXTURE2DARRAY
|
||||
%token KW_TEXTURE2DMS
|
||||
%token KW_TEXTURE2DMSARRAY
|
||||
%token KW_TEXTURE3D
|
||||
%token KW_TEXTURE3DARRAY
|
||||
%token KW_TEXTURECUBE
|
||||
%token KW_TRUE
|
||||
%token KW_TYPEDEF
|
||||
%token KW_UNIFORM
|
||||
%token KW_VECTOR
|
||||
%token KW_VERTEXSHADER
|
||||
%token KW_VOID
|
||||
%token KW_VOLATILE
|
||||
%token KW_WHILE
|
||||
|
||||
%token OP_INC
|
||||
%token OP_DEC
|
||||
%token OP_AND
|
||||
%token OP_OR
|
||||
%token OP_EQ
|
||||
%token OP_LEFTSHIFT
|
||||
%token OP_LEFTSHIFTASSIGN
|
||||
%token OP_RIGHTSHIFT
|
||||
%token OP_RIGHTSHIFTASSIGN
|
||||
%token OP_ELLIPSIS
|
||||
%token OP_LE
|
||||
%token OP_GE
|
||||
%token OP_LT
|
||||
%token OP_GT
|
||||
%token OP_NE
|
||||
%token OP_ADDASSIGN
|
||||
%token OP_SUBASSIGN
|
||||
%token OP_MULASSIGN
|
||||
%token OP_DIVASSIGN
|
||||
%token OP_MODASSIGN
|
||||
%token OP_ANDASSIGN
|
||||
%token OP_ORASSIGN
|
||||
%token OP_XORASSIGN
|
||||
%token OP_UNKNOWN1
|
||||
%token OP_UNKNOWN2
|
||||
%token OP_UNKNOWN3
|
||||
%token OP_UNKNOWN4
|
||||
|
||||
%token <intval> PRE_LINE
|
||||
|
||||
%token <name> STRING
|
||||
%token <floatval> C_FLOAT
|
||||
%token <intval> C_INTEGER
|
||||
%%
|
||||
|
||||
hlsl_prog: /* empty */
|
||||
|
|
Loading…
Reference in New Issue