本文整理汇总了C#中Microsoft.Cci.SourceLocationBuilder.UpdateToSpan方法的典型用法代码示例。如果您正苦于以下问题:C# SourceLocationBuilder.UpdateToSpan方法的具体用法?C# SourceLocationBuilder.UpdateToSpan怎么用?C# SourceLocationBuilder.UpdateToSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Cci.SourceLocationBuilder
的用法示例。
在下文中一共展示了SourceLocationBuilder.UpdateToSpan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseStatementBlock
private BlockStatement ParseStatementBlock(TokenSet followers) {
SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.CurrentSourceLocation);
List<Statement> statements = new List<Statement>();
this.ParseStatements(statements, followers);
slb.UpdateToSpan(this.scanner.CurrentSourceLocation);
return new BlockStatement(statements, slb);
}
示例2: ParseDo
private Statement ParseDo(TokenSet followers)
//^ requires this.currentToken == Token.Do;
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.CurrentSourceLocation);
this.GetNextToken();
this.Skip(Token.While);
Expression condition = this.ParseExpression(followers|Token.EndOfLine);
this.Skip(Token.EndOfLine);
BlockStatement body = this.ParseStatementBlock(followers|Token.Loop);
slb.UpdateToSpan(this.scanner.CurrentSourceLocation);
WhileDoStatement result = new WhileDoStatement(condition, body, slb);
this.SkipClosingKeyword(Token.Loop, followers);
return result;
}
示例3: ParseArgumentList
protected override List<Expression> ParseArgumentList(SourceLocationBuilder slb, TokenSet followers)
{
var result = new List<Expression>();
this.Skip(Token.LeftParenthesis);
while (this.currentToken != Token.RightParenthesis) {
if (this.currentToken == Token.Specification) {
result.Add(this.ParseSpecArgument(followers | Token.Comma | Token.Specification | Token.RightParenthesis));
continue;
}
result.Add(this.ParseArgumentExpression(followers | Token.Comma | Token.Specification | Token.RightParenthesis));
if (this.currentToken == Token.Comma) {
this.GetNextToken();
continue;
}
if (this.currentToken == Token.Specification)
continue;
break;
}
slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
this.SkipOverTo(Token.RightParenthesis, followers);
return result;
}
示例4: ParseRestOfEnum
private void ParseRestOfEnum(SourceLocationBuilder sctx, TypeDeclaration type, List<ITypeDeclarationMember> members, TokenSet followers)
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
TypeExpression texpr = new NamedTypeExpression(new SimpleName(type.Name, type.Name.SourceLocation, false));
this.Skip(Token.LeftBrace);
while (this.currentToken == Token.LeftBracket || Parser.IdentifierOrNonReservedKeyword[this.currentToken]){
this.ParseEnumMember(texpr, members, followers|Token.Comma|Token.RightBrace);
if (this.currentToken == Token.RightBrace) break;
this.Skip(Token.Comma);
if (this.currentToken == Token.RightBrace) break;
}
sctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
this.Skip(Token.RightBrace);
if (this.currentToken == Token.Semicolon)
this.GetNextToken();
this.SkipTo(followers);
}
示例5: ParseNestedDelegateDeclaration
private void ParseNestedDelegateDeclaration(List<ITypeDeclarationMember> typeMembers, List<SourceCustomAttribute>/*?*/ attributes, TypeDeclaration.Flags flags, SourceLocationBuilder sctx, TokenSet followers)
//^ requires this.currentToken == Token.Delegate;
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
this.GetNextToken();
TypeExpression returnType = this.ParseTypeExpression(false, false, followers|Token.LeftParenthesis|Token.Semicolon|Parser.IdentifierOrNonReservedKeyword);
if (!Parser.IdentifierOrNonReservedKeyword[this.currentToken])
this.HandleError(Error.ExpectedIdentifier);
NameDeclaration name = this.ParseNameDeclaration();
List<Ast.GenericTypeParameterDeclaration> genericParameters = new List<Ast.GenericTypeParameterDeclaration>();
List<Ast.ParameterDeclaration> parameters = new List<Ast.ParameterDeclaration>();
SignatureDeclaration signature = new SignatureDeclaration(returnType, parameters, sctx);
NestedDelegateDeclaration type = new NestedDelegateDeclaration(attributes, flags, name, genericParameters, signature, sctx);
typeMembers.Add(type);
this.ParseGenericTypeParameters(genericParameters, followers|Token.LeftParenthesis|Token.Where|Token.Semicolon);
this.ParseParameters(parameters, Token.RightParenthesis, followers|Token.Where|Token.Semicolon, sctx);
this.ParseGenericTypeParameterConstraintsClauses(genericParameters, followers|Token.Semicolon);
sctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
if (this.currentToken == Token.Semicolon)
this.GetNextToken();
this.SkipTo(followers);
}
示例6: ParseRealLiteral
private CompileTimeConstant ParseRealLiteral()
//^ requires this.currentToken == Token.RealLiteral;
{
string tokStr = this.scanner.GetTokenSource();
SourceLocationBuilder ctx = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
TypeCode tc = this.scanner.ScanNumberSuffix();
ctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
CompileTimeConstant result;
string/*?*/ typeName = null;
switch (tc) {
case TypeCode.Single:
typeName = "float";
float fVal;
if (!Single.TryParse(tokStr, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out fVal))
this.HandleError(ctx, Error.FloatOverflow, typeName);
else if (fVal == 0f && tokStr.IndexOfAny(nonZeroDigits) >= 0)
this.HandleError(ctx, Error.FloatOverflow, typeName);
result = new CompileTimeConstant(fVal, false, ctx);
break;
case TypeCode.Empty:
case TypeCode.Double:
typeName = "double";
double dVal;
if (!Double.TryParse(tokStr, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out dVal))
this.HandleError(ctx, Error.FloatOverflow, typeName);
else if (dVal == 0d && tokStr.IndexOfAny(nonZeroDigits) >= 0)
this.HandleError(ctx, Error.FloatOverflow, typeName);
result = new CompileTimeConstant(dVal, tc == TypeCode.Empty, ctx);
break;
case TypeCode.Decimal:
typeName = "decimal";
decimal decVal;
if (!Decimal.TryParse(tokStr, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out decVal))
this.HandleError(ctx, Error.FloatOverflow, typeName);
result = new CompileTimeConstant(decVal, false, ctx);
break;
default:
this.HandleError(Error.ExpectedSemicolon);
goto case TypeCode.Empty;
}
//^ assume this.currentToken == Token.RealLiteral; //follows from the precondition
this.GetNextToken();
return result;
}
示例7: ParseHexLiteral
private CompileTimeConstant ParseHexLiteral()
//^ requires this.currentToken == Token.HexLiteral;
{
string tokStr = this.scanner.GetTokenSource();
//^ assume tokStr.StartsWith("0x") || tokStr.StartsWith("0X"); //The scanner should not return a Token.HexLiteral when this is not the case.
SourceLocationBuilder ctx = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
TypeCode tc = this.scanner.ScanNumberSuffix();
ctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
CompileTimeConstant result;
switch (tc) {
case TypeCode.Single:
case TypeCode.Double:
case TypeCode.Decimal:
this.HandleError(Error.ExpectedSemicolon);
goto default;
default:
ulong ul;
//^ assume tokStr.Length >= 2;
if (!UInt64.TryParse(tokStr.Substring(2), System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out ul)) {
this.HandleError(ctx, Error.IntOverflow);
ul = 0;
}
result = GetConstantOfSmallestIntegerTypeThatIncludes(ul, tc, ctx);
break;
}
//^ assume this.currentToken == Token.HexLiteral; //follows from the precondition
this.GetNextToken();
return result;
}
示例8: ParseIndexer
private Indexer ParseIndexer(Expression indexedObject, TokenSet followers)
//^ requires this.currentToken == Token.LeftBracket;
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
SourceLocationBuilder slb = new SourceLocationBuilder(indexedObject.SourceLocation);
this.GetNextToken();
List<Expression> indices = new List<Expression>();
while (this.currentToken != Token.RightBracket) {
Expression index = this.ParseExpression(followers|Token.Comma|Token.RightBracket);
indices.Add(index);
if (this.currentToken != Token.Comma) break;
this.GetNextToken();
}
indices.TrimExcess();
slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
Indexer result = new Indexer(indexedObject, indices.AsReadOnly(), slb);
this.SkipOverTo(Token.RightBracket, followers);
return result;
}
示例9: ParseArgumentList
private List<Expression> ParseArgumentList(SourceLocationBuilder slb, TokenSet followers)
//^ requires this.currentToken == Token.LeftParenthesis;
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
this.GetNextToken();
TokenSet followersOrCommaOrRightParenthesis = followers|Token.Comma|Token.RightParenthesis;
List<Expression> arguments = new List<Expression>();
if (this.currentToken != Token.RightParenthesis) {
Expression argument = this.ParseArgument(followersOrCommaOrRightParenthesis);
arguments.Add(argument);
while (this.currentToken == Token.Comma) {
this.GetNextToken();
argument = this.ParseArgument(followersOrCommaOrRightParenthesis);
arguments.Add(argument);
}
}
arguments.TrimExcess();
slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
this.SkipOverTo(Token.RightParenthesis, followers);
return arguments;
}
示例10: ParseRankSpecifier
private uint ParseRankSpecifier(SourceLocationBuilder sctx, TokenSet followers)
//^ requires this.currentToken == Token.LeftBracket;
//^ ensures result > 0;
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
this.GetNextToken();
uint rank = 1;
while (this.currentToken == Token.Comma) {
rank++;
this.GetNextToken();
}
ISourceLocation tokLoc = this.scanner.SourceLocationOfLastScannedToken;
//^ assume tokLoc.SourceDocument == sctx.SourceDocument;
sctx.UpdateToSpan(tokLoc);
this.SkipOverTo(Token.RightBracket, followers);
return rank;
}
示例11: ParseGetValueOfTypedReference
private Expression ParseGetValueOfTypedReference(TokenSet followers)
//^ requires this.currentToken == Token.RefValue;
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
this.GetNextToken();
this.Skip(Token.LeftParenthesis);
Expression e = this.ParseExpression(followers|Token.Comma);
this.Skip(Token.Comma);
TypeExpression te = this.ParseTypeExpression(false, false, followers|Token.RightParenthesis);
slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
Expression result = new GetValueOfTypedReference(e, te, slb);
this.SkipOverTo(Token.RightParenthesis, followers);
return result;
}
示例12: ParseLambdaParameter
private LambdaParameter ParseLambdaParameter(bool allowType, TokenSet followers)
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
bool isOut = false;
bool isRef = false;
Token firstToken = this.currentToken;
NameDeclaration parameterName = new NameDeclaration(this.GetNameFor(this.scanner.GetIdentifierString()), this.scanner.SourceLocationOfLastScannedToken);
TypeExpression/*?*/ parameterType = null;
if (allowType) {
if (this.currentToken == Token.Out) { isOut = true; this.GetNextToken(); }
else if (this.currentToken == Token.Ref) { isRef = true; this.GetNextToken(); }
parameterType = this.ParseTypeExpression(false, false, followers);
if ((this.currentToken == Token.Comma || this.currentToken == Token.RightParenthesis) && Parser.IdentifierOrNonReservedKeyword[firstToken]) {
parameterType = null;
} else {
parameterName = new NameDeclaration(this.GetNameFor(this.scanner.GetIdentifierString()), this.scanner.SourceLocationOfLastScannedToken);
}
}
slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
LambdaParameter result = new LambdaParameter(isOut, isRef, parameterType, parameterName, slb);
if (!Parser.IdentifierOrNonReservedKeyword[this.currentToken])
this.HandleError(Error.ExpectedIdentifier);
else {
//^ assume this.currentToken != Token.EndOfFile; //follows from definition of Parser.IdentifierOrNonReservedKeyword
this.GetNextToken();
}
this.SkipTo(followers);
return result;
}
示例13: ParsePrimaryExpression
//.........这里部分代码省略.........
this.GetNextToken();
break;
case Token.HexLiteral:
expression = this.ParseHexLiteral();
break;
case Token.IntegerLiteral:
expression = this.ParseIntegerLiteral();
break;
case Token.RealLiteral:
expression = this.ParseRealLiteral();
break;
case Token.StringLiteral:
expression = new CompileTimeConstant(this.scanner.GetString(), false, sctx);
this.GetNextToken();
break;
case Token.This:
expression = new ThisReference(sctx);
this.GetNextToken();
break;
case Token.Base:
expression = new BaseClassReference(sctx);
this.GetNextToken();
break;
case Token.Typeof:
case Token.Sizeof:
case Token.Default:
expression = this.ParseTypeofSizeofOrDefault(followers);
break;
case Token.Stackalloc:
return this.ParseStackalloc(followers);
case Token.Checked:
case Token.MakeRef:
case Token.RefType:
case Token.Unchecked:
expression = this.ParseCheckedOrMakeRefOrRefTypeOrUnchecked(followers);
break;
case Token.RefValue:
expression = this.ParseGetValueOfTypedReference(followers);
break;
case Token.Bool:
case Token.Decimal:
case Token.Sbyte:
case Token.Byte:
case Token.Short:
case Token.Ushort:
case Token.Int:
case Token.Uint:
case Token.Long:
case Token.Ulong:
case Token.Char:
case Token.Float:
case Token.Double:
case Token.Object:
case Token.String:
expression = this.RootQualifiedNameFor(this.currentToken, sctx);
this.GetNextToken();
break;
case Token.LeftParenthesis:
expression = this.ParseCastExpression(followers|Token.Dot|Token.LeftBracket|Token.Arrow);
break;
default:
if (Parser.IdentifierOrNonReservedKeyword[this.currentToken]) goto case Token.Identifier;
if (Parser.InfixOperators[this.currentToken]) {
this.HandleError(Error.InvalidExprTerm, this.scanner.GetTokenSource());
//^ assume this.currentToken != Token.EndOfFile; //should not be a member of InfixOperators
this.GetNextToken();
} else
this.SkipTo(followers|Parser.PrimaryStart, Error.InvalidExprTerm, this.scanner.GetTokenSource());
if (Parser.PrimaryStart[this.currentToken]) return this.ParsePrimaryExpression(followers);
goto done;
}
expression = this.ParseIndexerCallOrSelector(expression, followers|Token.AddOne|Token.SubtractOne);
for (; ; ) {
switch (this.currentToken) {
case Token.AddOne:
SourceLocationBuilder slb = new SourceLocationBuilder(expression.SourceLocation);
slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
this.GetNextToken();
expression = new PostfixIncrement(new TargetExpression(expression), slb);
break;
case Token.SubtractOne:
slb = new SourceLocationBuilder(expression.SourceLocation);
slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
this.GetNextToken();
expression = new PostfixDecrement(new TargetExpression(expression), slb);
break;
case Token.Arrow:
case Token.Dot:
case Token.LeftBracket:
expression = this.ParseIndexerCallOrSelector(expression, followers|Token.AddOne|Token.SubtractOne);
break;
default:
goto done;
}
}
done:
this.SkipTo(followers);
return expression;
}
示例14: ParseUnaryExpression
private Expression ParseUnaryExpression(TokenSet followers)
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
switch (this.currentToken) {
case Token.AddOne:
case Token.BitwiseAnd:
case Token.BitwiseNot:
case Token.LogicalNot:
case Token.Multiply:
case Token.Plus:
case Token.Subtract:
case Token.SubtractOne:
SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
Token operatorToken = this.currentToken;
this.GetNextToken();
Expression operand = this.ParseUnaryExpression(followers);
slb.UpdateToSpan(operand.SourceLocation);
Expression result = AllocateUnaryExpression(operatorToken, operand, slb);
//^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile;
return result;
//case Token.LeftParenthesis:
// return this.ParseCastExpression(followers);
default:
return this.ParsePrimaryExpression(followers);
}
}
示例15: ParseConditional
private Expression ParseConditional(Expression condition, TokenSet followers)
//^ requires this.currentToken == Token.Conditional;
//^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
{
this.GetNextToken();
SourceLocationBuilder slb = new SourceLocationBuilder(condition.SourceLocation);
Expression resultIfTrue = this.ParseExpression(followers|Token.Colon);
Expression resultIfFalse;
if (this.currentToken == Token.Colon) {
this.GetNextToken();
resultIfFalse = this.ParseExpression(followers);
} else {
this.Skip(Token.Colon); //gives appropriate error message
if (!followers[this.currentToken])
//Assume that only the : is missing. Go ahead as if it were specified.
resultIfFalse = this.ParseExpression(followers);
else
resultIfFalse = this.ParseDummyExpression();
}
slb.UpdateToSpan(resultIfFalse.SourceLocation);
Expression result = new Conditional(condition, resultIfTrue, resultIfFalse, slb);
this.SkipTo(followers);
return result;
}