HLSL: allow "sample" as a valid identifier.
HLSL has keywords for various interpolation modifiers such as "linear", "centroid", "sample", etc. Of these, "sample" appears to be special, as it is also accepted as an identifier string, where the others are not. This PR adds this ability, so the construct "int sample = 42;" no longer produces a compilation error. New test = hlsl.identifier.sample.frag
This commit is contained in:
@@ -85,6 +85,19 @@ bool HlslGrammar::acceptIdentifier(HlslToken& idToken)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Even though "sample" is a keyword (for interpolation modifiers), it IS still accepted as
|
||||
// an identifier. This appears to be a solitary exception: other interp modifier keywords such
|
||||
// as "linear" or "centroid" NOT valid identifiers. This code special cases "sample",
|
||||
// so e.g, "int sample;" is accepted.
|
||||
if (peekTokenClass(EHTokSample)) {
|
||||
idToken.string = NewPoolTString("sample");
|
||||
idToken.tokenClass = EHTokIdentifier;
|
||||
idToken.symbol = nullptr;
|
||||
idToken.loc = token.loc;
|
||||
advanceToken();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user