Browse Source

fixed some bugs in EF parser

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@6003 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
04afca4812
  1. 3
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt
  2. 1
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Keywords.cs
  3. 8
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs
  4. 126
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs
  5. 41
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg
  6. 5
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.cs
  7. 4215
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs
  8. 7
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/PushParser.frame
  9. 3307
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  10. 2
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  11. 7
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs

3
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt

@ -203,6 +203,7 @@ ColonAssign = ":=" @@ -203,6 +203,7 @@ ColonAssign = ":="
"Or"
"Order"
"OrElse"
"Out"
"Overloads"
"Overridable"
"Overrides"
@ -273,7 +274,7 @@ GlobalLevel("Namespace", "Module", "Class", "Structure", "Imports", "Option") @@ -273,7 +274,7 @@ GlobalLevel("Namespace", "Module", "Class", "Structure", "Imports", "Option")
TypeLevel("Sub", "Function", "Property")
# List of keywords that are valid identifiers, must be the same as the "Identifier" production in VBNET.ATG
IdentifierTokens("Text", "Binary", "Compare", "Assembly", "Ansi", "Auto", "Preserve", "Unicode", "Until", "Off", "Explicit", "Infer", "From", "Join", "Equals", "Distinct", "Where", "Take", "Skip", "Order", "By", "Ascending", "Descending", "Group", "Into", "Aggregate")
IdentifierTokens("Text", "Binary", "Compare", "Assembly", "Ansi", "Auto", "Preserve", "Unicode", "Until", "Off", "Out", "Key", "Explicit", "Infer", "From", "Join", "Equals", "Distinct", "Where", "Take", "Skip", "Order", "By", "Ascending", "Descending", "Group", "Into", "Aggregate")
ExpressionStart("Me", "MyBase", "MyClass", "False", "New", "Nothing", "True", "GetType")
SimpleTypeName(@TypeKW, @IdentifierTokens)
TypeKW("Boolean", "Date", "Char", "String", "Decimal", "Byte", "Short", "Integer", "Long", "Single", "Double", "UInteger", "ULong", "UShort", "SByte")

1
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Keywords.cs

@ -128,6 +128,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -128,6 +128,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"OR",
"ORDER",
"ORELSE",
"OUT",
"OVERLOADS",
"OVERRIDABLE",
"OVERRIDES",

8
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs

@ -9,8 +9,10 @@ using System; @@ -9,8 +9,10 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Parser.VBNet.Experimental;
@ -446,6 +448,12 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -446,6 +448,12 @@ namespace ICSharpCode.NRefactory.Parser.VB
{
Token t = NextInternal();
ef.InformToken(t);
// if (ef.Errors.Any()) {
// foreach (Token token in ef.Errors) {
// if (token != null)
// errors.Error(token.Location.Line, token.Location.Column, "unexpected: " + token.ToString());
// }
// }
ef.Advance();
return t;
}

126
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs

