Browse Source

NRefactory.VB: cleaned Parser API and removed old C# constructs

newNRvisualizers
Siegfried Pammer 16 years ago
parent
commit
561062526a
  1. 8
      NRefactory.sln
  2. 66
      VB/Project/Dom/Generated.cs
  3. 2
      VB/Project/IAstVisitor.cs
  4. 19
      VB/Project/ICSharpCode.NRefactory.VB.csproj
  5. 106
      VB/Project/Parser/AbstractParser.cs
  6. 50
      VB/Project/Parser/Frames/Parser.frame
  7. 202
      VB/Project/Parser/Frames/Scanner.frame
  8. BIN
      VB/Project/Parser/Frames/SharpCoco.exe
  9. 38
      VB/Project/Parser/IParser.cs
  10. 4
      VB/Project/Parser/ParamModifierList.cs
  11. 190
      VB/Project/Parser/Parser.cs
  12. 119
      VB/Project/Parser/Parser.frame
  13. 98
      VB/Project/Parser/VBParser.cs
  14. 14
      VB/Project/Parser/gen.bat
  15. 18
      VB/Project/Parser/gen.sh
  16. 1398
      VB/Project/Parser/trace.txt
  17. 158
      VB/Project/Parser/vb.atg
  18. 8
      VB/Project/ParserFactory.cs
  19. 30
      VB/Project/PrettyPrinter/VBNet/VBNetOutputVisitor.cs
  20. 2
      VB/Project/Properties/AssemblyInfo.cs
  21. 2
      VB/Project/SnippetParser.cs
  22. 11
      VB/Project/Visitors/AbstractASTVisitor.cs
  23. 21
      VB/Project/Visitors/AbstractAstTransformer.cs
  24. 10
      VB/Project/Visitors/LookupTableVisitor.cs
  25. 11
      VB/Project/Visitors/NodeTrackingAstVisitor.cs
  26. 4
      VB/Project/Visitors/NotImplementedAstVisitor.cs
  27. 8
      VB/Test/Output/SpecialOutputVisitorTest.cs
  28. 9
      VB/Test/Output/VBNet/VBNetOutputTest.cs
  29. 2
      VB/Test/Parser/GlobalScope/OptionDeclarationTests.cs
  30. 18
      VB/Test/Parser/GlobalScope/UsingDeclarationTests.cs
  31. 4
      VB/Test/Parser/ParseUtil.cs

8
NRefactory.sln

@ -12,11 +12,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VB", "VB", "{61F5C042-086B-
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryASTGenerator", "VB\NRefactoryASTGenerator\NRefactoryASTGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.VB.Tests", "VB\Test\ICSharpCode.NRefactory.VB.Tests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.VB", "VB\Project\ICSharpCode.NRefactory.VB.csproj", "{7B82B671-419F-45F4-B778-D9286F996EFA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.VB", "VB\Project\ICSharpCode.NRefactory.VB.csproj", "{7B82B671-419F-45F4-B778-D9286F996EFA}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.VB.Tests", "VB\Test\ICSharpCode.NRefactory.VB.Tests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryASTGenerator", "VB\NRefactoryASTGenerator\NRefactoryASTGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj", "{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj", "{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}"
EndProject EndProject
@ -64,8 +64,8 @@ Global
{870115DD-960A-4406-A6B9-600BCDC36A03}.Release|x86.ActiveCfg = Release|Any CPU {870115DD-960A-4406-A6B9-600BCDC36A03}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{870115DD-960A-4406-A6B9-600BCDC36A03} = {61F5C042-086B-45DD-999E-01B1A78A4619}
{7B82B671-419F-45F4-B778-D9286F996EFA} = {61F5C042-086B-45DD-999E-01B1A78A4619}
{B22522AA-B5BF-4A58-AC6D-D4B45805521F} = {61F5C042-086B-45DD-999E-01B1A78A4619} {B22522AA-B5BF-4A58-AC6D-D4B45805521F} = {61F5C042-086B-45DD-999E-01B1A78A4619}
{7B82B671-419F-45F4-B778-D9286F996EFA} = {61F5C042-086B-45DD-999E-01B1A78A4619}
{870115DD-960A-4406-A6B9-600BCDC36A03} = {61F5C042-086B-45DD-999E-01B1A78A4619}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

66
VB/Project/Dom/Generated.cs

@ -80,56 +80,6 @@ namespace ICSharpCode.NRefactory.VB.Dom {
} }
} }
public class AnonymousMethodExpression : Expression {
List<ParameterDeclarationExpression> parameters;
BlockStatement body;
bool hasParameterList;
public List<ParameterDeclarationExpression> Parameters {
get {
return parameters;
}
set {
parameters = value ?? new List<ParameterDeclarationExpression>();
}
}
public BlockStatement Body {
get {
return body;
}
set {
body = value ?? BlockStatement.Null;
if (!body.IsNull) body.Parent = this;
}
}
public bool HasParameterList {
get {
return hasParameterList;
}
set {
hasParameterList = value;
}
}
public AnonymousMethodExpression() {
parameters = new List<ParameterDeclarationExpression>();
body = BlockStatement.Null;
}
public override object AcceptVisitor(IAstVisitor visitor, object data) {
return visitor.VisitAnonymousMethodExpression(this, data);
}
public override string ToString() {
return string.Format("[AnonymousMethodExpression Parameters={0} Body={1} HasParameterList={2}]", GetCollectionString(Parameters), Body, HasParameterList);
}
}
public class ArrayCreateExpression : Expression { public class ArrayCreateExpression : Expression {
TypeReference createType; TypeReference createType;
@ -2192,15 +2142,15 @@ namespace ICSharpCode.NRefactory.VB.Dom {
if (trueStatement != null) trueStatement.Parent = this; if (trueStatement != null) trueStatement.Parent = this;
} }
public bool HasElseIfSections { public bool HasElseStatements {
get { get {
return elseIfSections.Count > 0; return falseStatement.Count > 0;
} }
} }
public bool HasElseStatements { public bool HasElseIfSections {
get { get {
return falseStatement.Count > 0; return elseIfSections.Count > 0;
} }
} }
@ -5083,15 +5033,15 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L
attributes = new List<XmlExpression>(); attributes = new List<XmlExpression>();
} }
public bool NameIsExpression { public bool IsExpression {
get { get {
return !nameExpression.IsNull; return !content.IsNull;
} }
} }
public bool IsExpression { public bool NameIsExpression {
get { get {
return !content.IsNull; return !nameExpression.IsNull;
} }
} }

2
VB/Project/IAstVisitor.cs

@ -19,8 +19,6 @@ namespace ICSharpCode.NRefactory.VB {
object VisitAddressOfExpression(AddressOfExpression addressOfExpression, object data); object VisitAddressOfExpression(AddressOfExpression addressOfExpression, object data);
object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data);
object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data); object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data);
object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data); object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data);

19
VB/Project/ICSharpCode.NRefactory.VB.csproj

