I don't think this approach is quite going to work. Consider the following shader:
typedef float2 Dword;
float4 main() : sv_target { DWORD f = 1.0; return f; }
It seems that redefining these types is legal (although it doesn't seem to be legal to redefine lowercase "dword" as a type?). E.g. that shader compiles as-is, but if the first line is changed to "DWORD" it will predictably fail (float2 to float4 implicit conversion).
It also seems that at least "vector" and "string" should be case-insensitive keywords rather than typedefs. That's mostly out of scope here, but it does mean that patch 3/4 is going in the wrong direction.
From patch 3/4:
@@ -3509,6 +3509,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl INT intval; FLOAT floatval; bool boolval;
- char *strval; char *name; DWORD modifiers; struct hlsl_ir_node *instr;
I'd just rename "name" rather than adding a new union value.
@@ -611,6 +611,7 @@ struct hlsl_ir_constant int32_t i; float f; double d;
} value[4];const char *s;
This is going to need special handling when the constant is cloned or freed.