Browse Source

current state of NRefactory additions (broken)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5864 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
17f9b913f7
  1. 2
      src/Libraries/NRefactory/NRefactory.sln
  2. 32
      src/Libraries/NRefactory/NRefactoryASTGenerator/KeywordGenerator.cs
  3. 32
      src/Libraries/NRefactory/Project/NRefactory.csproj
  4. 48
      src/Libraries/NRefactory/Project/Src/Ast/Generated.cs
  5. 2
      src/Libraries/NRefactory/Project/Src/IAstVisitor.cs
  6. 4
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs
  7. 4
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt
  8. 4
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs
  9. 6008
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  10. 37
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  11. 38
      src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame
  12. 52
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg
  13. 26
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.cs
  14. 1652
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs
  15. 4
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.frame
  16. 6
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/PushParser.frame
  17. 58
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/ParserTests.cs
  18. 40
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/Program.cs
  19. 29
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/TokenTests.cs
  20. 1
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/VBParserExperiment.csproj
  21. 6745
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  22. 79
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  23. 2
      src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs
  24. 2
      src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs
  25. 2
      src/Libraries/NRefactory/Project/Src/Visitors/NodeTrackingAstVisitor.cs
  26. 2
      src/Libraries/NRefactory/Project/Src/Visitors/NotImplementedAstVisitor.cs
  27. 311
      src/Libraries/NRefactory/Test/Lexer/CSharp/LexerTests.cs
  28. 535
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs
  29. 6
      src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

2
src/Libraries/NRefactory/NRefactory.sln

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
# SharpDevelop 4.0.0.5705 # SharpDevelop 4.0.0.5826
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryTests", "Test\NRefactoryTests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryTests", "Test\NRefactoryTests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}"

32
src/Libraries/NRefactory/NRefactoryASTGenerator/KeywordGenerator.cs