@ -85,16 +85,16 @@
<Compile Include="Location.cs" /> <Compile Include="Location.cs" />
<Compile Include="OperatorPrecedence.cs" /> <Compile Include="OperatorPrecedence.cs" />
<Compile Include="ParserFactory.cs" /> <Compile Include="ParserFactory.cs" />
<Compile Include="Parser\AbstractParser.cs" />
<Compile Include="Parser\Errors.cs" /> <Compile Include="Parser\Errors.cs" />
<Compile Include="Parser\IParser.cs" />
<Compile Include="Parser\ModifierList.cs" /> <Compile Include="Parser\ModifierList.cs" />
<Compile Include="Parser\ParamModifierList.cs" /> <Compile Include="Parser\ParamModifierList.cs" />
<Compile Include="Parser\Parser.cs" /> <Compile Include="Parser\Parser.cs">
<DependentUpon>vb.atg</DependentUpon>
</Compile>
<None Include="Parser\trace.txt"> <None Include="Parser\trace.txt">
<DependentUpon>vb.atg</DependentUpon> <DependentUpon>vb.atg</DependentUpon>
</None> </None>
<Compile Include="Parser\VBNetParser.cs" /> <Compile Include="Parser\VBParser.cs" />
<Compile Include="PrettyPrinter\AbstractOutputFormatter.cs" /> <Compile Include="PrettyPrinter\AbstractOutputFormatter.cs" />
<Compile Include="PrettyPrinter\AbstractPrettyPrintOptions.cs" /> <Compile Include="PrettyPrinter\AbstractPrettyPrintOptions.cs" />
<Compile Include="PrettyPrinter\IOutputAstVisitor.cs" /> <Compile Include="PrettyPrinter\IOutputAstVisitor.cs" />
@ -123,7 +123,6 @@
<Folder Include="Lexer" /> <Folder Include="Lexer" />
<Folder Include="Lexer\Special" /> <Folder Include="Lexer\Special" />
<Folder Include="Parser" /> <Folder Include="Parser" />
<Folder Include="Parser\Frames" />
<Folder Include="PrettyPrinter" /> <Folder Include="PrettyPrinter" />
<Folder Include="PrettyPrinter\VBNet" /> <Folder Include="PrettyPrinter\VBNet" />
<Folder Include="Visitors" /> <Folder Include="Visitors" />
@ -143,17 +142,13 @@
<None Include="Lexer\PushParser.frame"> <None Include="Lexer\PushParser.frame">
<DependentUpon>ExpressionFinder.atg</DependentUpon> <DependentUpon>ExpressionFinder.atg</DependentUpon>
</None> </None>
<None Include="Parser\Frames\Parser.frame" /> <None Include="Parser\Parser.frame">
<None Include="Parser\Frames\Scanner.frame" /> <DependentUpon>vb.atg</DependentUpon>
<None Include="Parser\Frames\SharpCoco.exe" /> </None>
<None Include="Parser\Frames\trace.txt" />
<None Include="Parser\gen.bat" />
<None Include="Parser\Parser.frame" />
<None Include="Parser\vb.atg"> <None Include="Parser\vb.atg">
<CustomToolNamespace>ICSharpCode.NRefactory.VB.Parser</CustomToolNamespace> <CustomToolNamespace>ICSharpCode.NRefactory.VB.Parser</CustomToolNamespace>
<Generator>CocoParserGenerator</Generator> <Generator>CocoParserGenerator</Generator>
</None> </None>
<None Include="Parser\vbnet.atg" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project> </Project>

106
VB/Project/Parser/AbstractParser.cs

@ -1,106 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.VB.Dom;
namespace ICSharpCode.NRefactory.VB.Parser
{
public abstract class AbstractParser : IParser
{
protected const int MinErrDist = 2;
protected const string ErrMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
private Errors errors;
private ILexer lexer;
protected int errDist = MinErrDist;
[CLSCompliant(false)]
protected CompilationUnit compilationUnit;
bool parseMethodContents = true;
public bool ParseMethodBodies {
get {
return parseMethodContents;
}
set {
parseMethodContents = value;
}
}
public ILexer Lexer {
get {
return lexer;
}
}
public Errors Errors {
get {
return errors;
}
}
public CompilationUnit CompilationUnit {
get {
return compilationUnit;
}
}
internal AbstractParser(ILexer lexer)
{
this.errors = lexer.Errors;
this.lexer = lexer;
errors.SynErr = new ErrorCodeProc(SynErr);
}
public abstract void Parse();
public abstract TypeReference ParseTypeReference ();
public abstract Expression ParseExpression();
public abstract BlockStatement ParseBlock();
public abstract List<INode> ParseTypeMembers();
protected abstract void SynErr(int line, int col, int errorNumber);
protected void SynErr(int n)
{
if (errDist >= MinErrDist) {
errors.SynErr(lexer.LookAhead.line, lexer.LookAhead.col, n);
}
errDist = 0;
}
protected void SemErr(string msg)
{
if (errDist >= MinErrDist) {
errors.Error(lexer.Token.line, lexer.Token.col, msg);
}
errDist = 0;
}
protected void Expect(int n)
{
if (lexer.LookAhead.kind == n) {
lexer.NextToken();
} else {
SynErr(n);
}
}
#region System.IDisposable interface implementation
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
public void Dispose()
{
errors = null;
if (lexer != null) {
lexer.Dispose();
}
lexer = null;
}
#endregion
}
}

50
VB/Project/Parser/Frames/Parser.frame

@ -1,50 +0,0 @@
/*
Parser.frame file for NRefactory.
*/
using System;
using System.Reflection;
-->namespace
-->tokens
partial class Parser : AbstractParser
{
-->constants
const bool T = true;
const bool x = false;
-->declarations
/*
-->pragmas
*/
-->productions
void 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)
{
return set[s, lexer.LookAhead.kind];
}
static bool[,] set = {
-->initialization
};
} // end Parser
$$$

202
VB/Project/Parser/Frames/Scanner.frame

@ -1,202 +0,0 @@
/*----------------------------------------------------------------------
Compiler Generator Coco/R,
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
extended by M. Loeberbauer & A. Woess, Univ. of Linz
with improvements by Pat Terry, Rhodes University
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As an exception, it is allowed to write an extension of Coco/R that is
used as a plugin in non-free software.
If not otherwise stated, any source code generated by Coco/R (other than
Coco/R itself) does not fall under the GNU General Public License.
-----------------------------------------------------------------------*/
-->begin
using System;
using System.IO;
using System.Collections;
using System.Text;
-->namespace
public class Token {
public int kind; // token kind
public int pos; // token position in the source text (starting at 0)
public int col; // token column (starting at 0)
public int line; // token line (starting at 1)
public string val; // token value
public Token next; // AW 2003-03-07 Tokens are kept in linked list
}
public class Buffer {
public const char EOF = (char)256;
static byte[] buf;
static int bufLen;
static int pos;
// CHANGES by M.KRUEGER
public static int CountLines(int offset)
{
int line = 0;
for (int i = 0; i <= offset; ++i) {
if (buf[i] == '\n') {
++line;
}
}
return line;
}
//EOC
public static void Fill (Stream s) {
bufLen = (int) s.Length;
buf = new byte[bufLen];
s.Read(buf, 0, bufLen);
pos = 0;
}
public static int Read () {
if (pos < bufLen) return buf[pos++];
else return EOF; /* pdt */
}
public static int Peek () {
if (pos < bufLen) return buf[pos];
else return EOF; /* pdt */
}
/* AW 2003-03-10 moved this from ParserGen.cs */
public static string GetString (int beg, int end) {
StringBuilder s = new StringBuilder(64);
int oldPos = Buffer.Pos;
Buffer.Pos = beg;
while (beg < end) { s.Append((char)Buffer.Read()); beg++; }
Buffer.Pos = oldPos;
return s.ToString();
}
public static int Pos {
get { return pos; }
set {
if (value < 0) pos = 0;
else if (value >= bufLen) pos = bufLen;
else pos = value;
}
}
}
public class Scanner {
const char EOL = '\n';
const int eofSym = 0; /* pdt */
-->declarations
static Token t; // current token
static char ch; // current input character
static int pos; // column number of current character
static int line; // line number of current character
static int lineStart; // start position of current line
static int oldEols; // EOLs that appeared in a comment;
static BitArray ignore; // set of characters to be ignored by the scanner
static Token tokens; // the complete input token stream
static Token pt; // current peek token
public static void Init (string fileName) {
FileStream s = null;
try {
s = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
Init(s);
} catch (IOException) {
Console.WriteLine("--- Cannot open file {0}", fileName);
System.Environment.Exit(1);
} finally {
if (s != null) s.Close();
}
}
public static void Init (Stream s) {
Buffer.Fill(s);
pos = -1; line = 1; lineStart = 0;
oldEols = 0;
NextCh();
-->initialization
//--- AW: fill token list
tokens = new Token(); // first token is a dummy
Token node = tokens;
do {
node.next = NextToken();
node = node.next;
} while (node.kind != eofSym);
node.next = node;
node.val = "EOF";
t = pt = tokens;
}
static void NextCh() {
if (oldEols > 0) { ch = EOL; oldEols--; }
else {
ch = (char)Buffer.Read(); pos++;
// replace isolated '\r' by '\n' in order to make
// eol handling uniform across Windows, Unix and Mac
if (ch == '\r' && Buffer.Peek() != '\n') ch = EOL;
if (ch == EOL) { line++; lineStart = pos + 1; }
}
-->casing
}
-->comments
static void CheckLiteral() {
-->literals
}
/* AW Scan() renamed to NextToken() */
static Token NextToken() {
while (ignore[ch]) NextCh();
-->scan1
t = new Token();
t.pos = pos; t.col = pos - lineStart + 1; t.line = line;
int state = start[ch];
StringBuilder buf = new StringBuilder(16);
-->scan2
switch (state) {
case -1: { t.kind = eofSym; goto done; } // NextCh already done /* pdt */
case 0: { t.kind = noSym; goto done; } // NextCh already done
-->scan3
}
done:
t.val = buf.ToString();
return t;
}
/* AW 2003-03-07 get the next token, move on and synch peek token with current */
public static Token Scan () {
t = pt = t.next;
return t;
}
/* AW 2003-03-07 get the next token, ignore pragmas */
public static Token Peek () {
do { // skip pragmas while peeking
pt = pt.next;
} while (pt.kind > maxT);
return pt;
}
/* AW 2003-03-11 to make sure peek start at current scan position */
public static void ResetPeek () { pt = t; }
} // end Scanner
$$$

