Browse Source

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

newNRvisualizers
Siegfried Pammer 15 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- @@ -12,11 +12,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VB", "VB", "{61F5C042-086B-
ProjectSection(SolutionItems) = postProject
EndProjectSection
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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.VB", "VB\Project\ICSharpCode.NRefactory.VB.csproj", "{7B82B671-419F-45F4-B778-D9286F996EFA}"
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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj", "{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}"
EndProject
@ -64,8 +64,8 @@ Global @@ -64,8 +64,8 @@ Global
{870115DD-960A-4406-A6B9-600BCDC36A03}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
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}
{7B82B671-419F-45F4-B778-D9286F996EFA} = {61F5C042-086B-45DD-999E-01B1A78A4619}
{870115DD-960A-4406-A6B9-600BCDC36A03} = {61F5C042-086B-45DD-999E-01B1A78A4619}
EndGlobalSection
EndGlobal

66
VB/Project/Dom/Generated.cs

@ -80,56 +80,6 @@ namespace ICSharpCode.NRefactory.VB.Dom { @@ -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 {
TypeReference createType;
@ -2192,15 +2142,15 @@ namespace ICSharpCode.NRefactory.VB.Dom { @@ -2192,15 +2142,15 @@ namespace ICSharpCode.NRefactory.VB.Dom {
if (trueStatement != null) trueStatement.Parent = this;
}
public bool HasElseIfSections {
public bool HasElseStatements {
get {
return elseIfSections.Count > 0;
return falseStatement.Count > 0;
}
}
public bool HasElseStatements {
public bool HasElseIfSections {
get {
return falseStatement.Count > 0;
return elseIfSections.Count > 0;
}
}
@ -5083,15 +5033,15 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L @@ -5083,15 +5033,15 @@ public UsingDeclaration(string @namespace, TypeReference alias) { usings = new L
attributes = new List<XmlExpression>();
}
public bool NameIsExpression {
public bool IsExpression {
get {
return !nameExpression.IsNull;
return !content.IsNull;
}
}
public bool IsExpression {
public bool NameIsExpression {
get {
return !content.IsNull;
return !nameExpression.IsNull;
}
}

2
VB/Project/IAstVisitor.cs

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

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

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

106
VB/Project/Parser/AbstractParser.cs

@ -1,106 +0,0 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ -8,7 +8,7 @@ namespace ICSharpCode.NRefactory.VB.Parser
internal class ParamModifierList
{
ParameterModifiers cur;
Parser parser;
VBParser parser;
public ParameterModifiers Modifier {
get {
@ -16,7 +16,7 @@ namespace ICSharpCode.NRefactory.VB.Parser @@ -16,7 +16,7 @@ namespace ICSharpCode.NRefactory.VB.Parser
}
}
public ParamModifierList(Parser parser)
public ParamModifierList(VBParser parser)
{
this.parser = parser;
cur = ParameterModifiers.None;

190
VB/Project/Parser/Parser.cs

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

119
VB/Project/Parser/Parser.frame

@ -0,0 +1,119 @@ @@ -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; @@ -12,13 +12,21 @@ using ICSharpCode.NRefactory.VB.Visitors;
namespace ICSharpCode.NRefactory.VB.Parser
{
internal sealed partial class Parser : AbstractParser
public partial class VBParser
{
Lexer lexer;
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.blockStack = new Stack<INode>();
}
@ -42,7 +50,7 @@ namespace ICSharpCode.NRefactory.VB.Parser @@ -42,7 +50,7 @@ namespace ICSharpCode.NRefactory.VB.Parser
}
}
private StringBuilder qualidentBuilder = new StringBuilder();
StringBuilder qualidentBuilder = new StringBuilder();
Token t
{
@ -78,19 +86,19 @@ namespace ICSharpCode.NRefactory.VB.Parser @@ -78,19 +86,19 @@ namespace ICSharpCode.NRefactory.VB.Parser
errDist = 0;
}
public override void Parse()
public void Parse()
{
ParseRoot();
compilationUnit.AcceptVisitor(new SetParentVisitor(), null);
}
public override TypeReference ParseTypeReference ()
public TypeReference ParseTypeReference ()
{
// TODO
return null;
}
public override Expression ParseExpression()
public Expression ParseExpression()
{
lexer.SetInitialContext(SnippetType.Expression);
lexer.NextToken();
@ -107,7 +115,7 @@ namespace ICSharpCode.NRefactory.VB.Parser @@ -107,7 +115,7 @@ namespace ICSharpCode.NRefactory.VB.Parser
return expr;
}
public override BlockStatement ParseBlock()
public BlockStatement ParseBlock()
{
lexer.NextToken();
compilationUnit = new CompilationUnit();
@ -127,9 +135,9 @@ namespace ICSharpCode.NRefactory.VB.Parser @@ -127,9 +135,9 @@ namespace ICSharpCode.NRefactory.VB.Parser
return st as BlockStatement;
}
public override List<INode> ParseTypeMembers()
public List<INode> ParseTypeMembers()
{
lexer.NextToken();
lexer.NextToken();
TypeDeclaration newType = new TypeDeclaration(Modifiers.None, null);
BlockStart(newType);
ClassBody(newType);
@ -139,12 +147,6 @@ namespace ICSharpCode.NRefactory.VB.Parser @@ -139,12 +147,6 @@ namespace ICSharpCode.NRefactory.VB.Parser
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 */
bool DotAndIdentOrKw () {
int peek = Peek(1).kind;
@ -383,5 +385,71 @@ namespace ICSharpCode.NRefactory.VB.Parser @@ -383,5 +385,71 @@ namespace ICSharpCode.NRefactory.VB.Parser
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 @@ @@ -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 @@ @@ -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 @@ @@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
@ -7,7 +8,8 @@ using ICSharpCode.NRefactory.VB.Dom; @@ -7,7 +8,8 @@ using ICSharpCode.NRefactory.VB.Dom;
using ICSharpCode.NRefactory.VB.Parser;
using ASTAttribute = ICSharpCode.NRefactory.VB.Dom.Attribute;
COMPILER VBNET
COMPILER VB
$trace=FG
/* START AUTOGENERATED TOKENS SECTION */
TOKENS
@ -20,7 +22,7 @@ TOKENS @@ -20,7 +22,7 @@ TOKENS
LiteralInteger
LiteralDouble
LiteralSingle
LiteralDecimal
LiteralDecimal
LiteralDate
XmlOpenTag
XmlCloseTag
@ -53,7 +55,7 @@ TOKENS @@ -53,7 +55,7 @@ TOKENS
"}"
"("
")"
">"
">"
"<"
"<>"
">="
@ -258,7 +260,7 @@ TOKENS @@ -258,7 +260,7 @@ TOKENS
PRODUCTIONS
VBNET
VB
(.
lexer.NextToken(); // get the first token
compilationUnit = new CompilationUnit();
@ -270,7 +272,6 @@ VBNET @@ -270,7 +272,6 @@ VBNET
{ ImportsStmt { EndOfStmt } }
{ IF (IsGlobalAttrTarget()) GlobalAttributeSection { EndOfStmt } }
{ NamespaceMemberDecl { EndOfStmt } }
EOF
.
OptionStmt (. INode node = null; bool val = true; .) =
@ -297,7 +298,7 @@ OptionStmt (. INode node = null; bool val = true; .) = @@ -297,7 +298,7 @@ OptionStmt (. INode node = null; bool val = true; .) =
AddChild(node);
}
.)
.
.
OptionValue<ref bool val> =
(
@ -386,7 +387,7 @@ NamespaceMemberDecl @@ -386,7 +387,7 @@ NamespaceMemberDecl
.
/* 4.9.1 */
TypeParameterList<List<TemplateDefinition> templates>
TypeParameterList<.List<TemplateDefinition> templates.>
(.
TemplateDefinition template;
.)
@ -452,7 +453,7 @@ TypeParameterConstraint<out TypeReference constraint> @@ -452,7 +453,7 @@ TypeParameterConstraint<out TypeReference constraint>
.
/* 6.4.2 */
NonModuleDeclaration<ModifierList m, List<AttributeSection> attributes>
NonModuleDeclaration<.ModifierList m, List<AttributeSection> attributes.>
(.
TypeReference typeRef = null;
List<TypeReference> baseInterfaces = null;
@ -790,7 +791,7 @@ EnumMemberDecl<out FieldDeclaration f> @@ -790,7 +791,7 @@ EnumMemberDecl<out FieldDeclaration f>
EndOfStmt
.
ClassMemberDecl<ModifierList m, List<AttributeSection> attributes> =
ClassMemberDecl<.ModifierList m, List<AttributeSection> attributes.> =
StructureMemberDecl<m, attributes>
.
@ -804,7 +805,7 @@ ClassBaseType<out TypeReference typeRef> @@ -804,7 +805,7 @@ ClassBaseType<out TypeReference typeRef>
.
/* 7.6.1 */
StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
StructureMemberDecl<.ModifierList m, List<AttributeSection> attributes.>
(.
TypeReference type = null;
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
@ -1395,7 +1396,7 @@ AccessorDecls<out PropertyGetRegion getBlock, out PropertySetRegion setBlock> @@ -1395,7 +1396,7 @@ AccessorDecls<out PropertyGetRegion getBlock, out PropertySetRegion setBlock>
.
/* 9.7.1 */
GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attributes>
GetAccessorDecl<.out PropertyGetRegion getBlock, List<AttributeSection> attributes.>
(. Statement stmt = null; Modifiers m; .)
=
PropertyAccessorAccessModifier<out m>
@ -1411,7 +1412,7 @@ GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attribute @@ -1411,7 +1412,7 @@ GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attribute
.
/* 9.7.2 */
SetAccessorDecl<out PropertySetRegion setBlock, List<AttributeSection> attributes>
SetAccessorDecl<.out PropertySetRegion setBlock, List<AttributeSection> attributes.>
(.
Statement stmt = null;
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
@ -1435,7 +1436,7 @@ SetAccessorDecl<out PropertySetRegion setBlock, List<AttributeSection> attribute @@ -1435,7 +1436,7 @@ SetAccessorDecl<out PropertySetRegion setBlock, List<AttributeSection> attribute
.
/* 9.5 */
ConstantDeclarator<List<VariableDeclaration> constantDeclaration>
ConstantDeclarator<.List<VariableDeclaration> constantDeclaration.>
(.
Expression expr = null;
TypeReference type = null;
@ -1454,13 +1455,13 @@ ConstantDeclarator<List<VariableDeclaration> constantDeclaration> @@ -1454,13 +1455,13 @@ ConstantDeclarator<List<VariableDeclaration> constantDeclaration>
.
/* 9.6 */
VariableDeclarator<List<VariableDeclaration> fieldDeclaration>
VariableDeclarator<.List<VariableDeclaration> fieldDeclaration.>
=
Identifier (. string name = t.val; .)
VariableDeclaratorPartAfterIdentifier<fieldDeclaration, name>
.
VariableDeclaratorPartAfterIdentifier<List<VariableDeclaration> fieldDeclaration, string name>
VariableDeclaratorPartAfterIdentifier<.List<VariableDeclaration> fieldDeclaration, string name.>
(.
Expression expr = null;
TypeReference type = null;
@ -1528,7 +1529,7 @@ VariableDeclaratorPartAfterIdentifier<List<VariableDeclaration> fieldDeclaration @@ -1528,7 +1529,7 @@ VariableDeclaratorPartAfterIdentifier<List<VariableDeclaration> fieldDeclaration
.
/* 6.8 */
ArrayInitializationModifier<out List<Expression> arrayModifiers>
ArrayInitializationModifier<.out List<Expression> arrayModifiers.>
(.
arrayModifiers = null;
.) =
@ -1536,7 +1537,7 @@ ArrayInitializationModifier<out List<Expression> arrayModifiers> @@ -1536,7 +1537,7 @@ ArrayInitializationModifier<out List<Expression> arrayModifiers>
.
/* 7.5.4.3 */
InitializationRankList<out List<Expression> rank>
InitializationRankList<.out List<Expression> rank.>
(.
rank = new List<Expression>();
Expression expr = null;
@ -1589,7 +1590,7 @@ Charset<out CharsetModifier charsetModifier> @@ -1589,7 +1590,7 @@ Charset<out CharsetModifier charsetModifier>
.
/* 9.2.6 */
HandlesClause<out List<string> handlesClause>
HandlesClause<.out List<string> handlesClause.>
(.
handlesClause = new List<string>();
string name;
@ -1599,7 +1600,7 @@ HandlesClause<out List<string> handlesClause> @@ -1599,7 +1600,7 @@ HandlesClause<out List<string> handlesClause>
.
/* 7.8. */
InterfaceBase<out List<TypeReference> bases>
InterfaceBase<.out List<TypeReference> bases.>
(.
TypeReference type;
bases = new List<TypeReference>();
@ -1614,7 +1615,7 @@ InterfaceBase<out List<TypeReference> bases> @@ -1614,7 +1615,7 @@ InterfaceBase<out List<TypeReference> bases>
.
/* 7.2 */
TypeImplementsClause<out List<TypeReference> baseInterfaces>
TypeImplementsClause<.out List<TypeReference> baseInterfaces.>
(.
baseInterfaces = new List<TypeReference>();
TypeReference type = null;
@ -1631,7 +1632,7 @@ TypeImplementsClause<out List<TypeReference> baseInterfaces> @@ -1631,7 +1632,7 @@ TypeImplementsClause<out List<TypeReference> baseInterfaces>
.
/* 9.1 */
ImplementsClause<out List<InterfaceImplementation> baseInterfaces>
ImplementsClause<.out List<InterfaceImplementation> baseInterfaces.>
(.
baseInterfaces = new List<InterfaceImplementation>();
TypeReference type = null;
@ -1827,7 +1828,7 @@ XmlLiteralExpression<out Expression pexpr> @@ -1827,7 +1828,7 @@ XmlLiteralExpression<out Expression pexpr>
.)
.
XmlContentExpression<List<XmlExpression> exprs> =
XmlContentExpression<.List<XmlExpression> exprs.> =
(. XmlContentExpression expr = null; .)
(
XmlContent (. expr = new XmlContentExpression(t.val, XmlContentType.Text); .)
@ -1875,7 +1876,7 @@ XmlElement<out XmlExpression expr> @@ -1875,7 +1876,7 @@ XmlElement<out XmlExpression expr>
(. expr = el; .)
.
XmlAttribute<List<XmlExpression> attrs>
XmlAttribute<.List<XmlExpression> attrs.>
(. Location start = la.Location; .)
=
Identifier (. string name = t.val; .) "="
@ -1934,7 +1935,6 @@ InvocationExpression<ref Expression pexpr> @@ -1934,7 +1935,6 @@ InvocationExpression<ref Expression pexpr>
.
/* 11.11 */
CastTarget<out TypeReference type>
(.
type = null;
@ -2300,7 +2300,7 @@ QueryExpr<out Expression expr> @@ -2300,7 +2300,7 @@ QueryExpr<out Expression expr>
.)
.
FromOrAggregateQueryOperator<List<QueryExpressionClause> middleClauses>
FromOrAggregateQueryOperator<.List<QueryExpressionClause> middleClauses.>
(.
QueryExpressionFromClause fromClause = null;
QueryExpressionAggregateClause aggregateClause = null;
@ -2311,7 +2311,7 @@ FromOrAggregateQueryOperator<List<QueryExpressionClause> middleClauses> @@ -2311,7 +2311,7 @@ FromOrAggregateQueryOperator<List<QueryExpressionClause> middleClauses>
(. middleClauses.Add(aggregateClause); .)
.
QueryOperator<List<QueryExpressionClause> middleClauses>
QueryOperator<.List<QueryExpressionClause> middleClauses.>
(.
QueryExpressionJoinVBClause joinClause = null;
QueryExpressionGroupVBClause groupByClause = null;
@ -2339,7 +2339,7 @@ QueryOperator<List<QueryExpressionClause> middleClauses> @@ -2339,7 +2339,7 @@ QueryOperator<List<QueryExpressionClause> middleClauses>
(. middleClauses.Add(groupByClause); .)
.
OrderByQueryOperator<List<QueryExpressionClause> middleClauses>
OrderByQueryOperator<.List<QueryExpressionClause> middleClauses.>
(.
QueryExpressionOrderClause orderClause = new QueryExpressionOrderClause();
orderClause.StartLocation = la.Location;
@ -2353,7 +2353,7 @@ OrderByQueryOperator<List<QueryExpressionClause> middleClauses> @@ -2353,7 +2353,7 @@ OrderByQueryOperator<List<QueryExpressionClause> middleClauses>
.)
.
OrderExpressionList<out List<QueryExpressionOrdering> orderings>
OrderExpressionList<.out List<QueryExpressionOrdering> orderings.>
(.
orderings = new List<QueryExpressionOrdering>();
QueryExpressionOrdering ordering = null;
@ -2422,7 +2422,7 @@ FromQueryOperator<out QueryExpressionFromClause fromClause> @@ -2422,7 +2422,7 @@ FromQueryOperator<out QueryExpressionFromClause fromClause>
.)
.
SelectQueryOperator<List<QueryExpressionClause> middleClauses>
SelectQueryOperator<.List<QueryExpressionClause> middleClauses.>
(.
QueryExpressionSelectVBClause selectClause = new QueryExpressionSelectVBClause();
selectClause.StartLocation = la.Location;
@ -2434,7 +2434,7 @@ SelectQueryOperator<List<QueryExpressionClause> middleClauses> @@ -2434,7 +2434,7 @@ SelectQueryOperator<List<QueryExpressionClause> middleClauses>
.)
.
DistinctQueryOperator<List<QueryExpressionClause> middleClauses>
DistinctQueryOperator<.List<QueryExpressionClause> middleClauses.>
(.
QueryExpressionDistinctClause distinctClause = new QueryExpressionDistinctClause();
distinctClause.StartLocation = la.Location;
@ -2446,7 +2446,7 @@ DistinctQueryOperator<List<QueryExpressionClause> middleClauses> @@ -2446,7 +2446,7 @@ DistinctQueryOperator<List<QueryExpressionClause> middleClauses>
.)
.
WhereQueryOperator<List<QueryExpressionClause> middleClauses>
WhereQueryOperator<.List<QueryExpressionClause> middleClauses.>
(.
QueryExpressionWhereClause whereClause = new QueryExpressionWhereClause();
whereClause.StartLocation = la.Location;
@ -2500,7 +2500,7 @@ AggregateQueryOperator<out QueryExpressionAggregateClause aggregateClause> @@ -2500,7 +2500,7 @@ AggregateQueryOperator<out QueryExpressionAggregateClause aggregateClause>
.)
.
LetQueryOperator<List<QueryExpressionClause> middleClauses>
LetQueryOperator<.List<QueryExpressionClause> middleClauses.>
(.
QueryExpressionLetVBClause letClause = new QueryExpressionLetVBClause();
letClause.StartLocation = la.Location;
@ -2512,7 +2512,7 @@ LetQueryOperator<List<QueryExpressionClause> middleClauses> @@ -2512,7 +2512,7 @@ LetQueryOperator<List<QueryExpressionClause> middleClauses>
.)
.
ExpressionRangeVariableDeclarationList<List<ExpressionRangeVariable> variables>
ExpressionRangeVariableDeclarationList<.List<ExpressionRangeVariable> variables.>
(.
ExpressionRangeVariable variable = null;
.) =
@ -2571,7 +2571,7 @@ JoinQueryOperator<out QueryExpressionJoinVBClause joinClause> @@ -2571,7 +2571,7 @@ JoinQueryOperator<out QueryExpressionJoinVBClause joinClause>
.)
.
CollectionRangeVariableDeclarationList<List<CollectionRangeVariable> rangeVariables>
CollectionRangeVariableDeclarationList<.List<CollectionRangeVariable> rangeVariables.>
(. CollectionRangeVariable variableDeclaration; .)
=
CollectionRangeVariableDeclaration<out variableDeclaration>
@ -2630,7 +2630,7 @@ MemberInitializer<out MemberInitializerExpression memberInitializer> @@ -2630,7 +2630,7 @@ MemberInitializer<out MemberInitializerExpression memberInitializer>
.
/* 9.3.2 */
ArgumentList<out List<Expression> arguments>
ArgumentList<.out List<Expression> arguments.>
(.
arguments = new List<Expression>();
Expression expr = null;
@ -2644,7 +2644,7 @@ ArgumentList<out List<Expression> arguments> @@ -2644,7 +2644,7 @@ ArgumentList<out List<Expression> arguments>
.
/* 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>();
canBeNormal = true; canBeRedim = !IsNamedAssign();
@ -2802,7 +2802,7 @@ RankList<out int i> @@ -2802,7 +2802,7 @@ RankList<out int i>
.
/* 7.12 */
TypeArgumentList<List<TypeReference> typeArguments>
TypeArgumentList<.List<TypeReference> typeArguments.>
(.
TypeReference typeref;
.) =
@ -2853,7 +2853,7 @@ Attribute<out ASTAttribute attribute> @@ -2853,7 +2853,7 @@ Attribute<out ASTAttribute attribute>
.
/* Spec, 5.2.2 */
AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> named>
AttributeArguments<.List<Expression> positional, List<NamedArgumentExpression> named.>
(.
bool nameFound = false;
string name = "";
@ -2930,7 +2930,7 @@ AttributeSection<out AttributeSection section> @@ -2930,7 +2930,7 @@ AttributeSection<out AttributeSection section>
.
/* 9.2.5 */
FormalParameterList<List<ParameterDeclarationExpression> parameter>
FormalParameterList<.List<ParameterDeclarationExpression> parameter.>
(. ParameterDeclarationExpression p; .)
=
FormalParameter<out p> (. if (p != null) parameter.Add(p); .)
@ -2986,18 +2986,19 @@ Block<out Statement stmt> @@ -2986,18 +2986,19 @@ Block<out Statement stmt>
if (t != null) blockStmt.StartLocation = t.EndLocation;
BlockStart(blockStmt);
.)
{
IF (IsEndStmtAhead())
(. Token first = la; .)
"End" EndOfStmt
(.
AddChild(new EndStatement() {
StartLocation = first.Location,
EndLocation = first.EndLocation }
);
.)
| Statement EndOfStmt
/* IF (!LeaveBlock()) { }*/
{
IF (IsEndStmtAhead() || StartOf(StatementEndOfStmt))
(
"End"
(. Token first = t;
AddChild(new EndStatement() {
StartLocation = first.Location,
EndLocation = first.EndLocation }
);
.) EndOfStmt
|
(.NamedFirstSet:StatementEndOfStmt.) Statement EndOfStmt
)
}
(.
stmt = blockStmt;
@ -3011,10 +3012,9 @@ Statement @@ -3011,10 +3012,9 @@ Statement
Statement stmt = null;
Location startPos = la.Location;
string label = String.Empty;
.) =
(
| IF (IsLabel()) LabelName<out label>
IF (IsLabel()) LabelName<out label>
(.
AddChild(new LabelStatement(t.val));
.)
@ -3070,28 +3070,9 @@ EmbeddedStatement<out Statement statement> @@ -3070,28 +3070,9 @@ EmbeddedStatement<out Statement statement>
List<Expression> p = null;
Location startLocation = la.Location;
.) =
(
"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); .)
( ExitStatement<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 */
"Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .)
| /* 10.11 */
@ -3370,7 +3351,28 @@ EmbeddedStatement<out Statement statement> @@ -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; .)
=
( "End" (. embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
@ -3513,7 +3515,7 @@ ResumeStatement<out ResumeStatement resumeStatement> @@ -3513,7 +3515,7 @@ ResumeStatement<out ResumeStatement resumeStatement>
.
/* 18.8.2 */
CaseClauses<out List<CaseLabel> caseClauses>
CaseClauses<.out List<CaseLabel> caseClauses.>
(.
caseClauses = new List<CaseLabel>();
CaseLabel caseClause = null;
@ -3595,7 +3597,7 @@ TryStatement<out Statement tryStatement> @@ -3595,7 +3597,7 @@ TryStatement<out Statement tryStatement>
.
/* 10.10.1.2 */
CatchClauses<out List<CatchClause> catchClauses>
CatchClauses<.out List<CatchClause> catchClauses.>
(.
catchClauses = new List<CatchClause>();
TypeReference type = null;
@ -3743,4 +3745,4 @@ PropertyAccessorAccessModifier<out Modifiers m> = @@ -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 @@ -23,18 +23,18 @@ namespace ICSharpCode.NRefactory.VB
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);
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);
}
public static IParser CreateParser(string fileName, Encoding encoding)
public static VBParser CreateParser(string fileName, Encoding encoding)
{
string ext = Path.GetExtension(fileName);
if (ext.Equals(".vb", StringComparison.OrdinalIgnoreCase))

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

@ -2339,12 +2339,6 @@ namespace ICSharpCode.NRefactory.VB.PrettyPrinter @@ -2339,12 +2339,6 @@ namespace ICSharpCode.NRefactory.VB.PrettyPrinter
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)
{
if (castExpression.CastType == CastType.TryCast) {
@ -2779,30 +2773,6 @@ namespace ICSharpCode.NRefactory.VB.PrettyPrinter @@ -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)
{
outputFormatter.IndentationLevel++;

2
VB/Project/Properties/AssemblyInfo.cs

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

2
VB/Project/SnippetParser.cs

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

11
VB/Project/Visitors/AbstractASTVisitor.cs

@ -31,17 +31,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors { @@ -31,17 +31,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
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) {
Debug.Assert((arrayCreateExpression != null));
Debug.Assert((arrayCreateExpression.CreateType != null));

21
VB/Project/Visitors/AbstractAstTransformer.cs

@ -60,27 +60,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors { @@ -60,27 +60,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
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) {
Debug.Assert((arrayCreateExpression != null));
Debug.Assert((arrayCreateExpression.CreateType != null));

10
VB/Project/Visitors/LookupTableVisitor.cs

@ -120,16 +120,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors @@ -120,16 +120,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors
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)
{
foreach (ParameterDeclarationExpression p in lambdaExpression.Parameters) {

11
VB/Project/Visitors/NodeTrackingAstVisitor.cs

@ -45,13 +45,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors { @@ -45,13 +45,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
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) {
this.BeginVisit(arrayCreateExpression);
object result = this.TrackedVisitArrayCreateExpression(arrayCreateExpression, data);
@ -830,10 +823,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors { @@ -830,10 +823,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
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) {
return base.VisitArrayCreateExpression(arrayCreateExpression, data);
}

4
VB/Project/Visitors/NotImplementedAstVisitor.cs

@ -26,10 +26,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors { @@ -26,10 +26,6 @@ namespace ICSharpCode.NRefactory.VB.Visitors {
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) {
throw new global::System.NotImplementedException("ArrayCreateExpression");
}

8
VB/Test/Output/SpecialOutputVisitorTest.cs

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

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

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

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

@ -79,7 +79,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -79,7 +79,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetInvalidOptionDeclarationTest()
{
string program = "Option\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program));
VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse();
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 @@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetWrongUsingTest()
{
string program = "Imports\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program));
VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse();
Assert.IsTrue(parser.Errors.Count > 0);
UsingDeclaration u = (UsingDeclaration)parser.CompilationUnit.Children[0];
@ -74,7 +74,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -74,7 +74,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetWrongUsing2Test()
{
string program = "Imports ,\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program));
VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse();
Assert.IsTrue(parser.Errors.Count > 0);
UsingDeclaration u = (UsingDeclaration)parser.CompilationUnit.Children[0];
@ -88,7 +88,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -88,7 +88,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
{
string program = "Imports System\n" +
"Imports My.Name.Space\n";
IParser parser = ParserFactory.CreateParser(new StringReader(program));
VBParser parser = ParserFactory.CreateParser(new StringReader(program));
parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -101,7 +101,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -101,7 +101,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
string program = "Imports TESTME=System\n" +
"Imports myAlias=My.Name.Space\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();
Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -112,7 +112,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -112,7 +112,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetComplexUsingAliasDeclarationTest()
{
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();
Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -123,7 +123,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -123,7 +123,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetXmlNamespaceUsingTest()
{
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();
Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -144,7 +144,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -144,7 +144,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetXmlNamespaceWithPrefixUsingTest()
{
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();
Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -165,7 +165,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -165,7 +165,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetXmlNamespaceSingleQuotedUsingTest()
{
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();
Assert.AreEqual("", parser.Errors.ErrorOutput);
@ -186,7 +186,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -186,7 +186,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
public void VBNetXmlNamespaceSingleQuotedWithPrefixUsingTest()
{
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();
Assert.AreEqual("", parser.Errors.ErrorOutput);

4
VB/Test/Parser/ParseUtil.cs

@ -18,7 +18,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -18,7 +18,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
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();
if (expectErrors)
@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom @@ -76,7 +76,7 @@ namespace ICSharpCode.NRefactory.VB.Tests.Dom
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();
if (expectErrors)
Assert.IsFalse(parser.Errors.ErrorOutput.Length == 0, "Expected errors, but operation completed successfully");

Loading…
Cancel
Save