@ -190,67 +190,68 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -190,67 +190,68 @@ namespace ICSharpCode.NRefactory.Parser.VB
public const int Or = 176;
public const int Order = 177;
public const int OrElse = 178;
public const int Overloads = 179;
public const int Overridable = 180;
public const int Overrides = 181;
public const int ParamArray = 182;
public const int Partial = 183;
public const int Preserve = 184;
public const int Private = 185;
public const int Property = 186;
public const int Protected = 187;
public const int Public = 188;
public const int RaiseEvent = 189;
public const int ReadOnly = 190;
public const int ReDim = 191;
public const int Rem = 192;
public const int RemoveHandler = 193;
public const int Resume = 194;
public const int Return = 195;
public const int SByte = 196;
public const int Select = 197;
public const int Set = 198;
public const int Shadows = 199;
public const int Shared = 200;
public const int Short = 201;
public const int Single = 202;
public const int Skip = 203;
public const int Static = 204;
public const int Step = 205;
public const int Stop = 206;
public const int Strict = 207;
public const int String = 208;
public const int Structure = 209;
public const int Sub = 210;
public const int SyncLock = 211;
public const int Take = 212;
public const int Text = 213;
public const int Then = 214;
public const int Throw = 215;
public const int To = 216;
public const int True = 217;
public const int Try = 218;
public const int TryCast = 219;
public const int TypeOf = 220;
public const int UInteger = 221;
public const int ULong = 222;
public const int Unicode = 223;
public const int Until = 224;
public const int UShort = 225;
public const int Using = 226;
public const int Variant = 227;
public const int Wend = 228;
public const int When = 229;
public const int Where = 230;
public const int While = 231;
public const int Widening = 232;
public const int With = 233;
public const int WithEvents = 234;
public const int WriteOnly = 235;
public const int Xor = 236;
public const int GetXmlNamespace = 237;
public const int Out = 179;
public const int Overloads = 180;
public const int Overridable = 181;
public const int Overrides = 182;
public const int ParamArray = 183;
public const int Partial = 184;
public const int Preserve = 185;
public const int Private = 186;
public const int Property = 187;
public const int Protected = 188;
public const int Public = 189;
public const int RaiseEvent = 190;
public const int ReadOnly = 191;
public const int ReDim = 192;
public const int Rem = 193;
public const int RemoveHandler = 194;
public const int Resume = 195;
public const int Return = 196;
public const int SByte = 197;
public const int Select = 198;
public const int Set = 199;
public const int Shadows = 200;
public const int Shared = 201;
public const int Short = 202;
public const int Single = 203;
public const int Skip = 204;
public const int Static = 205;
public const int Step = 206;
public const int Stop = 207;
public const int Strict = 208;
public const int String = 209;
public const int Structure = 210;
public const int Sub = 211;
public const int SyncLock = 212;
public const int Take = 213;
public const int Text = 214;
public const int Then = 215;
public const int Throw = 216;
public const int To = 217;
public const int True = 218;
public const int Try = 219;
public const int TryCast = 220;
public const int TypeOf = 221;
public const int UInteger = 222;
public const int ULong = 223;
public const int Unicode = 224;
public const int Until = 225;
public const int UShort = 226;
public const int Using = 227;
public const int Variant = 228;
public const int Wend = 229;
public const int When = 230;
public const int Where = 231;
public const int While = 232;
public const int Widening = 233;
public const int With = 234;
public const int WithEvents = 235;
public const int WriteOnly = 236;
public const int Xor = 237;
public const int GetXmlNamespace = 238;
public const int MaxToken = 238;
public const int MaxToken = 239;
static BitArray NewSet(params int[] values)
{
BitArray bitArray = new BitArray(MaxToken);
@ -263,9 +264,9 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -263,9 +264,9 @@ namespace ICSharpCode.NRefactory.Parser.VB
public static BitArray BlockSucc = NewSet(Case, Catch, Else, ElseIf, End, Finally, Loop, Next);
public static BitArray GlobalLevel = NewSet(Namespace, Module, Class, Structure, Imports, Option);
public static BitArray TypeLevel = NewSet(Sub, Function, Property);
public static BitArray IdentifierTokens = NewSet(Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate);
public static BitArray IdentifierTokens = NewSet(Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate);
public static BitArray ExpressionStart = NewSet(Me, MyBase, MyClass, False, New, Nothing, True, GetType);
public static BitArray SimpleTypeName = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate);
public static BitArray SimpleTypeName = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate);
public static BitArray TypeKW = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte);
static string[] tokenList = new string[] {
@ -451,6 +452,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -451,6 +452,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"Or",
"Order",
"OrElse",
"Out",
"Overloads",
"Overridable",
"Overrides",

41
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg

@ -195,6 +195,7 @@ TOKENS @@ -195,6 +195,7 @@ TOKENS
"Or"
"Order"
"OrElse"
"Out"
"Overloads"
"Overridable"
"Overrides"
@ -297,13 +298,35 @@ NamespaceDeclaration = @@ -297,13 +298,35 @@ NamespaceDeclaration =
TypeDeclaration =
{ AttributeBlock }
{ TypeModifier }
( "Module" | "Class" ) (. PushContext(Context.IdentifierExpected, t); .) ANY (. PopContext(); .) { ANY } StatementTerminator
( ClassOrModuleOrStructureTypeDeclaration |
DelegateTypeDeclaration )
.
ClassOrModuleOrStructureTypeDeclaration =
( "Module" | "Class" | "Structure" ) (. PushContext(Context.IdentifierExpected, t); .) ANY (. PopContext(); .)
[ "(" "Of" [ "Out" | "In" ] IdentifierExceptOut [ "As" GenericConstraintList ] { "," [ "Out" | "In" ] IdentifierExceptOut [ "As" GenericConstraintList ] } ")" ] { ANY } [ StatementTerminator ]
[ "Inherits" { ANY } StatementTerminator ]
[ "Implements" { ANY } StatementTerminator ]
(. PushContext(Context.Type, t); .)
{ MemberDeclaration }
"End" ( "Module" | "Class" ) StatementTerminator
"End" ( "Module" | "Class" | "Structure" ) StatementTerminator
(. PopContext(); .)
.
GenericConstraint =
TypeName | "New" | "Class" | "Structure"
.
GenericConstraintList =
GenericConstraint | "{" GenericConstraint { "," GenericConstraint } "}"
.
DelegateTypeDeclaration =
"Delegate" ("Sub" | "Function")
(. PushContext(Context.IdentifierExpected, t); .) ANY (. PopContext(); .)
[ "(" [ ParameterList ] ")" ] [ "As" TypeName ] StatementTerminator
.
MemberDeclaration =
(. PushContext(Context.Member, t); .)
{ AttributeBlock } { MemberModifier }
@ -314,7 +337,7 @@ MemberDeclaration = @@ -314,7 +337,7 @@ MemberDeclaration =
EventMemberDeclaration |
CustomEventMemberDeclaration |
OperatorDeclaration
)
)
(. PopContext(); .)
.
@ -328,7 +351,7 @@ SubOrFunctionDeclaration = @@ -328,7 +351,7 @@ SubOrFunctionDeclaration =
ExternalMemberDeclaration =
"Declare" [ "Ansi" | "Unicode" | "Auto" ] ( "Sub" | "Function" ) (. PushContext(Context.IdentifierExpected, t); .) Identifier (. PopContext(); .)
"Lib" LiteralString [ "Alias" LiteralString ] [ "(" [ ParameterList ] ")" ] StatementTerminator
"Lib" LiteralString [ "Alias" LiteralString ] [ "(" [ ParameterList ] ")" ] [ "As" TypeName ] StatementTerminator
.
EventMemberDeclaration =
@ -597,7 +620,7 @@ GroupJoinSuffix = @@ -597,7 +620,7 @@ GroupJoinSuffix =
ExpressionRangeVariable =
[
EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve",
"Order", "Off", "Key", "Join", "Into", "Infer", "Group", "From",
"Order", "Off", "Out", "Key", "Join", "Into", "Infer", "Group", "From",
"Explicit", "Equals", "Distinct", "Descending", "Compare", "By",
"Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident)
(
@ -790,6 +813,7 @@ IdentifierOrKeyword = ident @@ -790,6 +813,7 @@ IdentifierOrKeyword = ident
| "Or"
| "Order"
| "OrElse"
| "Out"
| "Overloads"
| "Overridable"
| "Overrides"
@ -1063,7 +1087,12 @@ IdentifierForFieldDeclaration = @@ -1063,7 +1087,12 @@ IdentifierForFieldDeclaration =
| "From"
.
IdentifierForExpressionStart =
IdentifierForExpressionStart =
IdentifierExceptOut
| "Out"
.
IdentifierExceptOut =
ident
| "Ansi"
| "Ascending"

5
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.cs

@ -100,7 +100,10 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental @@ -100,7 +100,10 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental
public bool NextTokenIsStartOfImportsOrAccessExpression {
get { return nextTokenIsStartOfImportsOrAccessExpression; }
set { nextTokenIsStartOfImportsOrAccessExpression = value; }
}
public List<Token> Errors {
get { return errors; }
}
}

4215
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs

File diff suppressed because it is too large Load Diff

7
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/PushParser.frame

@ -37,6 +37,7 @@ partial class ExpressionFinder { @@ -37,6 +37,7 @@ partial class ExpressionFinder {
bool nextTokenIsPotentialStartOfXmlMode = false;
bool readXmlIdentifier = false;
bool nextTokenIsStartOfImportsOrAccessExpression = false;
List<Token> errors = new List<Token>();
public ExpressionFinder()
{
@ -45,14 +46,18 @@ partial class ExpressionFinder { @@ -45,14 +46,18 @@ partial class ExpressionFinder {
void Expect(int expectedKind, Token la)
{
if (la.kind != expectedKind)
if (la.kind != expectedKind) {
Error(la);
output.AppendLine("expected: " + expectedKind);
Console.WriteLine("expected: " + expectedKind);
}
}
void Error(Token la)
{
output.AppendLine("not expected: " + la);
Console.WriteLine("not expected: " + la);
errors.Add(la);
}
Token t;

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

File diff suppressed because it is too large Load Diff

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

@ -194,6 +194,7 @@ TOKENS @@ -194,6 +194,7 @@ TOKENS
"Or"
"Order"
"OrElse"
"Out"
"Overloads"
"Overridable"
"Overrides"
@ -3446,6 +3447,7 @@ IdentifierForFieldDeclaration = @@ -3446,6 +3447,7 @@ IdentifierForFieldDeclaration =
| "Key"
| "Off"
| "Order"
| "Out"
| "Preserve"
| "Skip"
| "Take"

7
src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs

@ -1122,6 +1122,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -1122,6 +1122,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.OrElse, lexer.NextToken().Kind);
}
[Test]
public void TestOut()
{
ILexer lexer = GenerateLexer(new StringReader("Out"));
Assert.AreEqual(Tokens.Out, lexer.NextToken().Kind);
}
[Test]
public void TestOverloads()
{

Loading…
Cancel
Save