BIN
VB/Project/Parser/Frames/SharpCoco.exe

Binary file not shown.

38
VB/Project/Parser/IParser.cs

@ -1,38 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.VB.Dom;
namespace ICSharpCode.NRefactory.VB
{
/// <summary>
/// Parser interface.
/// </summary>
public interface IParser : IDisposable
{
Parser.Errors Errors {
get;
}
Parser.ILexer Lexer {
get;
}
CompilationUnit CompilationUnit {
get;
}
bool ParseMethodBodies {
get; set;
}
void Parse();
Expression ParseExpression();
TypeReference ParseTypeReference ();
BlockStatement ParseBlock();
List<INode> ParseTypeMembers();
}
}

4
VB/Project/Parser/ParamModifierList.cs

@ -8,7 +8,7 @@ namespace ICSharpCode.NRefactory.VB.Parser
internal class ParamModifierList internal class ParamModifierList
{ {
ParameterModifiers cur; ParameterModifiers cur;
Parser parser; VBParser parser;
public ParameterModifiers Modifier { public ParameterModifiers Modifier {
get { get {
@ -16,7 +16,7 @@ namespace ICSharpCode.NRefactory.VB.Parser
} }
} }
public ParamModifierList(Parser parser) public ParamModifierList(VBParser parser)
{ {
this.parser = parser; this.parser = parser;
cur = ParameterModifiers.None; cur = ParameterModifiers.None;

190
VB/Project/Parser/Parser.cs

@ -18,7 +18,7 @@ namespace ICSharpCode.NRefactory.VB.Parser {
// Parser // Parser
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
//! A Coco/R Parser //! A Coco/R Parser
partial class Parser partial class VBParser
{ {
public const int _EOF = 0; public const int _EOF = 0;
public const int _EOL = 1; public const int _EOL = 1;
@ -3751,70 +3751,11 @@ partial class Parser
Location startLocation = la.Location; Location startLocation = la.Location;
if (la.kind == 120) { if (la.kind == 120) {
Get(); ExitStatement(out statement);
ExitType exitType = ExitType.None;
switch (la.kind) {
case 210: {
Get();
exitType = ExitType.Sub;
break;
}
case 127: {
Get();
exitType = ExitType.Function;
break;
}
case 186: {
Get();
exitType = ExitType.Property;
break;
}
case 108: {
Get();
exitType = ExitType.Do;
break;
}
case 124: {
Get();
exitType = ExitType.For;
break;
}
case 218: {
Get();
exitType = ExitType.Try;
break;
}
case 231: {
Get();
exitType = ExitType.While;
break;
}
case 197: {
Get();
exitType = ExitType.Select;
break;
}
default: SynErr(295); break;
}
statement = new ExitStatement(exitType);
} else if (la.kind == 218) { } else if (la.kind == 218) {
TryStatement(out statement); TryStatement(out statement);
} else if (la.kind == 89) { } else if (la.kind == 89) {
Get(); ContinueStatement(out statement);
ContinueType continueType = ContinueType.None;
if (la.kind == 108 || la.kind == 124 || la.kind == 231) {
if (la.kind == 108) {
Get();
continueType = ContinueType.Do;
} else if (la.kind == 124) {
Get();
continueType = ContinueType.For;
} else {
Get();
continueType = ContinueType.While;
}
}
statement = new ContinueStatement(continueType);
} else if (la.kind == 215) { } else if (la.kind == 215) {
Get(); Get();
if (StartOf(24)) { if (StartOf(24)) {
@ -3900,7 +3841,7 @@ partial class Parser
} }
statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End); statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End);
} else SynErr(296); } else SynErr(295);
} else if (la.kind == 124) { } else if (la.kind == 124) {
Get(); Get();
Expression group = null; Expression group = null;
@ -3974,7 +3915,7 @@ partial class Parser
NextExpressions = nextExpressions NextExpressions = nextExpressions
}; };
} else SynErr(297); } else SynErr(296);
} else if (la.kind == 118) { } else if (la.kind == 118) {
Get(); Get();
Expr(out expr); Expr(out expr);
@ -4074,7 +4015,7 @@ partial class Parser
} }
} }
ifStatement.EndLocation = t.Location; statement = ifStatement; ifStatement.EndLocation = t.Location; statement = ifStatement;
} else SynErr(298); } else SynErr(297);
} else if (la.kind == 197) { } else if (la.kind == 197) {
Get(); Get();
if (la.kind == 74) { if (la.kind == 74) {
@ -4136,7 +4077,7 @@ partial class Parser
} else if (StartOf(47)) { } else if (StartOf(47)) {
if (mustBeAssignment) Error("error in assignment."); if (mustBeAssignment) Error("error in assignment.");
} else SynErr(299); } else SynErr(298);
if(expr is MemberReferenceExpression || expr is IdentifierExpression) { if(expr is MemberReferenceExpression || expr is IdentifierExpression) {
Location endLocation = expr.EndLocation; Location endLocation = expr.EndLocation;
expr = new InvocationExpression(expr); expr = new InvocationExpression(expr);
@ -4166,12 +4107,12 @@ partial class Parser
Expr(out expr); Expr(out expr);
Block(out block); Block(out block);
statement = new UsingStatement(new ExpressionStatement(expr), block); statement = new UsingStatement(new ExpressionStatement(expr), block);
} else SynErr(300); } else SynErr(299);
Expect(113); Expect(113);
Expect(226); Expect(226);
} else if (StartOf(48)) { } else if (StartOf(48)) {
LocalDeclarationStatement(out statement); LocalDeclarationStatement(out statement);
} else SynErr(301); } else SynErr(300);
if (statement != null) { if (statement != null) {
statement.StartLocation = startLocation; statement.StartLocation = startLocation;
statement.EndLocation = t.EndLocation; statement.EndLocation = t.EndLocation;
@ -4189,7 +4130,7 @@ partial class Parser
} else if (la.kind == 58) { } else if (la.kind == 58) {
AggregateQueryOperator(out aggregateClause); AggregateQueryOperator(out aggregateClause);
middleClauses.Add(aggregateClause); middleClauses.Add(aggregateClause);
} else SynErr(302); } else SynErr(301);
} }
void QueryOperator(List<QueryExpressionClause> middleClauses) { void QueryOperator(List<QueryExpressionClause> middleClauses) {
@ -4228,7 +4169,7 @@ partial class Parser
} else if (la.kind == 133) { } else if (la.kind == 133) {
GroupByQueryOperator(out groupByClause); GroupByQueryOperator(out groupByClause);
middleClauses.Add(groupByClause); middleClauses.Add(groupByClause);
} else SynErr(303); } else SynErr(302);
} }
void FromQueryOperator(out QueryExpressionFromClause fromClause) { void FromQueryOperator(out QueryExpressionFromClause fromClause) {
@ -4328,7 +4269,7 @@ partial class Parser
Get(); Get();
partitionClause.PartitionType = QueryExpressionPartitionType.SkipWhile; partitionClause.PartitionType = QueryExpressionPartitionType.SkipWhile;
} }
} else SynErr(304); } else SynErr(303);
Expr(out expr); Expr(out expr);
partitionClause.Expression = expr; partitionClause.Expression = expr;
partitionClause.EndLocation = t.EndLocation; partitionClause.EndLocation = t.EndLocation;
@ -4531,7 +4472,7 @@ partial class Parser
} else if (StartOf(24)) { } else if (StartOf(24)) {
Expr(out argumentexpr); Expr(out argumentexpr);
} else SynErr(305); } else SynErr(304);
} }
void QualIdentAndTypeArguments(out TypeReference typeref, bool canBeUnbound) { void QualIdentAndTypeArguments(out TypeReference typeref, bool canBeUnbound) {
@ -4549,7 +4490,7 @@ partial class Parser
} }
} else if (StartOf(9)) { } else if (StartOf(9)) {
TypeArgumentList(typeref.GenericTypes); TypeArgumentList(typeref.GenericTypes);
} else SynErr(306); } else SynErr(305);
Expect(38); Expect(38);
} }
} }
@ -4595,7 +4536,7 @@ partial class Parser
Get(); Get();
} else if (la.kind == 20) { } else if (la.kind == 20) {
Get(); Get();
} else SynErr(307); } else SynErr(306);
} }
Expr(out expr); Expr(out expr);
if (expr != null) { if (expr != null) {
@ -4612,10 +4553,10 @@ partial class Parser
Get(); Get();
} else if (la.kind == 20) { } else if (la.kind == 20) {
Get(); Get();
} else SynErr(308); } else SynErr(307);
} else if (StartOf(24)) { } else if (StartOf(24)) {
if (nameFound) Error("no positional argument after named argument"); if (nameFound) Error("no positional argument after named argument");
} else SynErr(309); } else SynErr(308);
Expr(out expr); Expr(out expr);
if (expr != null) { if(name == "") positional.Add(expr); if (expr != null) { if(name == "") positional.Add(expr);
else { named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); name = ""; } else { named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); name = ""; }
@ -4639,7 +4580,7 @@ partial class Parser
} else if (la.kind == 182) { } else if (la.kind == 182) {
Get(); Get();
m.Add(ParameterModifiers.Params); m.Add(ParameterModifiers.Params);
} else SynErr(310); } else SynErr(309);
} }
void Statement() { void Statement() {
@ -4656,7 +4597,7 @@ partial class Parser
} else if (StartOf(1)) { } else if (StartOf(1)) {
EmbeddedStatement(out stmt); EmbeddedStatement(out stmt);
AddChild(stmt); AddChild(stmt);
} else SynErr(311); } else SynErr(310);
if (stmt != null) { if (stmt != null) {
stmt.StartLocation = startPos; stmt.StartLocation = startPos;
stmt.EndLocation = t.Location; stmt.EndLocation = t.Location;
@ -4673,7 +4614,7 @@ partial class Parser
} else if (la.kind == 5) { } else if (la.kind == 5) {
Get(); Get();
name = t.val; name = t.val;
} else SynErr(312); } else SynErr(311);
} }
void LocalDeclarationStatement(out Statement statement) { void LocalDeclarationStatement(out Statement statement) {
@ -4713,6 +4654,55 @@ partial class Parser
} }
void ExitStatement(out Statement statement) {
Expect(120);
ExitType exitType = ExitType.None;
switch (la.kind) {
case 210: {
Get();
exitType = ExitType.Sub;
break;
}
case 127: {
Get();
exitType = ExitType.Function;
break;
}
case 186: {
Get();
exitType = ExitType.Property;
break;
}
case 108: {
Get();
exitType = ExitType.Do;
break;
}
case 124: {
Get();
exitType = ExitType.For;
break;
}
case 218: {
Get();
exitType = ExitType.Try;
break;
}
case 231: {
Get();
exitType = ExitType.While;
break;
}
case 197: {
Get();
exitType = ExitType.Select;
break;
}
default: SynErr(312); break;
}
statement = new ExitStatement(exitType);
}
void TryStatement(out Statement tryStatement) { void TryStatement(out Statement tryStatement) {
Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null; Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
@ -4733,6 +4723,24 @@ partial class Parser
} }
void ContinueStatement(out Statement statement) {
Expect(89);
ContinueType continueType = ContinueType.None;
if (la.kind == 108 || la.kind == 124 || la.kind == 231) {
if (la.kind == 108) {
Get();
continueType = ContinueType.Do;
} else if (la.kind == 124) {
Get();
continueType = ContinueType.For;
} else {
Get();
continueType = ContinueType.While;
}
}
statement = new ContinueStatement(continueType);
}
void WithStatement(out Statement withStatement) { void WithStatement(out Statement withStatement) {
Statement blockStmt = null; Statement blockStmt = null;
Expression expr = null; Expression expr = null;
@ -5076,8 +5084,8 @@ partial class Parser
new BitArray(new int[] {1048576, 3968, 0, 0, 65536, 0, 0, 0}) new BitArray(new int[] {1048576, 3968, 0, 0, 65536, 0, 0, 0})
}; };
protected override void SynErr(int line, int col, int errorNumber) void SynErr(int line, int col, int errorNumber)
{ {
this.Errors.Error(line, col, GetMessage(errorNumber)); this.Errors.Error(line, col, GetMessage(errorNumber));
} }
@ -5386,18 +5394,18 @@ partial class Parser
case 298: return "invalid EmbeddedStatement"; case 298: return "invalid EmbeddedStatement";
case 299: return "invalid EmbeddedStatement"; case 299: return "invalid EmbeddedStatement";
case 300: return "invalid EmbeddedStatement"; case 300: return "invalid EmbeddedStatement";
case 301: return "invalid EmbeddedStatement"; case 301: return "invalid FromOrAggregateQueryOperator";
case 302: return "invalid FromOrAggregateQueryOperator"; case 302: return "invalid QueryOperator";
case 303: return "invalid QueryOperator"; case 303: return "invalid PartitionQueryOperator";
case 304: return "invalid PartitionQueryOperator"; case 304: return "invalid Argument";
case 305: return "invalid Argument"; case 305: return "invalid QualIdentAndTypeArguments";
case 306: return "invalid QualIdentAndTypeArguments"; case 306: return "invalid AttributeArguments";
case 307: return "invalid AttributeArguments"; case 307: return "invalid AttributeArguments";
case 308: return "invalid AttributeArguments"; case 308: return "invalid AttributeArguments";
case 309: return "invalid AttributeArguments"; case 309: return "invalid ParameterModifier";
case 310: return "invalid ParameterModifier"; case 310: return "invalid Statement";
case 311: return "invalid Statement"; case 311: return "invalid LabelName";
case 312: return "invalid LabelName"; case 312: return "invalid ExitStatement";
case 313: return "invalid WhileOrUntil"; case 313: return "invalid WhileOrUntil";
case 314: return "invalid SingleLineStatementList"; case 314: return "invalid SingleLineStatementList";
case 315: return "invalid SingleLineStatementList"; case 315: return "invalid SingleLineStatementList";

