Browse Source

fixed some more bugs in location assignment

pull/2/head
Siegfried Pammer 16 years ago
parent
commit
5de1b3594e
  1. 2426
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  2. 54
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

2426
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

54
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -786,8 +786,9 @@ EnumMemberDecl<out FieldDeclaration f>
f.StartLocation = varDecl.StartLocation = t.Location; f.StartLocation = varDecl.StartLocation = t.Location;
.) .)
[ "=" Expr<out expr> (. varDecl.Initializer = expr; .) ] [ "=" Expr<out expr> (. varDecl.Initializer = expr; .) ]
(. f.EndLocation = varDecl.EndLocation = t.EndLocation; .)
EndOfStmt EndOfStmt
. .
ClassMemberDecl<ModifierList m, List<AttributeSection> attributes> = ClassMemberDecl<ModifierList m, List<AttributeSection> attributes> =
StructureMemberDecl<m, attributes> StructureMemberDecl<m, attributes>
@ -1699,7 +1700,7 @@ SimpleExpr<out Expression pexpr>
XmlOpenTag IdentifierOrKeyword<out name> XmlCloseTag XmlOpenTag IdentifierOrKeyword<out name> XmlCloseTag
(. pexpr = new XmlMemberAccessExpression(pexpr, XmlAxisType.Element, name, true); .) (. pexpr = new XmlMemberAccessExpression(pexpr, XmlAxisType.Element, name, true); .)
| IdentifierOrKeyword<out name> | IdentifierOrKeyword<out name>
(. pexpr = new MemberReferenceExpression(pexpr, name); .) (. pexpr = new MemberReferenceExpression(pexpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
) )
[ IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) [ IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
"(" "Of" TypeArgumentList<((MemberReferenceExpression)pexpr).TypeArguments> ")" "(" "Of" TypeArgumentList<((MemberReferenceExpression)pexpr).TypeArguments> ")"
@ -1758,7 +1759,7 @@ SimpleNonInvocationExpression<out Expression pexpr>
( "MyBase" (. retExpr = new BaseReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation }; .) ( "MyBase" (. retExpr = new BaseReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
| "MyClass" (. retExpr = new ClassReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation }; .) | "MyClass" (. retExpr = new ClassReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
) )
"." IdentifierOrKeyword<out name> (. pexpr = new MemberReferenceExpression(retExpr, name); .) "." IdentifierOrKeyword<out name> (. pexpr = new MemberReferenceExpression(retExpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
| "Global" "." | "Global" "."
Identifier (. type = new TypeReference(t.val ?? ""); .) Identifier (. type = new TypeReference(t.val ?? ""); .)
/* fallback to "" is required if the token wasn't an identifier (->parser error but no exception) */ /* fallback to "" is required if the token wasn't an identifier (->parser error but no exception) */
@ -1786,9 +1787,9 @@ SimpleNonInvocationExpression<out Expression pexpr>
/* this form only occurs in WithStatements */ /* this form only occurs in WithStatements */
"." ( "." (
XmlOpenTag IdentifierOrKeyword<out name> XmlCloseTag XmlOpenTag IdentifierOrKeyword<out name> XmlCloseTag
(. pexpr = new XmlMemberAccessExpression(null, XmlAxisType.Element, name, true); .) (. pexpr = new XmlMemberAccessExpression(null, XmlAxisType.Element, name, true) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
| IdentifierOrKeyword<out name> | IdentifierOrKeyword<out name>
(. pexpr = new MemberReferenceExpression(null, name); .) (. pexpr = new MemberReferenceExpression(null, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
) | ) |
"!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(null, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation }); .) "!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(null, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation }); .)
| (. XmlAxisType axisType = XmlAxisType.Element; bool isXmlIdentifier = false; .) | (. XmlAxisType axisType = XmlAxisType.Element; bool isXmlIdentifier = false; .)
@ -2979,7 +2980,15 @@ Block<out Statement stmt>
BlockStart(blockStmt); BlockStart(blockStmt);
.) .)
{ {
IF (IsEndStmtAhead()) "End" EndOfStmt (. AddChild(new EndStatement()); .) IF (IsEndStmtAhead())
(. Token first = la; .)
"End" EndOfStmt
(.
AddChild(new EndStatement() {
StartLocation = first.Location,
EndLocation = first.EndLocation }
);
.)
| Statement EndOfStmt | Statement EndOfStmt
/* IF (!LeaveBlock()) { }*/ /* IF (!LeaveBlock()) { }*/
} }
@ -3319,7 +3328,10 @@ EmbeddedStatement<out Statement statement>
// a field reference expression that stands alone is a // a field reference expression that stands alone is a
// invocation expression without parantheses and arguments // invocation expression without parantheses and arguments
if(expr is MemberReferenceExpression || expr is IdentifierExpression) { if(expr is MemberReferenceExpression || expr is IdentifierExpression) {
Location endLocation = expr.EndLocation;
expr = new InvocationExpression(expr); expr = new InvocationExpression(expr);
expr.StartLocation = startLoc;
expr.EndLocation = endLocation;
} }
statement = new ExpressionStatement(expr); statement = new ExpressionStatement(expr);
.) .)
@ -3354,11 +3366,11 @@ EmbeddedStatement<out Statement statement>
SingleLineStatementList<List<Statement> list> SingleLineStatementList<List<Statement> list>
(. Statement embeddedStatement = null; .) (. Statement embeddedStatement = null; .)
= =
( "End" (. embeddedStatement = new EndStatement(); .) ( "End" (. embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
| EmbeddedStatement<out embeddedStatement> ) | EmbeddedStatement<out embeddedStatement> )
(. if (embeddedStatement != null) list.Add(embeddedStatement); .) (. if (embeddedStatement != null) list.Add(embeddedStatement); .)
{ ":" { ":" } { ":" { ":" }
( "End" (. embeddedStatement = new EndStatement(); .) ( "End" (. embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
| EmbeddedStatement<out embeddedStatement> ) | EmbeddedStatement<out embeddedStatement> )
(. if (embeddedStatement != null) list.Add(embeddedStatement); .) (. if (embeddedStatement != null) list.Add(embeddedStatement); .)
} }
@ -3388,6 +3400,7 @@ LoopControlVariable<out TypeReference type, out string name>
OnErrorStatement<out OnErrorStatement stmt> OnErrorStatement<out OnErrorStatement stmt>
(. (.
stmt = null; stmt = null;
Location startLocation = la.Location;
GotoStatement goToStatement = null; GotoStatement goToStatement = null;
.) .)
= =
@ -3420,19 +3433,26 @@ OnErrorStatement<out OnErrorStatement stmt>
stmt = new OnErrorStatement(new ResumeStatement(true)); stmt = new OnErrorStatement(new ResumeStatement(true));
.) .)
) )
(.
if (stmt != null) {
stmt.StartLocation = startLocation;
stmt.EndLocation = t.EndLocation;
}
.)
. .
/* 10.11 */ /* 10.11 */
GotoStatement<out GotoStatement goToStatement> GotoStatement<out GotoStatement goToStatement>
(. (. string label = String.Empty; Location startLocation = la.Location; .)
string label = String.Empty;
.)
= =
"GoTo" LabelName<out label> "GoTo" LabelName<out label>
(. (.
goToStatement = new GotoStatement(label); goToStatement = new GotoStatement(label) {
StartLocation = startLocation,
EndLocation = t.EndLocation
};
.) .)
. .
/* 10.1 */ /* 10.1 */
LabelName<out string name> LabelName<out string name>
@ -3451,11 +3471,15 @@ ReDimClause<out Expression expr>
. .
ReDimClauseInternal<ref Expression expr> ReDimClauseInternal<ref Expression expr>
(. List<Expression> arguments; bool canBeNormal; bool canBeRedim; string name; .) (. List<Expression> arguments; bool canBeNormal; bool canBeRedim; string name; Location startLocation = la.Location; .)
= =
{ "." IdentifierOrKeyword<out name> (. expr = new MemberReferenceExpression(expr, name); .) { "." IdentifierOrKeyword<out name> (. expr = new MemberReferenceExpression(expr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
| IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) | IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
InvocationExpression<ref expr> InvocationExpression<ref expr>
(.
expr.StartLocation = startLocation;
expr.EndLocation = t.EndLocation;
.)
} }
"(" "("
NormalOrReDimArgumentList<out arguments, out canBeNormal, out canBeRedim> NormalOrReDimArgumentList<out arguments, out canBeNormal, out canBeRedim>

Loading…
Cancel
Save