mojoshader_parser_hlsl.lemon
changeset 778 a43d07e5da68
parent 777 5ab8bb0ac2af
child 779 160b46d02cc0
equal deleted inserted replaced
777:5ab8bb0ac2af 778:a43d07e5da68
    19 
    19 
    20 %name ParseHLSL
    20 %name ParseHLSL
    21 
    21 
    22 %start_symbol shader
    22 %start_symbol shader
    23 %token_prefix TOKEN_HLSL_
    23 %token_prefix TOKEN_HLSL_
    24 %token_type { IncludeState * }
    24 %token_type { TokenData }
    25 %extra_argument { Context *ctx }
    25 %extra_argument { Context *ctx }
    26 
    26 
    27 %include {
    27 %include {
    28 #ifndef __MOJOSHADER_HLSL_COMPILER__
    28 #ifndef __MOJOSHADER_HLSL_COMPILER__
    29 #error Do not compile this file directly.
    29 #error Do not compile this file directly.
   159 variable_declaration_details ::= scalar_or_array variable_lowlevel.
   159 variable_declaration_details ::= scalar_or_array variable_lowlevel.
   160 variable_declaration_details ::= scalar_or_array.
   160 variable_declaration_details ::= scalar_or_array.
   161 
   161 
   162 // !!! FIXME: we don't handle full sampler declarations at the moment.
   162 // !!! FIXME: we don't handle full sampler declarations at the moment.
   163 
   163 
   164 struct_declaration ::= STRUCT identifier LBRACE struct_member_list RBRACE.
   164 struct_declaration ::= STRUCT identifier(A) LBRACE struct_member_list RBRACE.
       
   165 {
       
   166     add_usertype(ctx, A.token, A.tokenlen);
       
   167 }
   165 
   168 
   166 struct_member_list ::= struct_member.
   169 struct_member_list ::= struct_member.
   167 struct_member_list ::= struct_member_list struct_member.
   170 struct_member_list ::= struct_member_list struct_member.
   168 
   171 
   169 struct_member ::= interpolation_mod struct_member_details.
   172 struct_member ::= interpolation_mod struct_member_details.
   446 switch_case ::= CASE expression COLON statement_list.
   449 switch_case ::= CASE expression COLON statement_list.
   447 switch_case ::= CASE expression COLON.
   450 switch_case ::= CASE expression COLON.
   448 switch_case ::= DEFAULT COLON statement_list.
   451 switch_case ::= DEFAULT COLON statement_list.
   449 switch_case ::= DEFAULT COLON.
   452 switch_case ::= DEFAULT COLON.
   450 
   453 
   451 // I may want to do more with this at some point.
   454 %type identifier { TokenData }
   452 identifier ::= IDENTIFIER.
   455 identifier(A) ::= IDENTIFIER(B).
   453 
   456 {
       
   457     A.token = B.token;
       
   458     A.tokenlen = B.tokenlen;
       
   459 }
   454 
   460 
   455 // the expression stuff is based on Jeff Lee's ANSI C grammar.
   461 // the expression stuff is based on Jeff Lee's ANSI C grammar.
   456 primary_expr ::= identifier.
   462 primary_expr ::= identifier.
   457 primary_expr ::= INT_CONSTANT.
   463 primary_expr ::= INT_CONSTANT.
   458 primary_expr ::= FLOAT_CONSTANT.
   464 primary_expr ::= FLOAT_CONSTANT.