119
VB/Project/Parser/Parser.frame

@ -0,0 +1,119 @@
/*---------------------------------------------------------------------------*\
Compiler Generator Coco/R,
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
extended by M. Loeberbauer & A. Woess, Univ. of Linz
with improvements by Pat Terry, Rhodes University
-------------------------------------------------------------------------------
License
This file is part of Compiler Generator Coco/R
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As an exception, it is allowed to write an extension of Coco/R that is
used as a plugin in non-free software.
If not otherwise stated, any source code generated by Coco/R (other than
Coco/R itself) does not fall under the GNU General Public License.
About this file
This is a so-called 'frame' file that contains skeleton code for
generating a final Scanner/Parser code.
The '-->TAG' text markers are used to delimit code chunks and typically
correspond to places where additional information is added by the
DFA or ParserGen code.
All information prior to the first 'begin' text marker is discarded.
If the grammar contains a '[copy]' .. '[/copy]' section, its contents
will added instead.
\*---------------------------------------------------------------------------*/
-->begin
-->namespace
// ----------------------------------------------------------------------------
// Parser
// ----------------------------------------------------------------------------
//! A Coco/R Parser
partial class VBParser
{
-->constants
const bool T = true;
const bool x = false;
const int minErrDist = 2;
public Errors errors;
-->declarations
void Get () {
lexer.NextToken();
-->pragmas
}
bool StartOf (int s) {
return set[s].Get(la.kind);
}
void ExpectWeak (int n, int follow) {
if (la.kind == n) Get();
else {
SynErr(n);
while (!StartOf(follow)) Get();
}
}
bool WeakSeparator(int n, int syFol, int repFol) {
int kind = la.kind;
if (kind == n) {Get(); return true;}
else if (StartOf(repFol)) {return false;}
else {
SynErr(n);
while (!(set[syFol].Get(kind) || set[repFol].Get(kind) || set[0].Get(kind))) {
Get();
kind = la.kind;
}
return StartOf(syFol);
}
}
-->productions
public void ParseRoot() {
-->parseRoot
}
static readonly BitArray[] set = {
-->initialization
};
void SynErr(int line, int col, int errorNumber)
{
this.Errors.Error(line, col, GetMessage(errorNumber));
}
string GetMessage(int errorNumber)
{
switch (errorNumber) {
-->errors
default: return "error " + errorNumber;
}
}
} // end Parser
$$$

