VariableExpression: Restrict CharClass.Mixed to middle of identifiers
This commit is contained in:
@@ -334,6 +334,15 @@ namespace OpenRA.Support
|
||||
return false;
|
||||
}
|
||||
|
||||
static TokenType VariableOrKeyword(string expression, int start, ref int i)
|
||||
{
|
||||
if (CharClassOf(expression[i - 1]) == CharClass.Mixed)
|
||||
throw new InvalidDataException("Invalid identifier end character at index {0} for `{1}`".F(
|
||||
i - 1, expression.Substring(start, i - start)));
|
||||
|
||||
return VariableOrKeyword(expression, start, i - start);
|
||||
}
|
||||
|
||||
static TokenType VariableOrKeyword(string expression, int start, int length)
|
||||
{
|
||||
var i = start;
|
||||
@@ -464,10 +473,10 @@ namespace OpenRA.Support
|
||||
{
|
||||
cc = CharClassOf(expression[i]);
|
||||
if (cc == CharClass.Whitespace || cc == CharClass.Operator)
|
||||
return VariableOrKeyword(expression, start, i - start);
|
||||
return VariableOrKeyword(expression, start, ref i);
|
||||
}
|
||||
|
||||
return VariableOrKeyword(expression, start, i - start);
|
||||
return VariableOrKeyword(expression, start, ref i);
|
||||
}
|
||||
|
||||
public static Token GetNext(string expression, ref int i, TokenType lastType = TokenType.Invalid)
|
||||
|
||||
Reference in New Issue
Block a user