diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index daa2db23..a3c16c51 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -398,76 +398,6 @@ struct hlsl_scope struct hlsl_scope *upper; }; -/* Structures used only during parsing */ -struct parse_parameter -{ - struct hlsl_type *type; - const char *name; - const char *semantic; - const struct hlsl_reg_reservation *reg_reservation; - unsigned int modifiers; -}; - -struct parse_colon_attribute -{ - const char *semantic; - struct hlsl_reg_reservation *reg_reservation; -}; - -struct parse_initializer -{ - struct hlsl_ir_node **args; - unsigned int args_count; - struct list *instrs; -}; - -struct parse_variable_def -{ - struct list entry; - struct source_location loc; - - char *name; - unsigned int array_size; - const char *semantic; - struct hlsl_reg_reservation *reg_reservation; - struct parse_initializer initializer; -}; - -struct parse_function -{ - char *name; - struct hlsl_ir_function_decl *decl; -}; - -struct parse_if_body -{ - struct list *then_instrs; - struct list *else_instrs; -}; - -enum parse_unary_op -{ - UNARY_OP_PLUS, - UNARY_OP_MINUS, - UNARY_OP_LOGICNOT, - UNARY_OP_BITNOT, -}; - -enum parse_assign_op -{ - ASSIGN_OP_ASSIGN, - ASSIGN_OP_ADD, - ASSIGN_OP_SUB, - ASSIGN_OP_MUL, - ASSIGN_OP_DIV, - ASSIGN_OP_MOD, - ASSIGN_OP_LSHIFT, - ASSIGN_OP_RSHIFT, - ASSIGN_OP_AND, - ASSIGN_OP_OR, - ASSIGN_OP_XOR, -}; - struct hlsl_parse_ctx { const char **source_files; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index c97ce059..5c3160f4 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -19,10 +19,87 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -%{ + +%code requires +{ + #include "hlsl.h" #include +struct parse_parameter +{ + struct hlsl_type *type; + const char *name; + const char *semantic; + const struct hlsl_reg_reservation *reg_reservation; + unsigned int modifiers; +}; + +struct parse_colon_attribute +{ + const char *semantic; + struct hlsl_reg_reservation *reg_reservation; +}; + +struct parse_initializer +{ + struct hlsl_ir_node **args; + unsigned int args_count; + struct list *instrs; +}; + +struct parse_variable_def +{ + struct list entry; + struct source_location loc; + + char *name; + uint32_t array_size; + const char *semantic; + struct hlsl_reg_reservation *reg_reservation; + struct parse_initializer initializer; +}; + +struct parse_function +{ + char *name; + struct hlsl_ir_function_decl *decl; +}; + +struct parse_if_body +{ + struct list *then_instrs; + struct list *else_instrs; +}; + +enum parse_unary_op +{ + UNARY_OP_PLUS, + UNARY_OP_MINUS, + UNARY_OP_LOGICNOT, + UNARY_OP_BITNOT, +}; + +enum parse_assign_op +{ + ASSIGN_OP_ASSIGN, + ASSIGN_OP_ADD, + ASSIGN_OP_SUB, + ASSIGN_OP_MUL, + ASSIGN_OP_DIV, + ASSIGN_OP_MOD, + ASSIGN_OP_LSHIFT, + ASSIGN_OP_RSHIFT, + ASSIGN_OP_AND, + ASSIGN_OP_OR, + ASSIGN_OP_XOR, +}; + +} + +%code +{ + int hlsl_lex(void); struct hlsl_parse_ctx hlsl_ctx; @@ -1504,7 +1581,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, return statements_list; } -%} +} %locations %define parse.error verbose