98
VB/Project/Parser/VBNetParser.cs → VB/Project/Parser/VBParser.cs

@ -12,13 +12,21 @@ using ICSharpCode.NRefactory.VB.Visitors;
namespace ICSharpCode.NRefactory.VB.Parser namespace ICSharpCode.NRefactory.VB.Parser
{ {
internal sealed partial class Parser : AbstractParser public partial class VBParser
{ {
Lexer lexer; Lexer lexer;
Stack<INode> blockStack; Stack<INode> blockStack;
CompilationUnit compilationUnit;
int errDist = MinErrDist;
bool parseMethodContents = true;
public Parser(ILexer lexer) : base(lexer) const int MinErrDist = 2;
const string ErrMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
public VBParser(ILexer lexer)
{ {
this.errors = lexer.Errors;
errors.SynErr = new ErrorCodeProc(SynErr);
this.lexer = (Lexer)lexer; this.lexer = (Lexer)lexer;
this.blockStack = new Stack<INode>(); this.blockStack = new Stack<INode>();
} }
@ -42,7 +50,7 @@ namespace ICSharpCode.NRefactory.VB.Parser
} }
} }
private StringBuilder qualidentBuilder = new StringBuilder(); StringBuilder qualidentBuilder = new StringBuilder();
Token t Token t
{ {
@ -78,19 +86,19 @@ namespace ICSharpCode.NRefactory.VB.Parser
errDist = 0; errDist = 0;
} }
public override void Parse() public void Parse()
{ {
ParseRoot(); ParseRoot();
compilationUnit.AcceptVisitor(new SetParentVisitor(), null); compilationUnit.AcceptVisitor(new SetParentVisitor(), null);
} }
public override TypeReference ParseTypeReference () public TypeReference ParseTypeReference ()
{ {
// TODO // TODO
return null; return null;
} }
public override Expression ParseExpression() public Expression ParseExpression()
{ {
lexer.SetInitialContext(SnippetType.Expression); lexer.SetInitialContext(SnippetType.Expression);
lexer.NextToken(); lexer.NextToken();
@ -107,7 +115,7 @@ namespace ICSharpCode.NRefactory.VB.Parser
return expr; return expr;
} }
public override BlockStatement ParseBlock() public BlockStatement ParseBlock()
{ {
lexer.NextToken(); lexer.NextToken();
compilationUnit = new CompilationUnit(); compilationUnit = new CompilationUnit();
@ -127,9 +135,9 @@ namespace ICSharpCode.NRefactory.VB.Parser
return st as BlockStatement; return st as BlockStatement;
} }
public override List<INode> ParseTypeMembers() public List<INode> ParseTypeMembers()
{ {
lexer.NextToken(); lexer.NextToken();
TypeDeclaration newType = new TypeDeclaration(Modifiers.None, null); TypeDeclaration newType = new TypeDeclaration(Modifiers.None, null);
BlockStart(newType); BlockStart(newType);
ClassBody(newType); ClassBody(newType);
@ -139,12 +147,6 @@ namespace ICSharpCode.NRefactory.VB.Parser
return newType.Children; return newType.Children;
} }
bool LeaveBlock()
{
int peek = Peek(1).kind;
return Tokens.BlockSucc[la.kind] && (la.kind != Tokens.End || peek == Tokens.EOL || peek == Tokens.Colon);
}
/* True, if "." is followed by an ident */ /* True, if "." is followed by an ident */
bool DotAndIdentOrKw () { bool DotAndIdentOrKw () {
int peek = Peek(1).kind; int peek = Peek(1).kind;
@ -383,5 +385,71 @@ namespace ICSharpCode.NRefactory.VB.Parser
item.Parent = parent; item.Parent = parent;
} }
} }
public bool ParseMethodBodies {
get {
return parseMethodContents;
}
set {
parseMethodContents = value;
}
}
public ILexer Lexer {
get {
return lexer;
}
}
public Errors Errors {
get {
return errors;
}
}
public CompilationUnit CompilationUnit {
get {
return compilationUnit;
}
}
void SynErr(int n)
{
if (errDist >= MinErrDist) {
errors.SynErr(lexer.LookAhead.line, lexer.LookAhead.col, n);
}
errDist = 0;
}
void SemErr(string msg)
{
if (errDist >= MinErrDist) {
errors.Error(lexer.Token.line, lexer.Token.col, msg);
}
errDist = 0;
}
void Expect(int n)
{
if (lexer.LookAhead.kind == n) {
lexer.NextToken();
} else {
SynErr(n);
}
}
#region System.IDisposable interface implementation
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
public void Dispose()
{
errors = null;
if (lexer != null) {
lexer.Dispose();
}
lexer = null;
}
#endregion
} }
} }

14
VB/Project/Parser/gen.bat

@ -1,14 +0,0 @@
@echo off
echo Generating with #Coco
cd Frames
copy ..\vbnet.atg
SharpCoco -namespace ICSharpCode.NRefactory.VB.Parser -trace FG vbnet.atg
move Parser.cs ..
del vbnet.atg
pause
cd ..

18
VB/Project/Parser/gen.sh

@ -1,18 +0,0 @@
@echo off
echo Generating with #Coco
cd Frames
cp ../CSharp/cs.ATG .
mono SharpCoco.exe -namespace ICSharpCode.NRefactory.Parser.CSharp cs.ATG
mv Parser.cs ../CSharp
cp ../VBNet/VBNET.ATG .
mono SharpCoco.exe -trace GIPXA -namespace ICSharpCode.NRefactory.Parser.VB VBNET.ATG
mv Parser.cs ../VBNet
rm cs.ATG
rm VBNET.ATG
cd ..

1398
VB/Project/Parser/trace.txt

File diff suppressed because it is too large Load Diff

158
VB/Project/Parser/vbnet.atg → VB/Project/Parser/vb.atg