@ -10,11 +10,8 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Security.Principal;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks;
using NRefactoryASTGenerator.Ast;
namespace NRefactoryASTGenerator namespace NRefactoryASTGenerator
{ {
@ -107,12 +104,13 @@ namespace NRefactoryASTGenerator
{ {
string sourceDir = Path.Combine(testBaseDir, language, "LexerTests.cs"); string sourceDir = Path.Combine(testBaseDir, language, "LexerTests.cs");
using (StreamWriter writer = new StreamWriter(new FileStream(sourceDir, FileMode.Create))) { using (StreamWriter writer = new StreamWriter(new FileStream(sourceDir, FileMode.Create))) {
writer.WriteLine("// this file was autogenerated by a tool.");
writer.WriteLine("using System;"); writer.WriteLine("using System;");
writer.WriteLine("using System.IO;"); writer.WriteLine("using System.IO;");
writer.WriteLine("using NUnit.Framework;"); writer.WriteLine("using NUnit.Framework;");
writer.WriteLine("using ICSharpCode.NRefactory.Parser;"); writer.WriteLine("using ICSharpCode.NRefactory.Parser;");
writer.WriteLine("using ICSharpCode.NRefactory.Parser.{0};", language == "VBNet" ? "VB" : language); writer.WriteLine("using ICSharpCode.NRefactory.Parser.{0};", language == "VBNet" ? "VB" : language);
writer.WriteLine("using ICSharpCode.NRefactory.PrettyPrinter;\n"); writer.WriteLine("using ICSharpCode.NRefactory.PrettyPrinter;");
writer.WriteLine(); writer.WriteLine();
writer.WriteLine("namespace ICSharpCode.NRefactory.Tests.Lexer.{0}", language == "VBNet" ? "VB" : language); writer.WriteLine("namespace ICSharpCode.NRefactory.Tests.Lexer.{0}", language == "VBNet" ? "VB" : language);
writer.WriteLine("{"); writer.WriteLine("{");
@ -121,7 +119,7 @@ namespace NRefactoryASTGenerator
writer.WriteLine("\t{"); writer.WriteLine("\t{");
writer.WriteLine("\t\tILexer GenerateLexer(StringReader sr)"); writer.WriteLine("\t\tILexer GenerateLexer(StringReader sr)");
writer.WriteLine("\t\t{"); writer.WriteLine("\t\t{");
writer.WriteLine("\t\t\treturn ParserFactory.CreateLexer(SupportedLanguage.CSharp, sr);"); writer.WriteLine("\t\t\treturn ParserFactory.CreateLexer(SupportedLanguage.{0}, sr);", language);
writer.WriteLine("\t\t}"); writer.WriteLine("\t\t}");
for (int i = 0; i < specialChars.Values.Count; i++) { for (int i = 0; i < specialChars.Values.Count; i++) {
writer.WriteLine(); writer.WriteLine();
@ -133,6 +131,8 @@ namespace NRefactoryASTGenerator
writer.WriteLine("\t\t}"); writer.WriteLine("\t\t}");
} }
foreach (string keyword in keywords) { foreach (string keyword in keywords) {
if (keyword == "Rem")
continue;
writer.WriteLine(); writer.WriteLine();
writer.WriteLine("\t\t[Test]"); writer.WriteLine("\t\t[Test]");
writer.WriteLine("\t\tpublic void Test{0}()", UpperCaseFirst(keyword)); writer.WriteLine("\t\tpublic void Test{0}()", UpperCaseFirst(keyword));
@ -236,18 +236,6 @@ namespace NRefactoryASTGenerator
} }
} }
static int FindIndex<T>(this IEnumerable<T> items, Func<T, bool> f)
{
int index = -1;
foreach (T item in items) {
index++;
if (f(item))
return index;
}
return -1;
}
static void GenerateKeywords(Dictionary<string, string> properties, List<string> keywords, string language) static void GenerateKeywords(Dictionary<string, string> properties, List<string> keywords, string language)
{ {
string sourceDir = Path.Combine(baseDir, language, "Keywords.cs"); string sourceDir = Path.Combine(baseDir, language, "Keywords.cs");
@ -388,10 +376,16 @@ namespace NRefactoryASTGenerator
tokenValue++; tokenValue++;
} }
static int FindIndex<T>(this IEnumerable<T> items, Func<T, bool> f)
static void WriteList(this StreamWriter writer, Tuple<string, string[]> data)
{ {
int index = -1;
foreach (T item in items) {
index++;
if (f(item))
return index;
}
return -1;
} }
#endregion #endregion
} }

32
src/Libraries/NRefactory/Project/NRefactory.csproj

@ -55,11 +55,8 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Src\Parser\VBNet\Experimental\Parser.cs"> <Compile Include="Src\Parser\VBNet\Experimental\ExpressionFinder.cs" />
<DependentUpon>ParserHelper.atg</DependentUpon>
</Compile>
<None Include="Resources\ICSharpCode.NRefactory.snk" /> <None Include="Resources\ICSharpCode.NRefactory.snk" />
<None Include="Src\Lexer\BuildKeywords.pl" />
<Compile Include="Configuration\AssemblyInfo.cs" /> <Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\AstBuilder\ExpressionBuilder.cs" /> <Compile Include="Src\AstBuilder\ExpressionBuilder.cs" />
<Compile Include="Src\AstBuilder\StatementBuilder.cs" /> <Compile Include="Src\AstBuilder\StatementBuilder.cs" />
@ -87,7 +84,9 @@
<Compile Include="Src\OperatorPrecedence.cs" /> <Compile Include="Src\OperatorPrecedence.cs" />
<Compile Include="Src\Parser\CSharp\CSharpParser.cs" /> <Compile Include="Src\Parser\CSharp\CSharpParser.cs" />
<Compile Include="Src\Parser\CSharp\Parser.cs" /> <Compile Include="Src\Parser\CSharp\Parser.cs" />
<Compile Include="Src\Parser\VBNet\Experimental\ParserHelper.cs" /> <Compile Include="Src\Parser\VBNet\Experimental\Parser.cs">
<DependentUpon>ExpressionFinder.atg</DependentUpon>
</Compile>
<Compile Include="Src\Parser\VBNet\Parser.cs" /> <Compile Include="Src\Parser\VBNet\Parser.cs" />
<Compile Include="Src\Parser\VBNet\VBNetParser.cs" /> <Compile Include="Src\Parser\VBNet\VBNetParser.cs" />
<Compile Include="Src\Parser\AbstractParser.cs" /> <Compile Include="Src\Parser\AbstractParser.cs" />
@ -138,17 +137,18 @@
<Compile Include="Src\Ast\TypeReference.cs" /> <Compile Include="Src\Ast\TypeReference.cs" />
<Compile Include="Src\Parser\VBNet\ParamModifierList.cs" /> <Compile Include="Src\Parser\VBNet\ParamModifierList.cs" />
<Compile Include="Src\Visitors\NodeTrackingAstVisitor.cs" /> <Compile Include="Src\Visitors\NodeTrackingAstVisitor.cs" />
<None Include="Src\Parser\VBNet\Experimental\Parser.frame"> <None Include="Src\Parser\Frames\Parser.frame" />
<DependentUpon>ParserHelper.atg</DependentUpon> <None Include="Src\Parser\VBNet\Experimental\ExpressionFinder.atg">
</None>
<None Include="Src\Parser\VBNet\Experimental\ParserHelper.atg">
<Generator>CocoParserGenerator</Generator> <Generator>CocoParserGenerator</Generator>
</None> </None>
<None Include="Src\Parser\VBNet\Experimental\Parser.frame">
<DependentUpon>ExpressionFinder.atg</DependentUpon>
</None>
<None Include="Src\Parser\VBNet\Experimental\PushParser.frame"> <None Include="Src\Parser\VBNet\Experimental\PushParser.frame">
<DependentUpon>ParserHelper.atg</DependentUpon> <DependentUpon>ExpressionFinder.atg</DependentUpon>
</None> </None>
<None Include="Src\Parser\VBNet\Experimental\Scanner.frame"> <None Include="Src\Parser\VBNet\Experimental\Scanner.frame">
<DependentUpon>ParserHelper.atg</DependentUpon> <DependentUpon>ExpressionFinder.atg</DependentUpon>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -156,17 +156,19 @@
<Content Include="Src\Lexer\VBNet\KeywordList.txt" /> <Content Include="Src\Lexer\VBNet\KeywordList.txt" />
<Folder Include="Src\Parser" /> <Folder Include="Src\Parser" />
<Folder Include="Src\Parser\CSharp" /> <Folder Include="Src\Parser\CSharp" />
<Content Include="Src\Parser\CSharp\cs.ATG" /> <Content Include="Src\Parser\CSharp\cs.ATG">
<Generator>CocoParserGenerator</Generator>
</Content>
<Folder Include="Src\Parser\Frames" /> <Folder Include="Src\Parser\Frames" />
<Content Include="Src\Parser\Frames\Parser.frame" />
<Content Include="Src\Parser\Frames\Scanner.frame" /> <Content Include="Src\Parser\Frames\Scanner.frame" />
<Content Include="Src\Parser\Frames\SharpCoco.exe" /> <Content Include="Src\Parser\Frames\SharpCoco.exe" />
<Content Include="Src\Parser\Frames\trace.txt" /> <Content Include="Src\Parser\Frames\trace.txt" />
<Folder Include="Src\Parser\VBNet" /> <Folder Include="Src\Parser\VBNet" />
<Content Include="Src\Parser\VBNet\VBNET.ATG"> <None Include="Src\Parser\VBNet\VBNET.ATG">
<CopyToOutputDirectory>Never</CopyToOutputDirectory> <CopyToOutputDirectory>Never</CopyToOutputDirectory>
<Generator>CocoParserGenerator</Generator> <Generator>CocoParserGenerator</Generator>
</Content> <CustomToolNamespace>ICSharpCode.NRefactory.Parser.VB</CustomToolNamespace>
</None>
<Content Include="Src\Parser\gen.bat" /> <Content Include="Src\Parser\gen.bat" />
<Folder Include="Src\Parser\VBNet\Experimental" /> <Folder Include="Src\Parser\VBNet\Experimental" />
<Folder Include="Src\PrettyPrinter" /> <Folder Include="Src\PrettyPrinter" />

48
src/Libraries/NRefactory/Project/Src/Ast/Generated.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.4927 // Runtime Version:4.0.30319.1
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -1665,15 +1665,15 @@ namespace ICSharpCode.NRefactory.Ast {
initializer = Expression.Null; initializer = Expression.Null;
} }
public bool HasRemoveRegion { public bool HasAddRegion {
get { get {
return !removeRegion.IsNull; return !addRegion.IsNull;
} }
} }
public bool HasAddRegion { public bool HasRemoveRegion {
get { get {
return !addRegion.IsNull; return !removeRegion.IsNull;
} }
} }
@ -2421,21 +2421,18 @@ namespace ICSharpCode.NRefactory.Ast {
elseIfSections = new List<ElseIfSection>(); elseIfSections = new List<ElseIfSection>();
} }
public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement)
: this(condition) {
this.trueStatement.Add(Statement.CheckNull(trueStatement));
this.falseStatement.Add(Statement.CheckNull(falseStatement));
if (trueStatement != null) trueStatement.Parent = this;
if (falseStatement != null) falseStatement.Parent = this;
}
public bool HasElseStatements { public bool HasElseStatements {
get { get {
return falseStatement.Count > 0; return falseStatement.Count > 0;
} }
} }
public bool HasElseIfSections {
get {
return elseIfSections.Count > 0;
}
}
public IfElseStatement(Expression condition, Statement trueStatement) public IfElseStatement(Expression condition, Statement trueStatement)
: this(condition) { : this(condition) {
@ -2443,11 +2440,14 @@ namespace ICSharpCode.NRefactory.Ast {
if (trueStatement != null) trueStatement.Parent = this; if (trueStatement != null) trueStatement.Parent = this;
} }
public bool HasElseIfSections {
get { public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement)
return elseIfSections.Count > 0; : this(condition) {
this.trueStatement.Add(Statement.CheckNull(trueStatement));
this.falseStatement.Add(Statement.CheckNull(falseStatement));
if (trueStatement != null) trueStatement.Parent = this;
if (falseStatement != null) falseStatement.Parent = this;
} }
}
public override object AcceptVisitor(IAstVisitor visitor, object data) { public override object AcceptVisitor(IAstVisitor visitor, object data) {
return visitor.VisitIfElseStatement(this, data); return visitor.VisitIfElseStatement(this, data);
@ -3403,15 +3403,15 @@ public Location ExtendedEndLocation { get; set; }
initializer = Expression.Null; initializer = Expression.Null;
} }
public bool HasSetRegion { public bool HasGetRegion {
get { get {
return !setRegion.IsNull; return !getRegion.IsNull;
} }
} }
public bool HasGetRegion { public bool HasSetRegion {
get { get {
return !getRegion.IsNull; return !setRegion.IsNull;
} }
} }
@ -5281,10 +5281,10 @@ public Location ExtendedEndLocation { get; set; }
Usings = usings; Usings = usings;
} }
public UsingDeclaration(string @namespace) : this(@namespace, TypeReference.Null) {}
public UsingDeclaration(string @namespace, TypeReference alias) { usings = new List<Using>(1); usings.Add(new Using(@namespace, alias)); } public UsingDeclaration(string @namespace, TypeReference alias) { usings = new List<Using>(1); usings.Add(new Using(@namespace, alias)); }
public UsingDeclaration(string @namespace) : this(@namespace, TypeReference.Null) {}
public UsingDeclaration(string xmlNamespace, string prefix) { usings = new List<Using>(1); usings.Add(new Using(xmlNamespace, prefix)); } public UsingDeclaration(string xmlNamespace, string prefix) { usings = new List<Using>(1); usings.Add(new Using(xmlNamespace, prefix)); }
public override object AcceptVisitor(IAstVisitor visitor, object data) { public override object AcceptVisitor(IAstVisitor visitor, object data) {

2
src/Libraries/NRefactory/Project/Src/IAstVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.4927 // Runtime Version:4.0.30319.1
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

4
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs

@ -172,7 +172,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
public static BitArray TypeKW = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal); public static BitArray TypeKW = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal);
public static BitArray UnaryHead = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd); public static BitArray UnaryHead = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd);
public static BitArray AssnStartOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times); public static BitArray AssnStartOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times);
public static BitArray CastFollower = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal, Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Void, Literal, OpenParenthesis, BitwiseComplement, Not, Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From); public static BitArray CastFollower = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal, Identifier, Partial, Where, Get, Set, Add, Remove, Yield, Select, Group, By, Into, From, Ascending, Descending, Orderby, Let, Join, On, Equals, Void, Literal, OpenParenthesis, BitwiseComplement, Not, Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default);
public static BitArray AssgnOps = NewSet(Assign, PlusAssign, MinusAssign, TimesAssign, DivAssign, ModAssign, BitwiseAndAssign, BitwiseOrAssign, ShiftLeftAssign); public static BitArray AssgnOps = NewSet(Assign, PlusAssign, MinusAssign, TimesAssign, DivAssign, ModAssign, BitwiseAndAssign, BitwiseOrAssign, ShiftLeftAssign);
public static BitArray UnaryOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd); public static BitArray UnaryOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd);
public static BitArray TypeDeclarationKW = NewSet(Class, Interface, Struct, Enum, Delegate); public static BitArray TypeDeclarationKW = NewSet(Class, Interface, Struct, Enum, Delegate);
@ -187,7 +187,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
public static BitArray ExpressionContent = NewSet(As, Is, Out, Ref, In); public static BitArray ExpressionContent = NewSet(As, Is, Out, Ref, In);
public static BitArray InterfaceLevel = NewSet(Event); public static BitArray InterfaceLevel = NewSet(Event);
public static BitArray TypeLevel = NewSet(Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial, Protected, Private, Public, Internal, Const, Event, Explicit, Extern, Fixed, Implicit, New, Operator, Override, Readonly, Virtual, Volatile); public static BitArray TypeLevel = NewSet(Public, Internal, Class, Interface, Struct, Enum, Delegate, Abstract, Sealed, Static, Unsafe, Partial, Protected, Private, Public, Internal, Const, Event, Explicit, Extern, Fixed, Implicit, New, Operator, Override, Readonly, Virtual, Volatile);
public static BitArray StatementStart = NewSet(Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, As, Is, Out, Ref, In, Break, Case, Catch, Checked, Unchecked, Const, Continue, Default, Do, Else, Finally, Fixed, For, Foreach, Goto, If, Lock, Return, Stackalloc, Switch, Throw, Try, Unsafe, Using, While, Yield); public static BitArray StatementStart = NewSet(Base, Delegate, False, New, Null, Sizeof, This, True, Typeof, Checked, Unchecked, From, Default, As, Is, Out, Ref, In, Break, Case, Catch, Checked, Unchecked, Const, Continue, Default, Do, Else, Finally, Fixed, For, Foreach, Goto, If, Lock, Return, Stackalloc, Switch, Throw, Try, Unsafe, Using, While, Yield);
public static BitArray QueryExpressionClauseStart = NewSet(From, Let, Where, Join, Orderby, Group, Select); public static BitArray QueryExpressionClauseStart = NewSet(From, Let, Where, Join, Orderby, Group, Select);
public static BitArray InPropertyDeclaration = NewSet(Protected, Private, Public, Internal, Get, Set); public static BitArray InPropertyDeclaration = NewSet(Protected, Private, Public, Internal, Get, Set);
public static BitArray InEventDeclaration = NewSet(Add, Remove); public static BitArray InEventDeclaration = NewSet(Add, Remove);

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

@ -246,9 +246,13 @@ ConcatStringAssign = "&="
"WriteOnly" "WriteOnly"
"Xor" "Xor"
#XML specific keywords
#Sets #Sets
Null("Nothing") Null("Nothing")
BlockSucc("Case", "Catch", "Else", "ElseIf", "End", "Finally", "Loop", "Next") BlockSucc("Case", "Catch", "Else", "ElseIf", "End", "Finally", "Loop", "Next")
GlobalLevel("Namespace", "Module", "Class", "Structure")
TypeLevel("Sub", "Function", "Property")
# List of keywords that are valid identifiers, must be the same as the "Identifier" production in VBNET.ATG # 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", "Explicit", "Infer", "From", "Join", "Equals", "Distinct", "Where", "Take", "Skip", "Order", "By", "Ascending", "Descending", "Group", "Into", "Aggregate")

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

