private void CalculateVirtualEnd(ParseContext context) {
int position = this.Arguments.Count > 0 ? this.Arguments.End : this.OpenBrace.End;
if (!context.Tokens.IsEndOfStream()) {
TokenStream<RToken> tokens = context.Tokens;
// Walk through tokens allowing numbers, identifiers and operators
// as part of the function signature. Stop at keywords (except 'if'),
// or curly braces.
int i = tokens.Position;
_virtualEnd = 0;
for (; i < tokens.Length; i++) {
RToken token = tokens[i];
if (token.TokenType == RTokenType.Keyword || RParser.IsListTerminator(context, RTokenType.OpenBrace, token)) {
_virtualEnd = token.Start;
break;
}
}
}
if (_virtualEnd == 0) {
_virtualEnd = context.TextProvider.Length;
}
}