@ -1,3 +1,4 @@
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
@ -7,7 +8,8 @@ using ICSharpCode.NRefactory.VB.Dom;
using ICSharpCode.NRefactory.VB.Parser; using ICSharpCode.NRefactory.VB.Parser;
using ASTAttribute = ICSharpCode.NRefactory.VB.Dom.Attribute; using ASTAttribute = ICSharpCode.NRefactory.VB.Dom.Attribute;
COMPILER VBNET COMPILER VB
$trace=FG
/* START AUTOGENERATED TOKENS SECTION */ /* START AUTOGENERATED TOKENS SECTION */
TOKENS TOKENS
@ -20,7 +22,7 @@ TOKENS
LiteralInteger LiteralInteger
LiteralDouble LiteralDouble
LiteralSingle LiteralSingle
LiteralDecimal LiteralDecimal
LiteralDate LiteralDate
XmlOpenTag XmlOpenTag
XmlCloseTag XmlCloseTag
@ -53,7 +55,7 @@ TOKENS
"}" "}"
"(" "("
")" ")"
">" ">"
"<" "<"
"<>" "<>"
">=" ">="
@ -258,7 +260,7 @@ TOKENS
PRODUCTIONS PRODUCTIONS
VBNET VB
(. (.
lexer.NextToken(); // get the first token lexer.NextToken(); // get the first token
compilationUnit = new CompilationUnit(); compilationUnit = new CompilationUnit();
@ -270,7 +272,6 @@ VBNET
{ ImportsStmt { EndOfStmt } } { ImportsStmt { EndOfStmt } }
{ IF (IsGlobalAttrTarget()) GlobalAttributeSection { EndOfStmt } } { IF (IsGlobalAttrTarget()) GlobalAttributeSection { EndOfStmt } }
{ NamespaceMemberDecl { EndOfStmt } } { NamespaceMemberDecl { EndOfStmt } }
EOF
. .
OptionStmt (. INode node = null; bool val = true; .) = OptionStmt (. INode node = null; bool val = true; .) =
@ -297,7 +298,7 @@ OptionStmt (. INode node = null; bool val = true; .) =
AddChild(node); AddChild(node);
} }
.) .)
. .
OptionValue<ref bool val> = OptionValue<ref bool val> =
( (
@ -386,7 +387,7 @@ NamespaceMemberDecl
. .
/* 4.9.1 */ /* 4.9.1 */
TypeParameterList<List<TemplateDefinition> templates> TypeParameterList<.List<TemplateDefinition> templates.>
(. (.
TemplateDefinition template; TemplateDefinition template;
.) .)
@ -452,7 +453,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;
@ -790,7 +791,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>
. .
@ -804,7 +805,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>();
@ -1395,7 +1396,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>
@ -1411,7 +1412,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>();
@ -1435,7 +1436,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;
@ -1454,13 +1455,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;
@ -1528,7 +1529,7 @@ VariableDeclaratorPartAfterIdentifier<List<VariableDeclaration> fieldDeclaration
. .
/* 6.8 */ /* 6.8 */
ArrayInitializationModifier<out List<Expression> arrayModifiers> ArrayInitializationModifier<.out List<Expression> arrayModifiers.>
(. (.
arrayModifiers = null; arrayModifiers = null;
.) = .) =
@ -1536,7 +1537,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;
@ -1589,7 +1590,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;
@ -1599,7 +1600,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>();
@ -1614,7 +1615,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;
@ -1631,7 +1632,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;
@ -1827,7 +1828,7 @@ XmlLiteralExpression<out Expression pexpr>
.) .)
. .
XmlContentExpression<List<XmlExpression> exprs> = XmlContentExpression<.List<XmlExpression> exprs.> =
(. XmlContentExpression expr = null; .) (. XmlContentExpression expr = null; .)
( (
XmlContent (. expr = new XmlContentExpression(t.val, XmlContentType.Text); .) XmlContent (. expr = new XmlContentExpression(t.val, XmlContentType.Text); .)
@ -1875,7 +1876,7 @@ XmlElement<out XmlExpression expr>
(. expr = el; .) (. expr = el; .)
. .
XmlAttribute<List<XmlExpression> attrs> XmlAttribute<.List<XmlExpression> attrs.>
(. Location start = la.Location; .) (. Location start = la.Location; .)
= =
Identifier (. string name = t.val; .) "=" Identifier (. string name = t.val; .) "="
@ -1934,7 +1935,6 @@ InvocationExpression<ref Expression pexpr>
. .
/* 11.11 */ /* 11.11 */
CastTarget<out TypeReference type> CastTarget<out TypeReference type>
(. (.
type = null; type = null;
@ -2300,7 +2300,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;
@ -2311,7 +2311,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;
@ -2339,7 +2339,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;
@ -2353,7 +2353,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;
@ -2422,7 +2422,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;
@ -2434,7 +2434,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;
@ -2446,7 +2446,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;
@ -2500,7 +2500,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;
@ -2512,7 +2512,7 @@ LetQueryOperator<List<QueryExpressionClause> middleClauses>
.) .)
. .
ExpressionRangeVariableDeclarationList<List<ExpressionRangeVariable> variables> ExpressionRangeVariableDeclarationList<.List<ExpressionRangeVariable> variables.>
(. (.
ExpressionRangeVariable variable = null; ExpressionRangeVariable variable = null;
.) = .) =
@ -2571,7 +2571,7 @@ JoinQueryOperator<out QueryExpressionJoinVBClause joinClause>
.) .)
. .
CollectionRangeVariableDeclarationList<List<CollectionRangeVariable> rangeVariables> CollectionRangeVariableDeclarationList<.List<CollectionRangeVariable> rangeVariables.>
(. CollectionRangeVariable variableDeclaration; .) (. CollectionRangeVariable variableDeclaration; .)
= =
CollectionRangeVariableDeclaration<out variableDeclaration> CollectionRangeVariableDeclaration<out variableDeclaration>
@ -2630,7 +2630,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;
@ -2644,7 +2644,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();
@ -2802,7 +2802,7 @@ RankList<out int i>
. .
/* 7.12 */ /* 7.12 */
TypeArgumentList<List<TypeReference> typeArguments> TypeArgumentList<.List<TypeReference> typeArguments.>
(. (.
TypeReference typeref; TypeReference typeref;
.) = .) =
@ -2853,7 +2853,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 = "";
@ -2930,7 +2930,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); .)
@ -2986,18 +2986,19 @@ Block<out Statement stmt>
if (t != null) blockStmt.StartLocation = t.EndLocation; if (t != null) blockStmt.StartLocation = t.EndLocation;
BlockStart(blockStmt); BlockStart(blockStmt);
.) .)
{ {
IF (IsEndStmtAhead()) IF (IsEndStmtAhead() || StartOf(StatementEndOfStmt))
(. Token first = la; .) (
"End" EndOfStmt "End"
(. (. Token first = t;
AddChild(new EndStatement() { AddChild(new EndStatement() {
StartLocation = first.Location, StartLocation = first.Location,
EndLocation = first.EndLocation } EndLocation = first.EndLocation }
); );
.) .) EndOfStmt
| Statement EndOfStmt |
/* IF (!LeaveBlock()) { }*/ (.NamedFirstSet:StatementEndOfStmt.) Statement EndOfStmt
)
} }
(. (.
stmt = blockStmt; stmt = blockStmt;
@ -3011,10 +3012,9 @@ Statement
Statement stmt = null; Statement stmt = null;
Location startPos = la.Location; Location startPos = la.Location;
string label = String.Empty; string label = String.Empty;
.) = .) =
( (
| IF (IsLabel()) LabelName<out label> IF (IsLabel()) LabelName<out label>
(. (.
AddChild(new LabelStatement(t.val)); AddChild(new LabelStatement(t.val));
.) .)
@ -3070,28 +3070,9 @@ EmbeddedStatement<out Statement statement>
List<Expression> p = null; List<Expression> p = null;
Location startLocation = la.Location; Location startLocation = la.Location;
.) = .) =
( ( ExitStatement<out statement>
"Exit" (. ExitType exitType = ExitType.None; .)
(
"Sub" (. exitType = ExitType.Sub; .)
|
"Function" (. exitType = ExitType.Function; .)
|
"Property" (. exitType = ExitType.Property; .)
|
"Do" (. exitType = ExitType.Do; .)
|
"For" (. exitType = ExitType.For; .)
|
"Try" (. exitType = ExitType.Try; .)
|
"While" (. exitType = ExitType.While; .)
|
"Select" (. exitType = ExitType.Select; .)
)
(. statement = new ExitStatement(exitType); .)
| TryStatement<out statement> | TryStatement<out statement>
| "Continue" (. ContinueType continueType = ContinueType.None; .) [ "Do" (. continueType = ContinueType.Do; .) | "For" (. continueType = ContinueType.For; .) | "While" (. continueType = ContinueType.While; .)] (. statement = new ContinueStatement(continueType); .) | ContinueStatement<out statement>
| /* 10.10.1.3 */ | /* 10.10.1.3 */
"Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .) "Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .)
| /* 10.11 */ | /* 10.11 */
@ -3370,7 +3351,28 @@ EmbeddedStatement<out Statement statement>
.) .)
. .
SingleLineStatementList<List<Statement> list> ExitStatement<out Statement statement> =
"Exit" (. ExitType exitType = ExitType.None; .)
( "Sub" (. exitType = ExitType.Sub; .)
| "Function" (. exitType = ExitType.Function; .)
| "Property" (. exitType = ExitType.Property; .)
| "Do" (. exitType = ExitType.Do; .)
| "For" (. exitType = ExitType.For; .)
| "Try" (. exitType = ExitType.Try; .)
| "While" (. exitType = ExitType.While; .)
| "Select" (. exitType = ExitType.Select; .) )
(. statement = new ExitStatement(exitType); .)
.
ContinueStatement<out Statement statement> =
"Continue" (. ContinueType continueType = ContinueType.None; .)
[ "Do" (. continueType = ContinueType.Do; .)
| "For" (. continueType = ContinueType.For; .)
| "While" (. continueType = ContinueType.While; .) ]
(. statement = new ContinueStatement(continueType); .)
.
SingleLineStatementList<.List<Statement> list.>
(. Statement embeddedStatement = null; .) (. Statement embeddedStatement = null; .)
= =
( "End" (. embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; .) ( "End" (. embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
@ -3513,7 +3515,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;
@ -3595,7 +3597,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;
@ -3743,4 +3745,4 @@ PropertyAccessorAccessModifier<out Modifiers m> =
)} )}
. .
END VBNET. END VB .