@ -245,9 +245,9 @@ namespace ICSharpCode.NRefactory.Parser.VB
} }
public static BitArray Null = NewSet(Nothing); public static BitArray Null = NewSet(Nothing);
public static BitArray BlockSucc = NewSet(Case, Catch, Else, ElseIf, End, Finally, Loop, Next); public static BitArray BlockSucc = NewSet(Case, Catch, Else, ElseIf, End, Finally, Loop, Next);
public static BitArray GlobalLevel = NewSet(Namespace, Module, Class, Structure);
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, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate);
public static BitArray TypeLevel = NewSet(Public, Friend, Class, Interface, Structure, Enum, Delegate, Shared, Partial, Protected, Private, Public, Const, Event, Explicit, New, Operator);
public static BitArray GlobalLevel = NewSet(Namespace, Imports, Public, Friend, Class, Interface, Structure, Enum, Delegate, Partial);
static string[] tokenList = new string[] { static string[] tokenList = new string[] {
// ----- terminal classes ----- // ----- terminal classes -----

6008
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

File diff suppressed because it is too large Load Diff

37
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -9,11 +9,12 @@ using Types = ICSharpCode.NRefactory.Ast.ClassType;
COMPILER CS /* AW 2002-12-30 renamed from CompilationUnit to CS */ COMPILER CS /* AW 2002-12-30 renamed from CompilationUnit to CS */
$frameDir=../Frames
/*------------------------------------------------------------------------* /*------------------------------------------------------------------------*
*----- LEXER TOKEN LIST ------------------------------------------------* *----- LEXER TOKEN LIST ------------------------------------------------*
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/
/* START AUTOGENERATED TOKENS SECTION */ /* START AUTOGENERATED TOKENS SECTION */
TOKENS TOKENS
/* ----- terminal classes ----- */ /* ----- terminal classes ----- */
@ -251,7 +252,7 @@ Attribute<out ASTAttribute attribute>
.) .)
. .
AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> named> AttributeArguments<. List<Expression> positional, List<NamedArgumentExpression> named .>
= =
"(" "("
[ [
@ -264,7 +265,7 @@ AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> na
")" ")"
. .
AttributeArgument<List<Expression> positional, List<NamedArgumentExpression> named> AttributeArgument<. List<Expression> positional, List<NamedArgumentExpression> named .>
(. string name = null; bool isNamed = false; Expression expr; .) (. string name = null; bool isNamed = false; Expression expr; .)
= =
( (
@ -359,7 +360,7 @@ ExternAliasDirective
(. compilationUnit.AddChild(ead); .) (. compilationUnit.AddChild(ead); .)
. .
TypeDecl<ModifierList m, List<AttributeSection> attributes> TypeDecl<. ModifierList m, List<AttributeSection> attributes .>
(. (.
TypeReference type; TypeReference type;
List<TypeReference> names; List<TypeReference> names;
@ -489,7 +490,7 @@ Qualident<out string qualident>
} (. qualident = qualidentBuilder.ToString(); .) } (. qualident = qualidentBuilder.ToString(); .)
. .
ClassBase<out List<TypeReference> names> ClassBase<. out List<TypeReference> names .>
(. (.
TypeReference typeRef; TypeReference typeRef;
names = new List<TypeReference>(); names = new List<TypeReference>();
@ -512,7 +513,7 @@ ClassBody
} }
. .
StructInterfaces<out List<TypeReference> names> StructInterfaces<. out List<TypeReference> names .>
(. (.
TypeReference typeRef; TypeReference typeRef;
names = new List<TypeReference>(); names = new List<TypeReference>();
@ -536,7 +537,7 @@ StructBody
"}" "}"
. .
InterfaceBase<out List<TypeReference> names> InterfaceBase<. out List<TypeReference> names .>
(. (.
TypeReference typeRef; TypeReference typeRef;
names = new List<TypeReference>(); names = new List<TypeReference>();
@ -635,7 +636,7 @@ SimpleType<out string name>
. .
FormalParameterList<List<ParameterDeclarationExpression> parameter> FormalParameterList<. List<ParameterDeclarationExpression> parameter .>
(. (.
ParameterDeclarationExpression p; ParameterDeclarationExpression p;
@ -740,7 +741,7 @@ MemberModifiers<ModifierList m>
} }
. .
StructMemberDecl<ModifierList m, List<AttributeSection> attributes> StructMemberDecl<. ModifierList m, List<AttributeSection> attributes .>
(. (.
string qualident = null; string qualident = null;
TypeReference type; TypeReference type;
@ -1054,7 +1055,7 @@ StructMemberDecl<ModifierList m, List<AttributeSection> attributes>
) )
. .
ClassMemberDecl<ModifierList m, List<AttributeSection> attributes> ClassMemberDecl<. ModifierList m, List<AttributeSection> attributes .>
(. Statement stmt = null; .) (. Statement stmt = null; .)
= =
StructMemberDecl<m, attributes> StructMemberDecl<m, attributes>
@ -1205,7 +1206,7 @@ AccessorDecls<out PropertyGetRegion getBlock, out PropertySetRegion setBlock>
) )
. .
GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attributes> GetAccessorDecl<. out PropertyGetRegion getBlock, List<AttributeSection> attributes .>
(. Statement stmt = null; .) (. Statement stmt = null; .)
= =
"get" "get"
@ -1215,7 +1216,7 @@ GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attribute
(. getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; .) (. getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; .)
. .
SetAccessorDecl<out PropertySetRegion setBlock, List<AttributeSection> attributes> SetAccessorDecl<. out PropertySetRegion setBlock, List<AttributeSection> attributes .>
(. Statement stmt = null; .) (. Statement stmt = null; .)
= =
"set" "set"
@ -1643,7 +1644,7 @@ IfStatement<out Statement statement>
.) .)
. .
ForInitializer<out List<Statement> initializer> ForInitializer<. out List<Statement> initializer .>
(. (.
Statement stmt; Statement stmt;
initializer = new List<Statement>(); initializer = new List<Statement>();
@ -1653,7 +1654,7 @@ ForInitializer<out List<Statement> initializer>
| StatementExpr<out stmt> (.initializer.Add(stmt);.) { "," StatementExpr<out stmt> (. initializer.Add(stmt);.) } | StatementExpr<out stmt> (.initializer.Add(stmt);.) { "," StatementExpr<out stmt> (. initializer.Add(stmt);.) }
. .
ForIterator<out List<Statement> iterator> ForIterator<. out List<Statement> iterator .>
(. (.
Statement stmt; Statement stmt;
iterator = new List<Statement>(); iterator = new List<Statement>();
@ -1662,7 +1663,7 @@ ForIterator<out List<Statement> iterator>
StatementExpr<out stmt> (. iterator.Add(stmt);.) { "," StatementExpr<out stmt> (. iterator.Add(stmt); .) } StatementExpr<out stmt> (. iterator.Add(stmt);.) { "," StatementExpr<out stmt> (. iterator.Add(stmt); .) }
. .
SwitchSections<List<SwitchSection> switchSections> SwitchSections<. List<SwitchSection> switchSections .>
(. (.
SwitchSection switchSection = new SwitchSection(); SwitchSection switchSection = new SwitchSection();
CaseLabel label; CaseLabel label;
@ -2342,7 +2343,7 @@ NullableQuestionMark<ref TypeReference typeRef>
.) .)
. .
TypeArgumentList<out List<TypeReference> types, bool canBeUnbound> TypeArgumentList<. out List<TypeReference> types, bool canBeUnbound .>
(. (.
types = new List<TypeReference>(); types = new List<TypeReference>();
TypeReference type = null; TypeReference type = null;
@ -2358,7 +2359,7 @@ TypeArgumentList<out List<TypeReference> types, bool canBeUnbound>
">" ">"
. .
TypeParameterList<List<TemplateDefinition> templates> TypeParameterList<. List<TemplateDefinition> templates .>
(. (.
TemplateDefinition template; TemplateDefinition template;
.) .)
@ -2386,7 +2387,7 @@ VariantTypeParameter<out TemplateDefinition typeParameter>
(. typeParameter.EndLocation = t.EndLocation; .) (. typeParameter.EndLocation = t.EndLocation; .)
. .
TypeParameterConstraintsClause<List<TemplateDefinition> templates> TypeParameterConstraintsClause<. List<TemplateDefinition> templates .>
(. string name = ""; TypeReference type; .) (. string name = ""; TypeReference type; .)
= =
"where" "where"

38
src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame

@ -1,13 +1,8 @@
/* -->begin
Parser.frame file for NRefactory.
*/
using System; using System;
using System.Reflection;
-->namespace -->namespace
-->tokens
partial class Parser : AbstractParser partial class Parser : AbstractParser
{ {
-->constants -->constants
@ -16,9 +11,10 @@ partial class Parser : AbstractParser
-->declarations -->declarations
/* void Get () {
-->pragmas -->pragmas
*/ lexer.NextToken();
}
-->productions -->productions
@ -27,24 +23,28 @@ partial class Parser : AbstractParser
-->parseRoot -->parseRoot
} }
protected override void SynErr(int line, int col, int errorNumber)
{
string s;
switch (errorNumber) {
-->errors
default: s = "error " + errorNumber; break;
}
this.Errors.Error(line, col, s);
}
private bool StartOf(int s) private bool StartOf(int s)
{ {
return set[s, lexer.LookAhead.kind]; return set[s, lexer.LookAhead.kind];
} }
protected override void SynErr(int line, int col, int errorNumber)
{
this.Errors.Error(line, col, ErrorDesc(errorNumber));
}
static bool[,] set = { static bool[,] set = {
-->initialization -->initialization
}; };
string ErrorDesc(int errorNumber)
{
switch (errorNumber) {
-->errors
default: return "error " + errorNumber;
}
}
} // end Parser } // end Parser
$$$ $$$

52
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ParserHelper.atg → src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg

@ -6,7 +6,7 @@ using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Parser.VB; using ICSharpCode.NRefactory.Parser.VB;
using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute; using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute;
PUSHCOMPILER ParserHelper PUSHCOMPILER ExpressionFinder
/* START AUTOGENERATED TOKENS SECTION */ /* START AUTOGENERATED TOKENS SECTION */
TOKENS TOKENS
@ -241,7 +241,7 @@ TOKENS
PRODUCTIONS PRODUCTIONS
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
ParserHelper = ExpressionFinder =
(. PushContext(Context.Global); .) (. PushContext(Context.Global); .)
{ OptionStatement } { OptionStatement }
{ ImportsStatement } { ImportsStatement }
@ -257,7 +257,7 @@ OptionStatement =
. .
ImportsStatement = ImportsStatement =
"Imports" { ANY } StatementTerminator "Imports" (. nextTokenIsPotentialStartOfXmlMode = true; .) { ANY } StatementTerminator
. .
AttributeBlock = AttributeBlock =
@ -277,10 +277,10 @@ NamespaceDeclaration =
TypeDeclaration = TypeDeclaration =
{ AttributeBlock } { AttributeBlock }
{ TypeModifier } { TypeModifier }
"Module" { ANY } StatementTerminator ( "Module" | "Class" ) { ANY } StatementTerminator
(. PushContext(Context.Type); .) (. PushContext(Context.Type); .)
{ MemberDeclaration } { MemberDeclaration }
"End" "Module" StatementTerminator "End" ( "Module" | "Class" ) StatementTerminator
(. PopContext(); .) (. PopContext(); .)
. .
@ -295,8 +295,8 @@ MemberDeclaration =
SubOrFunctionDeclaration = SubOrFunctionDeclaration =
{ AttributeBlock } { MemberModifier } ("Sub" | "Function") { AttributeBlock } { MemberModifier } ("Sub" | "Function")
(. PushContext(Context.IdentifierExpected); .) ANY (. PopContext(); .) (. PushContext(Context.IdentifierExpected); .) ANY (. PopContext(); .)
[ "(" [ ParameterList ] ")" ] [ "As" TypeName ] EOL [ "(" [ ParameterList ] ")" ] [ "As" TypeName ]
[ Block ] Block
"End" ("Sub" | "Function") StatementTerminator "End" ("Sub" | "Function") StatementTerminator
. .
@ -309,17 +309,32 @@ Parameter =
. .
Block = Block =
EOL (. PushContext(Context.Body); .)
StatementTerminator
{ StatementTerminator }
{ Statement }
{ StatementTerminator }
(. PopContext(); .)
. .
Expression = Expression =
Literal | (. isExpressionStart = true; .)
( "(" Expression ")" ) | (
( Identifier [ "(" "Of" TypeName { "," TypeName } ")" ] ) | Literal (. isExpressionStart = false; .) |
"AddressOf" Expression | ( "(" (. isExpressionStart = false; .) Expression ")" ) |
( Identifier (. isExpressionStart = false; .) [ "(" "Of" TypeName { "," TypeName } ")" ] ) |
( "AddressOf" (. isExpressionStart = false; .) Expression) |
( "<" (. PushContext(Context.Xml); .) ANY ">" (. PopContext(); .) )
)
. .
/*
XmlLiteralExpression =
"<"
( "!" | "?" )
.*/
PrimitiveTypeName = PrimitiveTypeName =
"Byte" | "Byte" |
"SByte" | "SByte" |
@ -345,7 +360,8 @@ TypeSuffix = "(" ( "Of" TypeName { "," TypeName } | { "," /*[ EOL ]*/ } ) ")" .
IdentifierOrKeyword = ANY . IdentifierOrKeyword = ANY .
Literal = LiteralString | Literal =
LiteralString |
LiteralCharacter | LiteralCharacter |
LiteralInteger | LiteralInteger |
LiteralDouble | LiteralDouble |
@ -361,10 +377,14 @@ Literal = LiteralString |
"MyClass" "MyClass"
. .
Statement =
( ( Identifier | LiteralInteger ) ":" ) |
( ( "Dim" | "Static" | "Const" ) Identifier [ "?" ] [ ( "(" { "," } ")" ) ] { "," Identifier [ "?" ] [ ( "(" { "," } ")" ) ] } [ "As" [ "New" ] TypeName [ "(" ")" ] ] [ "=" Expression ] )
.
/* This production handles pseudo keywords that are needed in the grammar */ /* This production handles pseudo keywords that are needed in the grammar */
Identifier Identifier =
(. PushContext(Context.IdentifierExpected); .) (. PushContext(Context.IdentifierExpected); .)
=
( (
IdentifierForFieldDeclaration IdentifierForFieldDeclaration
| |
@ -434,5 +454,5 @@ ParameterModifier =
. .
END ParserHelper. END ExpressionFinder.

26
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ParserHelper.cs → src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.cs

@ -7,21 +7,24 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental
{ {
public partial class Parser public partial class ExpressionFinder
{ {
Stack<Context> stack = new Stack<Context>(); Stack<Context> stack = new Stack<Context>();
StringBuilder output = new StringBuilder();
bool isExpressionStart = false;
void PopContext() void PopContext()
{ {
if (stack.Count > 0) { if (stack.Count > 0) {
string indent = new string('\t', stack.Count - 1); string indent = new string('\t', stack.Count - 1);
var item = stack.Pop(); var item = stack.Pop();
Console.WriteLine(indent + "exit " + item); Print(indent + "exit " + item);
} else { } else {
Console.WriteLine("empty stack"); Print("empty stack");
} }
} }
@ -29,7 +32,7 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental
{ {
string indent = new string('\t', stack.Count); string indent = new string('\t', stack.Count);
stack.Push(context); stack.Push(context);
Console.WriteLine(indent + "enter " + context); Print(indent + "enter " + context);
} }
void SetContext(Context context) void SetContext(Context context)
@ -37,12 +40,25 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental
PopContext(); PopContext();
PushContext(context); PushContext(context);
} }
void Print(string text)
{
Console.WriteLine(text);
output.AppendLine(text);
}
public string Output {
get { return output.ToString(); }
}
} }
public enum Context { public enum Context {
Global, Global,
Type, Type,
Member, Member,
IdentifierExpected IdentifierExpected,
Body,
Xml,
Debug
} }
} }

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

File diff suppressed because it is too large Load Diff

4
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.frame

@ -29,7 +29,7 @@ using System;
-->namespace -->namespace
public partial class Parser { public partial class ExpressionFinder {
-->constants -->constants
const bool T = true; const bool T = true;
const bool x = false; const bool x = false;
@ -38,7 +38,7 @@ public partial class Parser {
public ILexer lexer; public ILexer lexer;
public Errors errors; public Errors errors;
public Parser(ILexer lexer) public ExpressionFinder(ILexer lexer)
{ {
this.lexer = lexer; this.lexer = lexer;
this.errors = new Errors(); this.errors = new Errors();

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

@ -30,15 +30,16 @@ using System.Collections.Generic;
-->namespace -->namespace
partial class Parser { partial class ExpressionFinder {
-->constants -->constants
const bool T = true; const bool T = true;
const bool x = false; const bool x = false;
-->declarations -->declarations
readonly Stack<int> stateStack = new Stack<int>(); readonly Stack<int> stateStack = new Stack<int>();
bool nextTokenIsPotentialStartOfXmlMode = false;
public Parser() public ExpressionFinder()
{ {
stateStack.Push(-1); // required so that we don't crash when leaving the root production stateStack.Push(-1); // required so that we don't crash when leaving the root production
} }
@ -55,6 +56,7 @@ partial class Parser {
public void InformToken(Token t) public void InformToken(Token t)
{ {
nextTokenIsPotentialStartOfXmlMode = false;
-->informToken -->informToken
} }

58
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/ParserTests.cs

@ -7,29 +7,69 @@
using System; using System;
using System.IO;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Parser;
using VB = ICSharpCode.NRefactory.Parser.VB;
using ICSharpCode.NRefactory.Parser.VBNet.Experimental;
using NUnit.Framework; using NUnit.Framework;
namespace VBParserExperiment namespace VBParserExperiment.Tests
{ {
[TestFixture] [TestFixture]
public class ParserTests public class ParserTests
{ {
[Test] [Test]
public void TestMethod() public void SimpleGlobal()
{ {
// TODO: Add your test. RunTest(
@"Option Explicit",
@"enter Global
exit Global
"
);
} }
[TestFixtureSetUp] [Test]
public void Init() public void VariableWithXmlLiteral()
{ {
// TODO: Add Init code. RunTest(
@"Class Test
Public Sub New()
Dim x = <a>
End Sub
End Class
",
@"enter Global
enter Type
enter Member
enter IdentifierExpected
exit IdentifierExpected
enter Body
enter IdentifierExpected
exit IdentifierExpected
enter Xml
exit Xml
exit Body
exit Member
exit Type
exit Global
"
);
} }
[TestFixtureTearDown] void RunTest(string code, string expectedOutput)
public void Dispose()
{ {
// TODO: Add tear down code. ExpressionFinder p = new ExpressionFinder();
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new StringReader(code));
Token t;
do {
t = lexer.NextToken();
p.InformToken(t);
} while (t.Kind != VB.Tokens.EOF);
Assert.AreEqual(expectedOutput, p.Output);
} }
} }
} }

40
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/Program.cs

@ -16,38 +16,22 @@ namespace VBParserExperiment
{ {
class Program class Program
{ {
static string data = @"Option Explicit static string data = @"Class Test
Option Strict On Public Sub New()
Dim x = <a>
Imports System End Sub
Imports System.Linq End Class
Module Program
End Module
Namespace Test
Module Functions
Public Sub New()
End Sub
Public Sub Test(ByVal x As Integer)
End Sub
End Module
End Namespace
"; ";
public static void Main(string[] args) public static void Main(string[] args)
{ {
Parser p = new Parser(); ExpressionFinder p = new ExpressionFinder();
ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new StringReader(data)); ILexer lexer = ParserFactory.CreateLexer(SupportedLanguage.VBNet, new StringReader(data));
Token t; Token t;
do { do {
t = lexer.NextToken(); t = lexer.NextToken();
p.InformToken(t); p.InformToken(t);
} while (t.Kind != VB.Tokens.EOF); } while (t.Kind != VB.Tokens.EOF);
Console.ReadKey(true); Console.ReadKey(true);
} }

29
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/TokenTests.cs

@ -0,0 +1,29 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="siegfriedpammer@gmail.com" />
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.NRefactory.Parser;
using NUnit.Framework;
namespace VBParserExperiment
{
[TestFixture]
public class TokenTests
{
[Test]
public void TestMethod()
{
Assert.DoesNotThrow(
() => {
string text = new Token(71, 1, 1).ToString();
Console.WriteLine(text);
}
);
}
}
}

1
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/VBParserExperiment.csproj

@ -50,6 +50,7 @@
<Compile Include="ParserTests.cs" /> <Compile Include="ParserTests.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TokenTests.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\..\NRefactory.csproj"> <ProjectReference Include="..\..\..\..\..\NRefactory.csproj">

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

File diff suppressed because it is too large Load Diff

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

@ -8,6 +8,8 @@ using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute;
COMPILER VBNET COMPILER VBNET
$frameDir=../Frames
/* START AUTOGENERATED TOKENS SECTION */ /* START AUTOGENERATED TOKENS SECTION */
TOKENS TOKENS
/* ----- terminal classes ----- */ /* ----- terminal classes ----- */
@ -335,7 +337,7 @@ ImportClause<out Using u>
} }
.) .)
) | ( (. string prefix = null; .) ) | ( (. string prefix = null; .)
"<" Identifier /* TODO this is "xmlns" */ [ ":" Identifier (. prefix = t.val; .) ] "=" LiteralString /* TODO support single-quote xml strings */ (. u = new Using(t.literalValue as string, prefix); .) ">" "<" Identifier (. prefix = t.val; .) "=" LiteralString /* TODO support single-quote xml strings */ (. u = new Using(t.literalValue as string, prefix); .) ">"
) )
. .
@ -370,10 +372,11 @@ NamespaceMemberDecl
. .
/* 4.9.1 */ /* 4.9.1 */
TypeParameterList<List<TemplateDefinition> templates> TypeParameterList<. List<TemplateDefinition> templates .>
=(. (.
TemplateDefinition template; TemplateDefinition template;
.) .)
=
[ [
IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
"(" "Of" TypeParameter<out template> "(" "Of" TypeParameter<out template>
@ -425,7 +428,7 @@ TypeParameterConstraint<out TypeReference constraint>
. .
/* 6.4.2 */ /* 6.4.2 */
NonModuleDeclaration<ModifierList m, List<AttributeSection> attributes> NonModuleDeclaration<. ModifierList m, List<AttributeSection> attributes .>
(. (.
TypeReference typeRef = null; TypeReference typeRef = null;
List<TypeReference> baseInterfaces = null; List<TypeReference> baseInterfaces = null;
@ -762,7 +765,7 @@ EnumMemberDecl<out FieldDeclaration f>
EndOfStmt EndOfStmt
. .
ClassMemberDecl<ModifierList m, List<AttributeSection> attributes> = ClassMemberDecl<. ModifierList m, List<AttributeSection> attributes .> =
StructureMemberDecl<m, attributes> StructureMemberDecl<m, attributes>
. .
@ -776,7 +779,7 @@ ClassBaseType<out TypeReference typeRef>
. .
/* 7.6.1 */ /* 7.6.1 */
StructureMemberDecl<ModifierList m, List<AttributeSection> attributes> StructureMemberDecl<. ModifierList m, List<AttributeSection> attributes .>
(. (.
TypeReference type = null; TypeReference type = null;
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
@ -1370,7 +1373,7 @@ AccessorDecls<out PropertyGetRegion getBlock, out PropertySetRegion setBlock>
. .
/* 9.7.1 */ /* 9.7.1 */
GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attributes> GetAccessorDecl<. out PropertyGetRegion getBlock, List<AttributeSection> attributes .>
(. Statement stmt = null; Modifiers m; .) (. Statement stmt = null; Modifiers m; .)
= =
PropertyAccessorAccessModifier<out m> PropertyAccessorAccessModifier<out m>
@ -1386,7 +1389,7 @@ GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attribute
. .
/* 9.7.2 */ /* 9.7.2 */
SetAccessorDecl<out PropertySetRegion setBlock, List<AttributeSection> attributes> SetAccessorDecl<. out PropertySetRegion setBlock, List<AttributeSection> attributes .>
(. (.
Statement stmt = null; Statement stmt = null;
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
@ -1410,7 +1413,7 @@ SetAccessorDecl<out PropertySetRegion setBlock, List<AttributeSection> attribute
. .
/* 9.5 */ /* 9.5 */
ConstantDeclarator<List<VariableDeclaration> constantDeclaration> ConstantDeclarator<. List<VariableDeclaration> constantDeclaration .>
(. (.
Expression expr = null; Expression expr = null;
TypeReference type = null; TypeReference type = null;
@ -1429,13 +1432,13 @@ ConstantDeclarator<List<VariableDeclaration> constantDeclaration>
. .
/* 9.6 */ /* 9.6 */
VariableDeclarator<List<VariableDeclaration> fieldDeclaration> VariableDeclarator<. List<VariableDeclaration> fieldDeclaration .>
= =
Identifier (. string name = t.val; .) Identifier (. string name = t.val; .)
VariableDeclaratorPartAfterIdentifier<fieldDeclaration, name> VariableDeclaratorPartAfterIdentifier<fieldDeclaration, name>
. .
VariableDeclaratorPartAfterIdentifier<List<VariableDeclaration> fieldDeclaration, string name> VariableDeclaratorPartAfterIdentifier<. List<VariableDeclaration> fieldDeclaration, string name .>
(. (.
Expression expr = null; Expression expr = null;
TypeReference type = null; TypeReference type = null;
@ -1503,7 +1506,7 @@ VariableDeclaratorPartAfterIdentifier<List<VariableDeclaration> fieldDeclaration
. .
/* 6.8 */ /* 6.8 */
ArrayInitializationModifier<out List<Expression> arrayModifiers> ArrayInitializationModifier<. out List<Expression> arrayModifiers .>
(. (.
arrayModifiers = null; arrayModifiers = null;
.) = .) =
@ -1511,7 +1514,7 @@ ArrayInitializationModifier<out List<Expression> arrayModifiers>
. .
/* 7.5.4.3 */ /* 7.5.4.3 */
InitializationRankList<out List<Expression> rank> InitializationRankList<. out List<Expression> rank .>
(. (.
rank = new List<Expression>(); rank = new List<Expression>();
Expression expr = null; Expression expr = null;
@ -1558,7 +1561,7 @@ Charset<out CharsetModifier charsetModifier>
. .
/* 9.2.6 */ /* 9.2.6 */
HandlesClause<out List<string> handlesClause> HandlesClause<. out List<string> handlesClause .>
(. (.
handlesClause = new List<string>(); handlesClause = new List<string>();
string name; string name;
@ -1568,7 +1571,7 @@ HandlesClause<out List<string> handlesClause>
. .
/* 7.8. */ /* 7.8. */
InterfaceBase <out List<TypeReference> bases> InterfaceBase<. out List<TypeReference> bases .>
(. (.
TypeReference type; TypeReference type;
bases = new List<TypeReference>(); bases = new List<TypeReference>();
@ -1583,7 +1586,7 @@ InterfaceBase <out List<TypeReference> bases>
. .
/* 7.2 */ /* 7.2 */
TypeImplementsClause<out List<TypeReference> baseInterfaces> TypeImplementsClause<. out List<TypeReference> baseInterfaces .>
(. (.
baseInterfaces = new List<TypeReference>(); baseInterfaces = new List<TypeReference>();
TypeReference type = null; TypeReference type = null;
@ -1600,7 +1603,7 @@ TypeImplementsClause<out List<TypeReference> baseInterfaces>
. .
/* 9.1 */ /* 9.1 */
ImplementsClause<out List<InterfaceImplementation> baseInterfaces> ImplementsClause<. out List<InterfaceImplementation> baseInterfaces .>
(. (.
baseInterfaces = new List<InterfaceImplementation>(); baseInterfaces = new List<InterfaceImplementation>();
TypeReference type = null; TypeReference type = null;
@ -2059,7 +2062,7 @@ QueryExpr<out Expression expr>
.) .)
. .
FromOrAggregateQueryOperator<List<QueryExpressionClause> middleClauses> FromOrAggregateQueryOperator<. List<QueryExpressionClause> middleClauses .>
(. (.
QueryExpressionFromClause fromClause = null; QueryExpressionFromClause fromClause = null;
QueryExpressionAggregateClause aggregateClause = null; QueryExpressionAggregateClause aggregateClause = null;
@ -2070,7 +2073,7 @@ FromOrAggregateQueryOperator<List<QueryExpressionClause> middleClauses>
(. middleClauses.Add(aggregateClause); .) (. middleClauses.Add(aggregateClause); .)
. .
QueryOperator<List<QueryExpressionClause> middleClauses> QueryOperator<. List<QueryExpressionClause> middleClauses .>
(. (.
QueryExpressionJoinVBClause joinClause = null; QueryExpressionJoinVBClause joinClause = null;
QueryExpressionGroupVBClause groupByClause = null; QueryExpressionGroupVBClause groupByClause = null;
@ -2098,7 +2101,7 @@ QueryOperator<List<QueryExpressionClause> middleClauses>
(. middleClauses.Add(groupByClause); .) (. middleClauses.Add(groupByClause); .)
. .
OrderByQueryOperator<List<QueryExpressionClause> middleClauses> OrderByQueryOperator<. List<QueryExpressionClause> middleClauses .>
(. (.
QueryExpressionOrderClause orderClause = new QueryExpressionOrderClause(); QueryExpressionOrderClause orderClause = new QueryExpressionOrderClause();
orderClause.StartLocation = la.Location; orderClause.StartLocation = la.Location;
@ -2112,7 +2115,7 @@ OrderByQueryOperator<List<QueryExpressionClause> middleClauses>
.) .)
. .
OrderExpressionList<out List<QueryExpressionOrdering> orderings> OrderExpressionList<. out List<QueryExpressionOrdering> orderings .>
(. (.
orderings = new List<QueryExpressionOrdering>(); orderings = new List<QueryExpressionOrdering>();
QueryExpressionOrdering ordering = null; QueryExpressionOrdering ordering = null;
@ -2181,7 +2184,7 @@ FromQueryOperator<out QueryExpressionFromClause fromClause>
.) .)
. .
SelectQueryOperator<List<QueryExpressionClause> middleClauses> SelectQueryOperator<. List<QueryExpressionClause> middleClauses .>
(. (.
QueryExpressionSelectVBClause selectClause = new QueryExpressionSelectVBClause(); QueryExpressionSelectVBClause selectClause = new QueryExpressionSelectVBClause();
selectClause.StartLocation = la.Location; selectClause.StartLocation = la.Location;
@ -2193,7 +2196,7 @@ SelectQueryOperator<List<QueryExpressionClause> middleClauses>
.) .)
. .
DistinctQueryOperator<List<QueryExpressionClause> middleClauses> DistinctQueryOperator<. List<QueryExpressionClause> middleClauses .>
(. (.
QueryExpressionDistinctClause distinctClause = new QueryExpressionDistinctClause(); QueryExpressionDistinctClause distinctClause = new QueryExpressionDistinctClause();
distinctClause.StartLocation = la.Location; distinctClause.StartLocation = la.Location;
@ -2205,7 +2208,7 @@ DistinctQueryOperator<List<QueryExpressionClause> middleClauses>
.) .)
. .
WhereQueryOperator<List<QueryExpressionClause> middleClauses> WhereQueryOperator<. List<QueryExpressionClause> middleClauses .>
(. (.
QueryExpressionWhereClause whereClause = new QueryExpressionWhereClause(); QueryExpressionWhereClause whereClause = new QueryExpressionWhereClause();
whereClause.StartLocation = la.Location; whereClause.StartLocation = la.Location;
@ -2259,7 +2262,7 @@ AggregateQueryOperator<out QueryExpressionAggregateClause aggregateClause>
.) .)
. .
LetQueryOperator<List<QueryExpressionClause> middleClauses> LetQueryOperator<. List<QueryExpressionClause> middleClauses .>
(. (.
QueryExpressionLetVBClause letClause = new QueryExpressionLetVBClause(); QueryExpressionLetVBClause letClause = new QueryExpressionLetVBClause();
letClause.StartLocation = la.Location; letClause.StartLocation = la.Location;
@ -2271,7 +2274,7 @@ LetQueryOperator<List<QueryExpressionClause> middleClauses>
.) .)
. .
ExpressionRangeVariableDeclarationList<List<ExpressionRangeVariable> variables> ExpressionRangeVariableDeclarationList<. List<ExpressionRangeVariable> variables .>
(. (.
ExpressionRangeVariable variable = null; ExpressionRangeVariable variable = null;
.) = .) =
@ -2330,7 +2333,7 @@ JoinQueryOperator<out QueryExpressionJoinVBClause joinClause>
.) .)
. .
CollectionRangeVariableDeclarationList<List<CollectionRangeVariable> rangeVariables> CollectionRangeVariableDeclarationList<. List<CollectionRangeVariable> rangeVariables .>
(. CollectionRangeVariable variableDeclaration; .) (. CollectionRangeVariable variableDeclaration; .)
= =
CollectionRangeVariableDeclaration<out variableDeclaration> CollectionRangeVariableDeclaration<out variableDeclaration>
@ -2389,7 +2392,7 @@ MemberInitializer<out MemberInitializerExpression memberInitializer>
. .
/* 9.3.2 */ /* 9.3.2 */
ArgumentList<out List<Expression> arguments> ArgumentList<. out List<Expression> arguments .>
(. (.
arguments = new List<Expression>(); arguments = new List<Expression>();
Expression expr = null; Expression expr = null;
@ -2403,7 +2406,7 @@ ArgumentList<out List<Expression> arguments>
. .
/* argument list that hasn't decided if it is method call or array initialisation */ /* argument list that hasn't decided if it is method call or array initialisation */
NormalOrReDimArgumentList<out List<Expression> arguments, out bool canBeNormal, out bool canBeRedim> NormalOrReDimArgumentList<. out List<Expression> arguments, out bool canBeNormal, out bool canBeRedim .>
(. (.
arguments = new List<Expression>(); arguments = new List<Expression>();
canBeNormal = true; canBeRedim = !IsNamedAssign(); canBeNormal = true; canBeRedim = !IsNamedAssign();
@ -2558,7 +2561,7 @@ RankList<out int i>
. .
/* 7.12 */ /* 7.12 */
TypeArgumentList<List<TypeReference> typeArguments> TypeArgumentList<. List<TypeReference> typeArguments .>
(. (.
TypeReference typeref; TypeReference typeref;
.) = .) =
@ -2607,7 +2610,7 @@ Attribute<out ASTAttribute attribute>
. .
/* Spec, 5.2.2 */ /* Spec, 5.2.2 */
AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> named> AttributeArguments<. List<Expression> positional, List<NamedArgumentExpression> named .>
(. (.
bool nameFound = false; bool nameFound = false;
string name = ""; string name = "";
@ -2682,7 +2685,7 @@ AttributeSection<out AttributeSection section>
. .
/* 9.2.5 */ /* 9.2.5 */
FormalParameterList<List<ParameterDeclarationExpression> parameter> FormalParameterList<. List<ParameterDeclarationExpression> parameter .>
(. ParameterDeclarationExpression p; .) (. ParameterDeclarationExpression p; .)
= =
FormalParameter <out p> (. if (p != null) parameter.Add(p); .) FormalParameter <out p> (. if (p != null) parameter.Add(p); .)
@ -2729,7 +2732,7 @@ FormalParameter<out ParameterDeclarationExpression p>
. .
/* 10.1 */ /* 10.1 */
Block<out Statement stmt> Block<out Statement stmt>
= =
(. (.
BlockStatement blockStmt = new BlockStatement(); BlockStatement blockStmt = new BlockStatement();
@ -3096,7 +3099,7 @@ EmbeddedStatement<out Statement statement>
| LocalDeclarationStatement<out statement> | LocalDeclarationStatement<out statement>
. .
SingleLineStatementList<List<Statement> list> SingleLineStatementList<. List<Statement> list .>
(. Statement embeddedStatement = null; .) (. Statement embeddedStatement = null; .)
= =
( "End" (. embeddedStatement = new EndStatement(); .) ( "End" (. embeddedStatement = new EndStatement(); .)
@ -3227,7 +3230,7 @@ ResumeStatement<out ResumeStatement resumeStatement>
. .
/* 18.8.2 */ /* 18.8.2 */
CaseClauses<out List<CaseLabel> caseClauses> CaseClauses<. out List<CaseLabel> caseClauses .>
(. (.
caseClauses = new List<CaseLabel>(); caseClauses = new List<CaseLabel>();
CaseLabel caseClause = null; CaseLabel caseClause = null;
@ -3309,7 +3312,7 @@ TryStatement<out Statement tryStatement>
. .
/* 10.10.1.2 */ /* 10.10.1.2 */
CatchClauses<out List<CatchClause> catchClauses> CatchClauses<. out List<CatchClause> catchClauses .>
(. (.
catchClauses = new List<CatchClause>(); catchClauses = new List<CatchClause>();
TypeReference type = null; TypeReference type = null;
@ -3380,7 +3383,7 @@ IdentifierForFieldDeclaration =
IdentifierOrKeyword<out string name> IdentifierOrKeyword<out string name>
= =
(. lexer.NextToken(); name = t.val; .) ANY (. name = t.val; .)
. .
@ -3433,7 +3436,7 @@ MemberModifier<ModifierList m> =
| "Private" (.m.Add(Modifiers.Private, t.Location);.) | "Private" (.m.Add(Modifiers.Private, t.Location);.)
| "Protected" (.m.Add(Modifiers.Protected, t.Location);.) | "Protected" (.m.Add(Modifiers.Protected, t.Location);.)
| "Public" (.m.Add(Modifiers.Public, t.Location);.) | "Public" (.m.Add(Modifiers.Public, t.Location);.)
| "NotInheritable" (.m.Add(Modifiers.Sealed, t.Location);.) | "NotInheritable" (.m.Add(Modifiers.Sealed, t.Location);.)
| "NotOverridable" (.m.Add(Modifiers.Sealed, t.Location);.) | "NotOverridable" (.m.Add(Modifiers.Sealed, t.Location);.)
| "Shared" (.m.Add(Modifiers.Static, t.Location);.) | "Shared" (.m.Add(Modifiers.Static, t.Location);.)
| "Overridable" (.m.Add(Modifiers.Virtual, t.Location);.) | "Overridable" (.m.Add(Modifiers.Virtual, t.Location);.)

2
src/Libraries/NRefactory/Project/Src/Visitors/AbstractASTVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.4927 // Runtime Version:4.0.30319.1
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

2
src/Libraries/NRefactory/Project/Src/Visitors/AbstractAstTransformer.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.4927 // Runtime Version:4.0.30319.1
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

2
src/Libraries/NRefactory/Project/Src/Visitors/NodeTrackingAstVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.4927 // Runtime Version:4.0.30319.1
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

2
src/Libraries/NRefactory/Project/Src/Visitors/NotImplementedAstVisitor.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.4927 // Runtime Version:4.0.30319.1
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

311
src/Libraries/NRefactory/Test/Lexer/CSharp/LexerTests.cs

@ -1,10 +1,4 @@
// <file> // this file was autogenerated by a tool.
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="unknown"/>
// <version>$Revision$</version>
// </file>
using System; using System;
using System.IO; using System.IO;
using NUnit.Framework; using NUnit.Framework;
@ -344,557 +338,676 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
Assert.AreEqual(Tokens.LambdaArrow, lexer.NextToken().Kind); Assert.AreEqual(Tokens.LambdaArrow, lexer.NextToken().Kind);
} }
[Test()] [Test]
public void TestAbstract() public void TestAbstract()
{ {
ILexer lexer = GenerateLexer(new StringReader("abstract")); ILexer lexer = GenerateLexer(new StringReader("abstract"));
Assert.AreEqual(Tokens.Abstract, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Abstract, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestAs() public void TestAs()
{ {
ILexer lexer = GenerateLexer(new StringReader("as")); ILexer lexer = GenerateLexer(new StringReader("as"));
Assert.AreEqual(Tokens.As, lexer.NextToken().Kind); Assert.AreEqual(Tokens.As, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestBase() public void TestBase()
{ {
ILexer lexer = GenerateLexer(new StringReader("base")); ILexer lexer = GenerateLexer(new StringReader("base"));
Assert.AreEqual(Tokens.Base, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Base, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestBool() public void TestBool()
{ {
ILexer lexer = GenerateLexer(new StringReader("bool")); ILexer lexer = GenerateLexer(new StringReader("bool"));
Assert.AreEqual(Tokens.Bool, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Bool, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestBreak() public void TestBreak()
{ {
ILexer lexer = GenerateLexer(new StringReader("break")); ILexer lexer = GenerateLexer(new StringReader("break"));
Assert.AreEqual(Tokens.Break, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Break, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestByte() public void TestByte()
{ {
ILexer lexer = GenerateLexer(new StringReader("byte")); ILexer lexer = GenerateLexer(new StringReader("byte"));
Assert.AreEqual(Tokens.Byte, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Byte, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestCase() public void TestCase()
{ {
ILexer lexer = GenerateLexer(new StringReader("case")); ILexer lexer = GenerateLexer(new StringReader("case"));
Assert.AreEqual(Tokens.Case, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Case, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestCatch() public void TestCatch()
{ {
ILexer lexer = GenerateLexer(new StringReader("catch")); ILexer lexer = GenerateLexer(new StringReader("catch"));
Assert.AreEqual(Tokens.Catch, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Catch, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestChar() public void TestChar()
{ {
ILexer lexer = GenerateLexer(new StringReader("char")); ILexer lexer = GenerateLexer(new StringReader("char"));
Assert.AreEqual(Tokens.Char, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Char, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestChecked() public void TestChecked()
{ {
ILexer lexer = GenerateLexer(new StringReader("checked")); ILexer lexer = GenerateLexer(new StringReader("checked"));
Assert.AreEqual(Tokens.Checked, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Checked, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestClass() public void TestClass()
{ {
ILexer lexer = GenerateLexer(new StringReader("class")); ILexer lexer = GenerateLexer(new StringReader("class"));
Assert.AreEqual(Tokens.Class, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Class, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestConst() public void TestConst()
{ {
ILexer lexer = GenerateLexer(new StringReader("const")); ILexer lexer = GenerateLexer(new StringReader("const"));
Assert.AreEqual(Tokens.Const, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Const, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestContinue() public void TestContinue()
{ {
ILexer lexer = GenerateLexer(new StringReader("continue")); ILexer lexer = GenerateLexer(new StringReader("continue"));
Assert.AreEqual(Tokens.Continue, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Continue, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestDecimal() public void TestDecimal()
{ {
ILexer lexer = GenerateLexer(new StringReader("decimal")); ILexer lexer = GenerateLexer(new StringReader("decimal"));
Assert.AreEqual(Tokens.Decimal, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Decimal, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestDefault() public void TestDefault()
{ {
ILexer lexer = GenerateLexer(new StringReader("default")); ILexer lexer = GenerateLexer(new StringReader("default"));
Assert.AreEqual(Tokens.Default, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Default, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestDelegate() public void TestDelegate()
{ {
ILexer lexer = GenerateLexer(new StringReader("delegate")); ILexer lexer = GenerateLexer(new StringReader("delegate"));
Assert.AreEqual(Tokens.Delegate, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Delegate, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestDo() public void TestDo()
{ {
ILexer lexer = GenerateLexer(new StringReader("do")); ILexer lexer = GenerateLexer(new StringReader("do"));
Assert.AreEqual(Tokens.Do, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Do, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestDouble() public void TestDouble()
{ {
ILexer lexer = GenerateLexer(new StringReader("double")); ILexer lexer = GenerateLexer(new StringReader("double"));
Assert.AreEqual(Tokens.Double, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Double, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestElse() public void TestElse()
{ {
ILexer lexer = GenerateLexer(new StringReader("else")); ILexer lexer = GenerateLexer(new StringReader("else"));
Assert.AreEqual(Tokens.Else, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Else, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestEnum() public void TestEnum()
{ {
ILexer lexer = GenerateLexer(new StringReader("enum")); ILexer lexer = GenerateLexer(new StringReader("enum"));
Assert.AreEqual(Tokens.Enum, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Enum, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestEvent() public void TestEvent()
{ {
ILexer lexer = GenerateLexer(new StringReader("event")); ILexer lexer = GenerateLexer(new StringReader("event"));
Assert.AreEqual(Tokens.Event, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Event, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestExplicit() public void TestExplicit()
{ {
ILexer lexer = GenerateLexer(new StringReader("explicit")); ILexer lexer = GenerateLexer(new StringReader("explicit"));
Assert.AreEqual(Tokens.Explicit, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Explicit, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestExtern() public void TestExtern()
{ {
ILexer lexer = GenerateLexer(new StringReader("extern")); ILexer lexer = GenerateLexer(new StringReader("extern"));
Assert.AreEqual(Tokens.Extern, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Extern, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestFalse() public void TestFalse()
{ {
ILexer lexer = GenerateLexer(new StringReader("false")); ILexer lexer = GenerateLexer(new StringReader("false"));
Assert.AreEqual(Tokens.False, lexer.NextToken().Kind); Assert.AreEqual(Tokens.False, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestFinally() public void TestFinally()
{ {
ILexer lexer = GenerateLexer(new StringReader("finally")); ILexer lexer = GenerateLexer(new StringReader("finally"));
Assert.AreEqual(Tokens.Finally, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Finally, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestFixed() public void TestFixed()
{ {
ILexer lexer = GenerateLexer(new StringReader("fixed")); ILexer lexer = GenerateLexer(new StringReader("fixed"));
Assert.AreEqual(Tokens.Fixed, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Fixed, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestFloat() public void TestFloat()
{ {
ILexer lexer = GenerateLexer(new StringReader("float")); ILexer lexer = GenerateLexer(new StringReader("float"));
Assert.AreEqual(Tokens.Float, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Float, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestFor() public void TestFor()
{ {
ILexer lexer = GenerateLexer(new StringReader("for")); ILexer lexer = GenerateLexer(new StringReader("for"));
Assert.AreEqual(Tokens.For, lexer.NextToken().Kind); Assert.AreEqual(Tokens.For, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestForeach() public void TestForeach()
{ {
ILexer lexer = GenerateLexer(new StringReader("foreach")); ILexer lexer = GenerateLexer(new StringReader("foreach"));
Assert.AreEqual(Tokens.Foreach, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Foreach, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestGoto() public void TestGoto()
{ {
ILexer lexer = GenerateLexer(new StringReader("goto")); ILexer lexer = GenerateLexer(new StringReader("goto"));
Assert.AreEqual(Tokens.Goto, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Goto, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestIf() public void TestIf()
{ {
ILexer lexer = GenerateLexer(new StringReader("if")); ILexer lexer = GenerateLexer(new StringReader("if"));
Assert.AreEqual(Tokens.If, lexer.NextToken().Kind); Assert.AreEqual(Tokens.If, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestImplicit() public void TestImplicit()
{ {
ILexer lexer = GenerateLexer(new StringReader("implicit")); ILexer lexer = GenerateLexer(new StringReader("implicit"));
Assert.AreEqual(Tokens.Implicit, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Implicit, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestIn() public void TestIn()
{ {
ILexer lexer = GenerateLexer(new StringReader("in")); ILexer lexer = GenerateLexer(new StringReader("in"));
Assert.AreEqual(Tokens.In, lexer.NextToken().Kind); Assert.AreEqual(Tokens.In, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestInt() public void TestInt()
{ {
ILexer lexer = GenerateLexer(new StringReader("int")); ILexer lexer = GenerateLexer(new StringReader("int"));
Assert.AreEqual(Tokens.Int, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Int, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestInterface() public void TestInterface()
{ {
ILexer lexer = GenerateLexer(new StringReader("interface")); ILexer lexer = GenerateLexer(new StringReader("interface"));
Assert.AreEqual(Tokens.Interface, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Interface, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestInternal() public void TestInternal()
{ {
ILexer lexer = GenerateLexer(new StringReader("internal")); ILexer lexer = GenerateLexer(new StringReader("internal"));
Assert.AreEqual(Tokens.Internal, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Internal, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestIs() public void TestIs()
{ {
ILexer lexer = GenerateLexer(new StringReader("is")); ILexer lexer = GenerateLexer(new StringReader("is"));
Assert.AreEqual(Tokens.Is, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Is, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestLock() public void TestLock()
{ {
ILexer lexer = GenerateLexer(new StringReader("lock")); ILexer lexer = GenerateLexer(new StringReader("lock"));
Assert.AreEqual(Tokens.Lock, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Lock, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestLong() public void TestLong()
{ {
ILexer lexer = GenerateLexer(new StringReader("long")); ILexer lexer = GenerateLexer(new StringReader("long"));
Assert.AreEqual(Tokens.Long, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Long, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestNamespace() public void TestNamespace()
{ {
ILexer lexer = GenerateLexer(new StringReader("namespace")); ILexer lexer = GenerateLexer(new StringReader("namespace"));
Assert.AreEqual(Tokens.Namespace, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Namespace, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestNew() public void TestNew()
{ {
ILexer lexer = GenerateLexer(new StringReader("new")); ILexer lexer = GenerateLexer(new StringReader("new"));
Assert.AreEqual(Tokens.New, lexer.NextToken().Kind); Assert.AreEqual(Tokens.New, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestNull() public void TestNull()
{ {
ILexer lexer = GenerateLexer(new StringReader("null")); ILexer lexer = GenerateLexer(new StringReader("null"));
Assert.AreEqual(Tokens.Null, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Null, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestObject() public void TestObject()
{ {
ILexer lexer = GenerateLexer(new StringReader("object")); ILexer lexer = GenerateLexer(new StringReader("object"));
Assert.AreEqual(Tokens.Object, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Object, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestOperator() public void TestOperator()
{ {
ILexer lexer = GenerateLexer(new StringReader("operator")); ILexer lexer = GenerateLexer(new StringReader("operator"));
Assert.AreEqual(Tokens.Operator, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Operator, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestOut() public void TestOut()
{ {
ILexer lexer = GenerateLexer(new StringReader("out")); ILexer lexer = GenerateLexer(new StringReader("out"));
Assert.AreEqual(Tokens.Out, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Out, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestOverride() public void TestOverride()
{ {
ILexer lexer = GenerateLexer(new StringReader("override")); ILexer lexer = GenerateLexer(new StringReader("override"));
Assert.AreEqual(Tokens.Override, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Override, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestParams() public void TestParams()
{ {
ILexer lexer = GenerateLexer(new StringReader("params")); ILexer lexer = GenerateLexer(new StringReader("params"));
Assert.AreEqual(Tokens.Params, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Params, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestPrivate() public void TestPrivate()
{ {
ILexer lexer = GenerateLexer(new StringReader("private")); ILexer lexer = GenerateLexer(new StringReader("private"));
Assert.AreEqual(Tokens.Private, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Private, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestProtected() public void TestProtected()
{ {
ILexer lexer = GenerateLexer(new StringReader("protected")); ILexer lexer = GenerateLexer(new StringReader("protected"));
Assert.AreEqual(Tokens.Protected, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Protected, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestPublic() public void TestPublic()
{ {
ILexer lexer = GenerateLexer(new StringReader("public")); ILexer lexer = GenerateLexer(new StringReader("public"));
Assert.AreEqual(Tokens.Public, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Public, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestReadonly() public void TestReadonly()
{ {
ILexer lexer = GenerateLexer(new StringReader("readonly")); ILexer lexer = GenerateLexer(new StringReader("readonly"));
Assert.AreEqual(Tokens.Readonly, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Readonly, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestRef() public void TestRef()
{ {
ILexer lexer = GenerateLexer(new StringReader("ref")); ILexer lexer = GenerateLexer(new StringReader("ref"));
Assert.AreEqual(Tokens.Ref, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Ref, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestReturn() public void TestReturn()
{ {
ILexer lexer = GenerateLexer(new StringReader("return")); ILexer lexer = GenerateLexer(new StringReader("return"));
Assert.AreEqual(Tokens.Return, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Return, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestSbyte() public void TestSbyte()
{ {
ILexer lexer = GenerateLexer(new StringReader("sbyte")); ILexer lexer = GenerateLexer(new StringReader("sbyte"));
Assert.AreEqual(Tokens.Sbyte, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Sbyte, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestSealed() public void TestSealed()
{ {
ILexer lexer = GenerateLexer(new StringReader("sealed")); ILexer lexer = GenerateLexer(new StringReader("sealed"));
Assert.AreEqual(Tokens.Sealed, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Sealed, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestShort() public void TestShort()
{ {
ILexer lexer = GenerateLexer(new StringReader("short")); ILexer lexer = GenerateLexer(new StringReader("short"));
Assert.AreEqual(Tokens.Short, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Short, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestSizeof() public void TestSizeof()
{ {
ILexer lexer = GenerateLexer(new StringReader("sizeof")); ILexer lexer = GenerateLexer(new StringReader("sizeof"));
Assert.AreEqual(Tokens.Sizeof, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Sizeof, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestStackalloc() public void TestStackalloc()
{ {
ILexer lexer = GenerateLexer(new StringReader("stackalloc")); ILexer lexer = GenerateLexer(new StringReader("stackalloc"));
Assert.AreEqual(Tokens.Stackalloc, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Stackalloc, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestStatic() public void TestStatic()
{ {
ILexer lexer = GenerateLexer(new StringReader("static")); ILexer lexer = GenerateLexer(new StringReader("static"));
Assert.AreEqual(Tokens.Static, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Static, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestString() public void TestString()
{ {
ILexer lexer = GenerateLexer(new StringReader("string")); ILexer lexer = GenerateLexer(new StringReader("string"));
Assert.AreEqual(Tokens.String, lexer.NextToken().Kind); Assert.AreEqual(Tokens.String, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestStruct() public void TestStruct()
{ {
ILexer lexer = GenerateLexer(new StringReader("struct")); ILexer lexer = GenerateLexer(new StringReader("struct"));
Assert.AreEqual(Tokens.Struct, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Struct, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestSwitch() public void TestSwitch()
{ {
ILexer lexer = GenerateLexer(new StringReader("switch")); ILexer lexer = GenerateLexer(new StringReader("switch"));
Assert.AreEqual(Tokens.Switch, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Switch, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestThis() public void TestThis()
{ {
ILexer lexer = GenerateLexer(new StringReader("this")); ILexer lexer = GenerateLexer(new StringReader("this"));
Assert.AreEqual(Tokens.This, lexer.NextToken().Kind); Assert.AreEqual(Tokens.This, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestThrow() public void TestThrow()
{ {
ILexer lexer = GenerateLexer(new StringReader("throw")); ILexer lexer = GenerateLexer(new StringReader("throw"));
Assert.AreEqual(Tokens.Throw, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Throw, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestTrue() public void TestTrue()
{ {
ILexer lexer = GenerateLexer(new StringReader("true")); ILexer lexer = GenerateLexer(new StringReader("true"));
Assert.AreEqual(Tokens.True, lexer.NextToken().Kind); Assert.AreEqual(Tokens.True, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestTry() public void TestTry()
{ {
ILexer lexer = GenerateLexer(new StringReader("try")); ILexer lexer = GenerateLexer(new StringReader("try"));
Assert.AreEqual(Tokens.Try, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Try, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestTypeof() public void TestTypeof()
{ {
ILexer lexer = GenerateLexer(new StringReader("typeof")); ILexer lexer = GenerateLexer(new StringReader("typeof"));
Assert.AreEqual(Tokens.Typeof, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Typeof, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestUint() public void TestUint()
{ {
ILexer lexer = GenerateLexer(new StringReader("uint")); ILexer lexer = GenerateLexer(new StringReader("uint"));
Assert.AreEqual(Tokens.Uint, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Uint, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestUlong() public void TestUlong()
{ {
ILexer lexer = GenerateLexer(new StringReader("ulong")); ILexer lexer = GenerateLexer(new StringReader("ulong"));
Assert.AreEqual(Tokens.Ulong, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Ulong, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestUnchecked() public void TestUnchecked()
{ {
ILexer lexer = GenerateLexer(new StringReader("unchecked")); ILexer lexer = GenerateLexer(new StringReader("unchecked"));
Assert.AreEqual(Tokens.Unchecked, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Unchecked, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestUnsafe() public void TestUnsafe()
{ {
ILexer lexer = GenerateLexer(new StringReader("unsafe")); ILexer lexer = GenerateLexer(new StringReader("unsafe"));
Assert.AreEqual(Tokens.Unsafe, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Unsafe, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestUshort() public void TestUshort()
{ {
ILexer lexer = GenerateLexer(new StringReader("ushort")); ILexer lexer = GenerateLexer(new StringReader("ushort"));
Assert.AreEqual(Tokens.Ushort, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Ushort, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestUsing() public void TestUsing()
{ {
ILexer lexer = GenerateLexer(new StringReader("using")); ILexer lexer = GenerateLexer(new StringReader("using"));
Assert.AreEqual(Tokens.Using, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Using, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestVirtual() public void TestVirtual()
{ {
ILexer lexer = GenerateLexer(new StringReader("virtual")); ILexer lexer = GenerateLexer(new StringReader("virtual"));
Assert.AreEqual(Tokens.Virtual, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Virtual, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestVoid() public void TestVoid()
{ {
ILexer lexer = GenerateLexer(new StringReader("void")); ILexer lexer = GenerateLexer(new StringReader("void"));
Assert.AreEqual(Tokens.Void, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Void, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestVolatile() public void TestVolatile()
{ {
ILexer lexer = GenerateLexer(new StringReader("volatile")); ILexer lexer = GenerateLexer(new StringReader("volatile"));
Assert.AreEqual(Tokens.Volatile, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Volatile, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestWhile() public void TestWhile()
{ {
ILexer lexer = GenerateLexer(new StringReader("while")); ILexer lexer = GenerateLexer(new StringReader("while"));
Assert.AreEqual(Tokens.While, lexer.NextToken().Kind); Assert.AreEqual(Tokens.While, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestPartial() public void TestPartial()
{ {
ILexer lexer = GenerateLexer(new StringReader("partial")); ILexer lexer = GenerateLexer(new StringReader("partial"));
Assert.AreEqual(Tokens.Partial, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Partial, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestWhere() public void TestWhere()
{ {
ILexer lexer = GenerateLexer(new StringReader("where")); ILexer lexer = GenerateLexer(new StringReader("where"));
Assert.AreEqual(Tokens.Where, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Where, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestGet() public void TestGet()
{ {
ILexer lexer = GenerateLexer(new StringReader("get")); ILexer lexer = GenerateLexer(new StringReader("get"));
Assert.AreEqual(Tokens.Get, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Get, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestSet() public void TestSet()
{ {
ILexer lexer = GenerateLexer(new StringReader("set")); ILexer lexer = GenerateLexer(new StringReader("set"));
Assert.AreEqual(Tokens.Set, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Set, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestAdd() public void TestAdd()
{ {
ILexer lexer = GenerateLexer(new StringReader("add")); ILexer lexer = GenerateLexer(new StringReader("add"));
Assert.AreEqual(Tokens.Add, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Add, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestRemove() public void TestRemove()
{ {
ILexer lexer = GenerateLexer(new StringReader("remove")); ILexer lexer = GenerateLexer(new StringReader("remove"));
Assert.AreEqual(Tokens.Remove, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Remove, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestYield() public void TestYield()
{ {
ILexer lexer = GenerateLexer(new StringReader("yield")); ILexer lexer = GenerateLexer(new StringReader("yield"));
Assert.AreEqual(Tokens.Yield, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Yield, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestSelect() public void TestSelect()
{ {
ILexer lexer = GenerateLexer(new StringReader("select")); ILexer lexer = GenerateLexer(new StringReader("select"));
Assert.AreEqual(Tokens.Select, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Select, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestGroup() public void TestGroup()
{ {
ILexer lexer = GenerateLexer(new StringReader("group")); ILexer lexer = GenerateLexer(new StringReader("group"));
Assert.AreEqual(Tokens.Group, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Group, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestBy() public void TestBy()
{ {
ILexer lexer = GenerateLexer(new StringReader("by")); ILexer lexer = GenerateLexer(new StringReader("by"));
Assert.AreEqual(Tokens.By, lexer.NextToken().Kind); Assert.AreEqual(Tokens.By, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestInto() public void TestInto()
{ {
ILexer lexer = GenerateLexer(new StringReader("into")); ILexer lexer = GenerateLexer(new StringReader("into"));
Assert.AreEqual(Tokens.Into, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Into, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestFrom() public void TestFrom()
{ {
ILexer lexer = GenerateLexer(new StringReader("from")); ILexer lexer = GenerateLexer(new StringReader("from"));
Assert.AreEqual(Tokens.From, lexer.NextToken().Kind); Assert.AreEqual(Tokens.From, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestAscending() public void TestAscending()
{ {
ILexer lexer = GenerateLexer(new StringReader("ascending")); ILexer lexer = GenerateLexer(new StringReader("ascending"));
Assert.AreEqual(Tokens.Ascending, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Ascending, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestDescending() public void TestDescending()
{ {
ILexer lexer = GenerateLexer(new StringReader("descending")); ILexer lexer = GenerateLexer(new StringReader("descending"));
Assert.AreEqual(Tokens.Descending, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Descending, lexer.NextToken().Kind);
} }
[Test()]
[Test]
public void TestOrderby() public void TestOrderby()
{ {
ILexer lexer = GenerateLexer(new StringReader("orderby")); ILexer lexer = GenerateLexer(new StringReader("orderby"));
Assert.AreEqual(Tokens.Orderby, lexer.NextToken().Kind); Assert.AreEqual(Tokens.Orderby, lexer.NextToken().Kind);
} }
[Test]
public void TestLet()
{
ILexer lexer = GenerateLexer(new StringReader("let"));
Assert.AreEqual(Tokens.Let, lexer.NextToken().Kind);
}
[Test]
public void TestJoin()
{
ILexer lexer = GenerateLexer(new StringReader("join"));
Assert.AreEqual(Tokens.Join, lexer.NextToken().Kind);
}
[Test]
public void TestOn()
{
ILexer lexer = GenerateLexer(new StringReader("on"));
Assert.AreEqual(Tokens.On, lexer.NextToken().Kind);
}
[Test]
public void TestEquals()
{
ILexer lexer = GenerateLexer(new StringReader("equals"));
Assert.AreEqual(Tokens.Equals, lexer.NextToken().Kind);
}
} }
} }

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

File diff suppressed because it is too large Load Diff

6
src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

@ -547,5 +547,11 @@ End Using");
{ {
TestTypeMember("Dim WithEvents a As Button"); TestTypeMember("Dim WithEvents a As Button");
} }
[Test]
public void FriendWithEventsField()
{
TestTypeMember("Friend WithEvents Button1 As System.Windows.Forms.Button");
}
} }
} }

Loading…
Cancel
Save