8
VB/Project/ParserFactory.cs

@ -23,18 +23,18 @@ namespace ICSharpCode.NRefactory.VB
return new ICSharpCode.NRefactory.VB.Parser.Lexer(textReader, state); return new ICSharpCode.NRefactory.VB.Parser.Lexer(textReader, state);
} }
public static IParser CreateParser(TextReader textReader) public static VBParser CreateParser(TextReader textReader)
{ {
Parser.ILexer lexer = CreateLexer(textReader); Parser.ILexer lexer = CreateLexer(textReader);
return new ICSharpCode.NRefactory.VB.Parser.Parser(lexer); return new ICSharpCode.NRefactory.VB.Parser.VBParser(lexer);
} }
public static IParser CreateParser(string fileName) public static VBParser CreateParser(string fileName)
{ {
return CreateParser(fileName, Encoding.UTF8); return CreateParser(fileName, Encoding.UTF8);
} }
public static IParser CreateParser(string fileName, Encoding encoding) public static VBParser CreateParser(string fileName, Encoding encoding)
{ {
string ext = Path.GetExtension(fileName); string ext = Path.GetExtension(fileName);
if (ext.Equals(".vb", StringComparison.OrdinalIgnoreCase)) if (ext.Equals(".vb", StringComparison.OrdinalIgnoreCase))

30
VB/Project/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

@ -2339,12 +2339,6 @@ namespace ICSharpCode.NRefactory.VB.PrettyPrinter
return null; return null;
} }
public override object TrackedVisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
{
OutputAnonymousMethodWithStatementBody(anonymousMethodExpression.Parameters, anonymousMethodExpression.Body);
return null;
}
public override object TrackedVisitCastExpression(CastExpression castExpression, object data) public override object TrackedVisitCastExpression(CastExpression castExpression, object data)
{ {
if (castExpression.CastType == CastType.TryCast) { if (castExpression.CastType == CastType.TryCast) {
@ -2779,30 +2773,6 @@ namespace ICSharpCode.NRefactory.VB.PrettyPrinter
} }
} }
void OutputAnonymousMethodWithStatementBody(List<ParameterDeclarationExpression> parameters, Statement body)
{
Error("VB does not support anonymous methods/lambda expressions with a statement body", body.StartLocation);
outputFormatter.PrintToken(Tokens.Function);
outputFormatter.PrintToken(Tokens.OpenParenthesis);
AppendCommaSeparatedList(parameters);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Do);
outputFormatter.NewLine();
++outputFormatter.IndentationLevel;
exitTokenStack.Push(Tokens.Function);
body.AcceptVisitor(this, null);
exitTokenStack.Pop();
--outputFormatter.IndentationLevel;
outputFormatter.Indent();
outputFormatter.PrintToken(Tokens.End);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Function);
}
public override object TrackedVisitQueryExpression(QueryExpression queryExpression, object data) public override object TrackedVisitQueryExpression(QueryExpression queryExpression, object data)
{ {
outputFormatter.IndentationLevel++; outputFormatter.IndentationLevel++;

2
VB/Project/Properties/AssemblyInfo.cs

@ -22,6 +22,8 @@ using System.Runtime.InteropServices;
// If you need to expose a type to COM, use [ComVisible(true)] on that type. // If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
//[assembly: CLSCompliant(true)]
// The assembly version has following format : // The assembly version has following format :
// //
// Major.Minor.Build.Revision // Major.Minor.Build.Revision

2
VB/Project/SnippetParser.cs

@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.VB
/// </summary> /// </summary>
public INode Parse(string code) public INode Parse(string code)
{ {
IParser parser = ParserFactory.CreateParser(new StringReader(code)); VBParser parser = ParserFactory.CreateParser(new StringReader(code));
parser.Parse(); parser.Parse();
this.Errors = parser.Errors; this.Errors = parser.Errors;
this.Specials = parser.Lexer.SpecialTracker.RetrieveSpecials(); this.Specials = parser.Lexer.SpecialTracker.RetrieveSpecials();

11
VB/Project/Visitors/AbstractASTVisitor.cs

@ -31,17 +31,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
return addressOfExpression.Expression.AcceptVisitor(this, data); return addressOfExpression.Expression.AcceptVisitor(this, data);
} }
public virtual object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
Debug.Assert((anonymousMethodExpression != null));
Debug.Assert((anonymousMethodExpression.Parameters != null));
Debug.Assert((anonymousMethodExpression.Body != null));
foreach (ParameterDeclarationExpression o in anonymousMethodExpression.Parameters) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
return anonymousMethodExpression.Body.AcceptVisitor(this, data);
}
public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) { public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
Debug.Assert((arrayCreateExpression != null)); Debug.Assert((arrayCreateExpression != null));
Debug.Assert((arrayCreateExpression.CreateType != null)); Debug.Assert((arrayCreateExpression.CreateType != null));

21
VB/Project/Visitors/AbstractAstTransformer.cs

@ -60,27 +60,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
return null; return null;
} }
public virtual object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
Debug.Assert((anonymousMethodExpression != null));
Debug.Assert((anonymousMethodExpression.Parameters != null));
Debug.Assert((anonymousMethodExpression.Body != null));
for (int i = 0; i < anonymousMethodExpression.Parameters.Count; i++) {
ParameterDeclarationExpression o = anonymousMethodExpression.Parameters[i];
Debug.Assert(o != null);
nodeStack.Push(o);
o.AcceptVisitor(this, data);
o = (ParameterDeclarationExpression)nodeStack.Pop();
if (o == null)
anonymousMethodExpression.Parameters.RemoveAt(i--);
else
anonymousMethodExpression.Parameters[i] = o;
}
nodeStack.Push(anonymousMethodExpression.Body);
anonymousMethodExpression.Body.AcceptVisitor(this, data);
anonymousMethodExpression.Body = ((BlockStatement)(nodeStack.Pop()));
return null;
}
public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) { public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
Debug.Assert((arrayCreateExpression != null)); Debug.Assert((arrayCreateExpression != null));
Debug.Assert((arrayCreateExpression.CreateType != null)); Debug.Assert((arrayCreateExpression.CreateType != null));

10
VB/Project/Visitors/LookupTableVisitor.cs

@ -120,16 +120,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors
return base.VisitLocalVariableDeclaration(localVariableDeclaration, data); return base.VisitLocalVariableDeclaration(localVariableDeclaration, data);
} }
public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
{
foreach (ParameterDeclarationExpression p in anonymousMethodExpression.Parameters) {
AddVariable(p.TypeReference, p.ParameterName,
anonymousMethodExpression.StartLocation, anonymousMethodExpression.EndLocation,
false, false, null, null, false);
}
return base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
}
public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data) public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
{ {
foreach (ParameterDeclarationExpression p in lambdaExpression.Parameters) { foreach (ParameterDeclarationExpression p in lambdaExpression.Parameters) {

11
VB/Project/Visitors/NodeTrackingAstVisitor.cs

@ -45,13 +45,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
return result; return result;
} }
public sealed override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
this.BeginVisit(anonymousMethodExpression);
object result = this.TrackedVisitAnonymousMethodExpression(anonymousMethodExpression, data);
this.EndVisit(anonymousMethodExpression);
return result;
}
public sealed override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) { public sealed override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
this.BeginVisit(arrayCreateExpression); this.BeginVisit(arrayCreateExpression);
object result = this.TrackedVisitArrayCreateExpression(arrayCreateExpression, data); object result = this.TrackedVisitArrayCreateExpression(arrayCreateExpression, data);
@ -830,10 +823,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
return base.VisitAddressOfExpression(addressOfExpression, data); return base.VisitAddressOfExpression(addressOfExpression, data);
} }
public virtual object TrackedVisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
return base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
}
public virtual object TrackedVisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) { public virtual object TrackedVisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
return base.VisitArrayCreateExpression(arrayCreateExpression, data); return base.VisitArrayCreateExpression(arrayCreateExpression, data);
} }

4
VB/Project/Visitors/NotImplementedAstVisitor.cs

@ -26,10 +26,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
throw new global::System.NotImplementedException("AddressOfExpression"); throw new global::System.NotImplementedException("AddressOfExpression");
} }
public virtual object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
throw new global::System.NotImplementedException("AnonymousMethodExpression");
}
public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) { public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
throw new global::System.NotImplementedException("ArrayCreateExpression"); throw new global::System.NotImplementedException("ArrayCreateExpression");
} }

8
VB/Test/Output/SpecialOutputVisitorTest.cs

@ -4,10 +4,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.VB.Dom; using ICSharpCode.NRefactory.VB.Dom;
using ICSharpCode.NRefactory.VB.Visitors; using ICSharpCode.NRefactory.VB.Parser;
using ICSharpCode.NRefactory.VB.PrettyPrinter; using ICSharpCode.NRefactory.VB.PrettyPrinter;
using ICSharpCode.NRefactory.VB.Visitors;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter
{ {
@ -16,7 +18,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter
{ {
void TestProgram(string program) void TestProgram(string program)
{ {
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor(); VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();

9
VB/Test/Output/VBNet/VBNetOutputTest.cs

@ -3,10 +3,11 @@
using System; using System;
using System.IO; using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.VB.Dom; using ICSharpCode.NRefactory.VB.Dom;
using ICSharpCode.NRefactory.VB.Visitors; using ICSharpCode.NRefactory.VB.Parser;
using ICSharpCode.NRefactory.VB.PrettyPrinter; using ICSharpCode.NRefactory.VB.PrettyPrinter;
using ICSharpCode.NRefactory.VB.Visitors;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter
{ {
@ -15,7 +16,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter
{ {
void TestProgram(string program) void TestProgram(string program)
{ {
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor(); VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
@ -46,7 +47,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter
void TestExpression(string expression) void TestExpression(string expression)
{ {
IParser parser = ParserFactory.CreateParser(new StringReader(expression)); VBParser parser = ParserFactory.CreateParser(new StringReader(expression));
Expression e = parser.ParseExpression(); Expression e = parser.ParseExpression();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor(); VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();

2
VB/Test/Parser/GlobalScope/OptionDeclarationTests.cs

@ -79,7 +79,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetInvalidOptionDeclarationTest() public void VBNetInvalidOptionDeclarationTest()
{ {
string program = "Option\n"; string program = "Option\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.IsFalse(parser.Errors.ErrorOutput.Length == 0, "Expected errors, but operation completed successfully"); Assert.IsFalse(parser.Errors.ErrorOutput.Length == 0, "Expected errors, but operation completed successfully");
} }

18
VB/Test/Parser/GlobalScope/UsingDeclarationTests.cs

@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetWrongUsingTest() public void VBNetWrongUsingTest()
{ {
string program = "Imports\n"; string program = "Imports\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.IsTrue(parser.Errors.Count > 0); Assert.IsTrue(parser.Errors.Count > 0);
UsingDeclaration u = (UsingDeclaration)parser.CompilationUnit.Children[0]; UsingDeclaration u = (UsingDeclaration)parser.CompilationUnit.Children[0];
@ -74,7 +74,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetWrongUsing2Test() public void VBNetWrongUsing2Test()
{ {
string program = "Imports ,\n"; string program = "Imports ,\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.IsTrue(parser.Errors.Count > 0); Assert.IsTrue(parser.Errors.Count > 0);
UsingDeclaration u = (UsingDeclaration)parser.CompilationUnit.Children[0]; UsingDeclaration u = (UsingDeclaration)parser.CompilationUnit.Children[0];
@ -88,7 +88,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
{ {
string program = "Imports System\n" + string program = "Imports System\n" +
"Imports My.Name.Space\n"; "Imports My.Name.Space\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -101,7 +101,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
string program = "Imports TESTME=System\n" + string program = "Imports TESTME=System\n" +
"Imports myAlias=My.Name.Space\n" + "Imports myAlias=My.Name.Space\n" +
"Imports StringCollection = System.Collections.Generic.List(Of string)\n"; "Imports StringCollection = System.Collections.Generic.List(Of string)\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -112,7 +112,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetComplexUsingAliasDeclarationTest() public void VBNetComplexUsingAliasDeclarationTest()
{ {
string program = "Imports NS1, AL=NS2, NS3, AL2=NS4, NS5\n"; string program = "Imports NS1, AL=NS2, NS3, AL2=NS4, NS5\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -123,7 +123,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetXmlNamespaceUsingTest() public void VBNetXmlNamespaceUsingTest()
{ {
string program = "Imports <xmlns=\"http://icsharpcode.net/sharpdevelop/avalonedit\">"; string program = "Imports <xmlns=\"http://icsharpcode.net/sharpdevelop/avalonedit\">";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -144,7 +144,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetXmlNamespaceWithPrefixUsingTest() public void VBNetXmlNamespaceWithPrefixUsingTest()
{ {
string program = "Imports <xmlns:avalonedit=\"http://icsharpcode.net/sharpdevelop/avalonedit\">"; string program = "Imports <xmlns:avalonedit=\"http://icsharpcode.net/sharpdevelop/avalonedit\">";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -165,7 +165,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetXmlNamespaceSingleQuotedUsingTest() public void VBNetXmlNamespaceSingleQuotedUsingTest()
{ {
string program = "Imports <xmlns='http://icsharpcode.net/sharpdevelop/avalonedit'>"; string program = "Imports <xmlns='http://icsharpcode.net/sharpdevelop/avalonedit'>";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -186,7 +186,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetXmlNamespaceSingleQuotedWithPrefixUsingTest() public void VBNetXmlNamespaceSingleQuotedWithPrefixUsingTest()
{ {
string program = "Imports <xmlns:avalonedit='http://icsharpcode.net/sharpdevelop/avalonedit'>"; string program = "Imports <xmlns:avalonedit='http://icsharpcode.net/sharpdevelop/avalonedit'>";
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);

4
VB/Test/Parser/ParseUtil.cs

@ -18,7 +18,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public static T ParseGlobal<T>(string program, bool expectErrors) where T : INode public static T ParseGlobal<T>(string program, bool expectErrors) where T : INode
{ {
IParser parser = ParserFactory.CreateParser(new StringReader(program)); VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse(); parser.Parse();
if (expectErrors) if (expectErrors)
@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public static T ParseExpression<T>(string expr, bool expectErrors) where T : INode public static T ParseExpression<T>(string expr, bool expectErrors) where T : INode
{ {
IParser parser = ParserFactory.CreateParser(new StringReader(expr)); VBParser parser = ParserFactory.CreateParser(new StringReader(expr));
INode parsedExpression = parser.ParseExpression(); INode parsedExpression = parser.ParseExpression();
if (expectErrors) if (expectErrors)
Assert.IsFalse(parser.Errors.ErrorOutput.Length == 0, "Expected errors, but operation completed successfully"); Assert.IsFalse(parser.Errors.ErrorOutput.Length == 0, "Expected errors, but operation completed successfully");

Loading…
Cancel
Save