Browse Source

- fixed VB Unit Tests

- started implementation of XML-Mode in VB Lexer

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5898 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 15 years ago
parent
commit
aef001350c
  1. 12
      src/Libraries/NRefactory/Project/NRefactory.csproj
  2. 8
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/KeywordList.txt
  3. 1
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Keywords.cs
  4. 387
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs
  5. 440
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Tokens.cs
  6. 4644
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  7. 23
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg
  8. 13
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.cs
  9. 1244
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs
  10. 37
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/VBNetParserTests.cs
  11. 2
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/VBParserExperiment.csproj
  12. 47
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/XmlModeLexerTests.cs
  13. 5672
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  14. 77
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  15. 6
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs
  16. 7
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerTests.cs
  17. 4
      src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs

12
src/Libraries/NRefactory/Project/NRefactory.csproj

@ -53,9 +53,13 @@ @@ -53,9 +53,13 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Src\Parser\VBNet\Experimental\ExpressionFinder.cs" />
<Compile Include="Src\Parser\VBNet\Experimental\Parser.cs">
<DependentUpon>ExpressionFinder.atg</DependentUpon>
</Compile>
<None Include="Resources\ICSharpCode.NRefactory.snk" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\AstBuilder\ExpressionBuilder.cs" />
@ -84,9 +88,6 @@ @@ -84,9 +88,6 @@
<Compile Include="Src\OperatorPrecedence.cs" />
<Compile Include="Src\Parser\CSharp\CSharpParser.cs" />
<Compile Include="Src\Parser\CSharp\Parser.cs" />
<Compile Include="Src\Parser\VBNet\Experimental\Parser.cs">
<DependentUpon>ExpressionFinder.atg</DependentUpon>
</Compile>
<Compile Include="Src\Parser\VBNet\Parser.cs" />
<Compile Include="Src\Parser\VBNet\VBNetParser.cs" />
<Compile Include="Src\Parser\AbstractParser.cs" />
@ -157,9 +158,7 @@ @@ -157,9 +158,7 @@
<Content Include="Src\Lexer\VBNet\KeywordList.txt" />
<Folder Include="Src\Parser" />
<Folder Include="Src\Parser\CSharp" />
<Content Include="Src\Parser\CSharp\cs.ATG">
<Generator>CocoParserGenerator</Generator>
</Content>
<Content Include="Src\Parser\CSharp\cs.ATG" />
<Folder Include="Src\Parser\Frames" />
<Content Include="Src\Parser\Frames\Scanner.frame" />
<Content Include="Src\Parser\Frames\SharpCoco.exe" />
@ -167,7 +166,6 @@ @@ -167,7 +166,6 @@
<Folder Include="Src\Parser\VBNet" />
<None Include="Src\Parser\VBNet\VBNET.ATG">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<Generator>CocoParserGenerator</Generator>
<CustomToolNamespace>ICSharpCode.NRefactory.Parser.VB</CustomToolNamespace>
</None>
<Content Include="Src\Parser\gen.bat" />

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

@ -19,6 +19,13 @@ LiteralDouble @@ -19,6 +19,13 @@ LiteralDouble
LiteralSingle
LiteralDecimal
LiteralDate
# XML_TERMINALS
XmlOpenTag
XmlCloseTag
XmlStartInlineVB
XmlEndInlineVB
XmlCloseTagEmptyElement
XmlOpenEndTag
# SPECIAL_CHARACTERS
Assign = "="
@ -156,6 +163,7 @@ ConcatStringAssign = "&=" @@ -156,6 +163,7 @@ ConcatStringAssign = "&="
"IsNot"
# Note: IsTrue and IsFalse are 'NOT' keywords they're only valid in Operator declarations (like get/set/value are no C# 'keywords')
"Join"
"Key"
"Let"
"Lib"
"Like"

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

@ -97,6 +97,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -97,6 +97,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"IS",
"ISNOT",
"JOIN",
"KEY",
"LET",
"LIB",
"LIKE",

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

@ -9,6 +9,8 @@ using System; @@ -9,6 +9,8 @@ using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
using ICSharpCode.NRefactory.Parser.VBNet.Experimental;
namespace ICSharpCode.NRefactory.Parser.VB
{
@ -17,8 +19,11 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -17,8 +19,11 @@ namespace ICSharpCode.NRefactory.Parser.VB
bool lineEnd = true;
bool isAtLineBegin = false; // TODO: handle line begin, if neccessarry
ExpressionFinder ef;
public Lexer(TextReader reader) : base(reader)
{
ef = new ExpressionFinder();
}
public override Token NextToken()
@ -26,6 +31,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -26,6 +31,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
if (curToken == null) { // first call of NextToken()
curToken = Next();
specialTracker.InformToken(curToken.kind);
ef.InformToken(curToken);
//Console.WriteLine("Tok:" + Tokens.GetTokenString(curToken.kind) + " --- " + curToken.val);
return curToken;
}
@ -35,6 +41,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -35,6 +41,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
if (curToken.next == null) {
curToken.next = Next();
specialTracker.InformToken(curToken.next.kind);
ef.InformToken(curToken);
}
curToken = curToken.next;
@ -42,14 +49,18 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -42,14 +49,18 @@ namespace ICSharpCode.NRefactory.Parser.VB
if (curToken.kind == Tokens.EOF && !(lastToken.kind == Tokens.EOL)) { // be sure that before EOF there is an EOL token
curToken = new Token(Tokens.EOL, curToken.col, curToken.line, string.Empty);
specialTracker.InformToken(curToken.kind);
ef.InformToken(curToken);
curToken.next = new Token(Tokens.EOF, curToken.col, curToken.line, string.Empty);
specialTracker.InformToken(curToken.next.kind);
ef.InformToken(curToken);
}
//Console.WriteLine("Tok:" + Tokens.GetTokenString(curToken.kind) + " --- " + curToken.val);
return curToken;
}
bool misreadExclamationMarkAsTypeCharacter;
bool inXmlMode, expectXmlIdentifier, inXmlTag, inXmlCloseTag;
int level = 0;
protected override Token Next()
{
@ -64,170 +75,229 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -64,170 +75,229 @@ namespace ICSharpCode.NRefactory.Parser.VB
if (nextChar == -1)
return new Token(Tokens.EOF, Col, Line, string.Empty);
char ch = (char)nextChar;
if (Char.IsWhiteSpace(ch)) {
if (HandleLineEnd(ch)) {
if (lineEnd) {
// second line end before getting to a token
// -> here was a blank line
specialTracker.AddEndOfLine(startLocation);
} else {
lineEnd = true;
return new Token(Tokens.EOL, startLocation, new Location(Col, Line), null, null, LiteralFormat.None);
}
}
continue;
if (inXmlMode && level <= 0) {
// int peek;
// while ((peek = ReaderPeek()) != -1 && XmlConvert.IsWhitespaceChar((char)peek)) ;
//
// inXmlMode = ReaderPeek() == '<' &&
// ReaderPeek() == '!' &&
// ReaderPeek() == '-' &&
// ReaderPeek() == '-';
inXmlMode = false;
}
if (ch == '_') {
if (ReaderPeek() == -1) {
errors.Error(Line, Col, String.Format("No EOF expected after _"));
return new Token(Tokens.EOF, Col, Line, string.Empty);
}
if (!Char.IsWhiteSpace((char)ReaderPeek())) {
int x = Col - 1;
int y = Line;
string s = ReadIdent('_');
lineEnd = false;
return new Token(Tokens.Identifier, x, y, s);
}
ch = (char)ReaderRead();
if (inXmlMode) {
switch (ch) {
case '<':
if (ReaderPeek() == '/') {
inXmlCloseTag = true;
return new Token(Tokens.XmlOpenEndTag, Col - 1, Line);
}
if (ReaderPeek() == '%') {
// TODO : suspend xml mode tracking
return new Token(Tokens.XmlStartInlineVB, Col - 1, Line);
}
bool oldLineEnd = lineEnd;
lineEnd = false;
while (Char.IsWhiteSpace(ch)) {
if (HandleLineEnd(ch)) {
lineEnd = true;
return new Token(Tokens.XmlOpenTag, Col - 1, Line);
case '/':
if (ReaderPeek() == '>')
return new Token(Tokens.XmlCloseTagEmptyElement, Col - 1, Line);
break;
case '%':
if (ReaderPeek() == '>') {
// TODO : resume xml mode tracking
return new Token(Tokens.XmlEndInlineVB, Col - 1, Line);
}
break;
case '>':
if (inXmlCloseTag)
level--;
return new Token(Tokens.XmlCloseTag, Col - 1, Line);
case '=':
return new Token(Tokens.Equals, Col - 1, Line);
case '\'':
case '"':
int x = Col - 1;
int y = Line;
string s = ReadXmlString(ch);
return new Token(Tokens.LiteralString, Col - 1, Line, '"' + s + '"', s, LiteralFormat.StringLiteral);
default:
// TODO : can be either identifier or xml content
return new Token(Tokens.Identifier, Col - 1, Line, ReadXmlIdent(ch));
}
} else {
if (Char.IsWhiteSpace(ch)) {
if (HandleLineEnd(ch)) {
if (lineEnd) {
// second line end before getting to a token
// -> here was a blank line
specialTracker.AddEndOfLine(startLocation);
} else {
lineEnd = true;
return new Token(Tokens.EOL, startLocation, new Location(Col, Line), null, null, LiteralFormat.None);
}
}
if (ReaderPeek() != -1) {
ch = (char)ReaderRead();
} else {
continue;
}
if (ch == '_') {
if (ReaderPeek() == -1) {
errors.Error(Line, Col, String.Format("No EOF expected after _"));
return new Token(Tokens.EOF, Col, Line, string.Empty);
}
}
if (!lineEnd) {
errors.Error(Line, Col, String.Format("Return expected"));
}
lineEnd = oldLineEnd;
continue;
}
if (!Char.IsWhiteSpace((char)ReaderPeek())) {
int x = Col - 1;
int y = Line;
string s = ReadIdent('_');
lineEnd = false;
return new Token(Tokens.Identifier, x, y, s);
}
ch = (char)ReaderRead();
if (ch == '#') {
while (Char.IsWhiteSpace((char)ReaderPeek())) {
ReaderRead();
}
if (Char.IsDigit((char)ReaderPeek())) {
int x = Col - 1;
int y = Line;
string s = ReadDate();
DateTime time = new DateTime(1, 1, 1, 0, 0, 0);
try {
time = DateTime.Parse(s, System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault);
} catch (Exception e) {
errors.Error(Line, Col, String.Format("Invalid date time {0}", e));
bool oldLineEnd = lineEnd;
lineEnd = false;
while (Char.IsWhiteSpace(ch)) {
if (HandleLineEnd(ch)) {
lineEnd = true;
break;
}
if (ReaderPeek() != -1) {
ch = (char)ReaderRead();
} else {
errors.Error(Line, Col, String.Format("No EOF expected after _"));
return new Token(Tokens.EOF, Col, Line, string.Empty);
}
}
return new Token(Tokens.LiteralDate, x, y, s, time, LiteralFormat.DateTimeLiteral);
} else {
ReadPreprocessorDirective();
if (!lineEnd) {
errors.Error(Line, Col, String.Format("Return expected"));
}
lineEnd = oldLineEnd;
continue;
}
}
if (ch == '[') { // Identifier
lineEnd = false;
if (ReaderPeek() == -1) {
errors.Error(Line, Col, String.Format("Identifier expected"));
}
ch = (char)ReaderRead();
if (ch == ']' || Char.IsWhiteSpace(ch)) {
errors.Error(Line, Col, String.Format("Identifier expected"));
}
int x = Col - 1;
int y = Line;
string s = ReadIdent(ch);
if (ReaderPeek() == -1) {
errors.Error(Line, Col, String.Format("']' expected"));
if (ch == '#') {
while (Char.IsWhiteSpace((char)ReaderPeek())) {
ReaderRead();
}
if (Char.IsDigit((char)ReaderPeek())) {
int x = Col - 1;
int y = Line;
string s = ReadDate();
DateTime time = new DateTime(1, 1, 1, 0, 0, 0);
try {
time = DateTime.Parse(s, System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault);
} catch (Exception e) {
errors.Error(Line, Col, String.Format("Invalid date time {0}", e));
}
return new Token(Tokens.LiteralDate, x, y, s, time, LiteralFormat.DateTimeLiteral);
} else {
ReadPreprocessorDirective();
continue;
}
}
ch = (char)ReaderRead();
if (!(ch == ']')) {
errors.Error(Line, Col, String.Format("']' expected"));
if (ch == '[') { // Identifier
lineEnd = false;
if (ReaderPeek() == -1) {
errors.Error(Line, Col, String.Format("Identifier expected"));
}
ch = (char)ReaderRead();
if (ch == ']' || Char.IsWhiteSpace(ch)) {
errors.Error(Line, Col, String.Format("Identifier expected"));
}
int x = Col - 1;
int y = Line;
string s = ReadIdent(ch);
if (ReaderPeek() == -1) {
errors.Error(Line, Col, String.Format("']' expected"));
}
ch = (char)ReaderRead();
if (!(ch == ']')) {
errors.Error(Line, Col, String.Format("']' expected"));
}
return new Token(Tokens.Identifier, x, y, s);
}
return new Token(Tokens.Identifier, x, y, s);
}
if (Char.IsLetter(ch)) {
int x = Col - 1;
int y = Line;
char typeCharacter;
string s = ReadIdent(ch, out typeCharacter);
if (typeCharacter == '\0') {
int keyWordToken = Keywords.GetToken(s);
if (keyWordToken >= 0) {
// handle 'REM' comments
if (keyWordToken == Tokens.Rem) {
ReadComment();
if (!lineEnd) {
lineEnd = true;
return new Token(Tokens.EOL, Col, Line, "\n");
if (Char.IsLetter(ch)) {
int x = Col - 1;
int y = Line;
char typeCharacter;
string s = ReadIdent(ch, out typeCharacter);
if (typeCharacter == '\0') {
int keyWordToken = Keywords.GetToken(s);
if (keyWordToken >= 0) {
// handle 'REM' comments
if (keyWordToken == Tokens.Rem) {
ReadComment();
if (!lineEnd) {
lineEnd = true;
return new Token(Tokens.EOL, Col, Line, "\n");
}
continue;
}
continue;
}
lineEnd = false;
return new Token(keyWordToken, x, y, s);
lineEnd = false;
return new Token(keyWordToken, x, y, s);
}
}
}
lineEnd = false;
return new Token(Tokens.Identifier, x, y, s);
lineEnd = false;
return new Token(Tokens.Identifier, x, y, s);
}
if (Char.IsDigit(ch)) {
lineEnd = false;
return ReadDigit(ch, Col - 1);
}
if (ch == '&') {
lineEnd = false;
if (ReaderPeek() == -1) {
return ReadOperator('&');
}
ch = (char)ReaderPeek();
if (Char.ToUpper(ch, CultureInfo.InvariantCulture) == 'H' || Char.ToUpper(ch, CultureInfo.InvariantCulture) == 'O') {
return ReadDigit('&', Col - 1);
if (Char.IsDigit(ch)) {
lineEnd = false;
return ReadDigit(ch, Col - 1);
}
return ReadOperator('&');
}
if (ch == '\'' || ch == '\u2018' || ch == '\u2019') {
int x = Col - 1;
int y = Line;
ReadComment();
if (!lineEnd) {
lineEnd = true;
return new Token(Tokens.EOL, x, y, "\n");
if (ch == '&') {
lineEnd = false;
if (ReaderPeek() == -1) {
return ReadOperator('&');
}
ch = (char)ReaderPeek();
if (Char.ToUpper(ch, CultureInfo.InvariantCulture) == 'H' || Char.ToUpper(ch, CultureInfo.InvariantCulture) == 'O') {
return ReadDigit('&', Col - 1);
}
return ReadOperator('&');
}
continue;
}
if (ch == '"') {
lineEnd = false;
int x = Col - 1;
int y = Line;
string s = ReadString();
if (ReaderPeek() != -1 && (ReaderPeek() == 'C' || ReaderPeek() == 'c')) {
ReaderRead();
if (s.Length != 1) {
errors.Error(Line, Col, String.Format("Chars can only have Length 1 "));
if (ch == '\'' || ch == '\u2018' || ch == '\u2019') {
int x = Col - 1;
int y = Line;
ReadComment();
if (!lineEnd) {
lineEnd = true;
return new Token(Tokens.EOL, x, y, "\n");
}
if (s.Length == 0) {
s = "\0";
continue;
}
if (ch == '"') {
lineEnd = false;
int x = Col - 1;
int y = Line;
string s = ReadString();
if (ReaderPeek() != -1 && (ReaderPeek() == 'C' || ReaderPeek() == 'c')) {
ReaderRead();
if (s.Length != 1) {
errors.Error(Line, Col, String.Format("Chars can only have Length 1 "));
}
if (s.Length == 0) {
s = "\0";
}
return new Token(Tokens.LiteralCharacter, x, y, '"' + s + "\"C", s[0], LiteralFormat.CharLiteral);
}
return new Token(Tokens.LiteralCharacter, x, y, '"' + s + "\"C", s[0], LiteralFormat.CharLiteral);
return new Token(Tokens.LiteralString, x, y, '"' + s + '"', s, LiteralFormat.StringLiteral);
}
if (ch == '<' && ef.NextTokenIsPotentialStartOfXmlMode) {
inXmlMode = inXmlTag = true;
level = 1;
return new Token(Tokens.XmlOpenTag, Col - 1, Line);
}
Token token = ReadOperator(ch);
if (token != null) {
lineEnd = false;
return token;
}
return new Token(Tokens.LiteralString, x, y, '"' + s + '"', s, LiteralFormat.StringLiteral);
}
Token token = ReadOperator(ch);
if (token != null) {
lineEnd = false;
return token;
}
errors.Error(Line, Col, String.Format("Unknown char({0}) which can't be read", ch));
}
}
@ -267,6 +337,21 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -267,6 +337,21 @@ namespace ICSharpCode.NRefactory.Parser.VB
return sb.ToString();
}
string ReadXmlIndent(char ch)
{
sb.Length = 0;
sb.Append(ch);
int peek;
while ((peek = ReaderPeek()) != -1 && (peek == ':' || XmlConvert.IsNCNameChar((char)peek))) {
ReaderRead();
sb.Append(ch);
}
return sb.ToString();
}
char PeekUpperChar()
{
return Char.ToUpper((char)ReaderPeek(), CultureInfo.InvariantCulture);
@ -558,6 +643,32 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -558,6 +643,32 @@ namespace ICSharpCode.NRefactory.Parser.VB
return sb.ToString();
}
string ReadXmlString(char terminator)
{
char ch = '\0';
sb.Length = 0;
int nextChar;
while ((nextChar = ReaderRead()) != -1) {
ch = (char)nextChar;
if (ch == terminator) {
if (ReaderPeek() != -1 && ReaderPeek() == terminator) {
sb.Append(terminator);
ReaderRead();
} else {
break;
}
} else if (ch == '\n') {
errors.Error(Line, Col, String.Format("No return allowed inside String literal"));
} else {
sb.Append(ch);
}
}
if (ch != terminator) {
errors.Error(Line, Col, String.Format("End of File reached before String terminated "));
}
return sb.ToString();
}
void ReadComment()
{
Location startPos = new Location(Col, Line);

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

@ -17,224 +17,231 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -17,224 +17,231 @@ namespace ICSharpCode.NRefactory.Parser.VB
public const int LiteralSingle = 7;
public const int LiteralDecimal = 8;
public const int LiteralDate = 9;
public const int XmlOpenTag = 10;
public const int XmlCloseTag = 11;
public const int XmlStartInlineVB = 12;
public const int XmlEndInlineVB = 13;
public const int XmlCloseTagEmptyElement = 14;
public const int XmlOpenEndTag = 15;
// ----- special character -----
public const int Assign = 10;
public const int Colon = 11;
public const int Comma = 12;
public const int ConcatString = 13;
public const int Div = 14;
public const int DivInteger = 15;
public const int Dot = 16;
public const int ExclamationMark = 17;
public const int Minus = 18;
public const int Plus = 19;
public const int Power = 20;
public const int QuestionMark = 21;
public const int Times = 22;
public const int OpenCurlyBrace = 23;
public const int CloseCurlyBrace = 24;
public const int OpenParenthesis = 25;
public const int CloseParenthesis = 26;
public const int GreaterThan = 27;
public const int LessThan = 28;
public const int NotEqual = 29;
public const int GreaterEqual = 30;
public const int LessEqual = 31;
public const int ShiftLeft = 32;
public const int ShiftRight = 33;
public const int PlusAssign = 34;
public const int PowerAssign = 35;
public const int MinusAssign = 36;
public const int TimesAssign = 37;
public const int DivAssign = 38;
public const int DivIntegerAssign = 39;
public const int ShiftLeftAssign = 40;
public const int ShiftRightAssign = 41;
public const int ConcatStringAssign = 42;
public const int Assign = 16;
public const int Colon = 17;
public const int Comma = 18;
public const int ConcatString = 19;
public const int Div = 20;
public const int DivInteger = 21;
public const int Dot = 22;
public const int ExclamationMark = 23;
public const int Minus = 24;
public const int Plus = 25;
public const int Power = 26;
public const int QuestionMark = 27;
public const int Times = 28;
public const int OpenCurlyBrace = 29;
public const int CloseCurlyBrace = 30;
public const int OpenParenthesis = 31;
public const int CloseParenthesis = 32;
public const int GreaterThan = 33;
public const int LessThan = 34;
public const int NotEqual = 35;
public const int GreaterEqual = 36;
public const int LessEqual = 37;
public const int ShiftLeft = 38;
public const int ShiftRight = 39;
public const int PlusAssign = 40;
public const int PowerAssign = 41;
public const int MinusAssign = 42;
public const int TimesAssign = 43;
public const int DivAssign = 44;
public const int DivIntegerAssign = 45;
public const int ShiftLeftAssign = 46;
public const int ShiftRightAssign = 47;
public const int ConcatStringAssign = 48;
// ----- keywords -----
public const int AddHandler = 43;
public const int AddressOf = 44;
public const int Aggregate = 45;
public const int Alias = 46;
public const int And = 47;
public const int AndAlso = 48;
public const int Ansi = 49;
public const int As = 50;
public const int Ascending = 51;
public const int Assembly = 52;
public const int Auto = 53;
public const int Binary = 54;
public const int Boolean = 55;
public const int ByRef = 56;
public const int By = 57;
public const int Byte = 58;
public const int ByVal = 59;
public const int Call = 60;
public const int Case = 61;
public const int Catch = 62;
public const int CBool = 63;
public const int CByte = 64;
public const int CChar = 65;
public const int CDate = 66;
public const int CDbl = 67;
public const int CDec = 68;
public const int Char = 69;
public const int CInt = 70;
public const int Class = 71;
public const int CLng = 72;
public const int CObj = 73;
public const int Compare = 74;
public const int Const = 75;
public const int Continue = 76;
public const int CSByte = 77;
public const int CShort = 78;
public const int CSng = 79;
public const int CStr = 80;
public const int CType = 81;
public const int CUInt = 82;
public const int CULng = 83;
public const int CUShort = 84;
public const int Custom = 85;
public const int Date = 86;
public const int Decimal = 87;
public const int Declare = 88;
public const int Default = 89;
public const int Delegate = 90;
public const int Descending = 91;
public const int Dim = 92;
public const int DirectCast = 93;
public const int Distinct = 94;
public const int Do = 95;
public const int Double = 96;
public const int Each = 97;
public const int Else = 98;
public const int ElseIf = 99;
public const int End = 100;
public const int EndIf = 101;
public const int Enum = 102;
new public const int Equals = 103;
public const int Erase = 104;
public const int Error = 105;
public const int Event = 106;
public const int Exit = 107;
public const int Explicit = 108;
public const int False = 109;
public const int Finally = 110;
public const int For = 111;
public const int Friend = 112;
public const int From = 113;
public const int Function = 114;
public const int Get = 115;
new public const int GetType = 116;
public const int Global = 117;
public const int GoSub = 118;
public const int GoTo = 119;
public const int Group = 120;
public const int Handles = 121;
public const int If = 122;
public const int Implements = 123;
public const int Imports = 124;
public const int In = 125;
public const int Infer = 126;
public const int Inherits = 127;
public const int Integer = 128;
public const int Interface = 129;
public const int Into = 130;
public const int Is = 131;
public const int IsNot = 132;
public const int Join = 133;
public const int Let = 134;
public const int Lib = 135;
public const int Like = 136;
public const int Long = 137;
public const int Loop = 138;
public const int Me = 139;
public const int Mod = 140;
public const int Module = 141;
public const int MustInherit = 142;
public const int MustOverride = 143;
public const int MyBase = 144;
public const int MyClass = 145;
public const int Namespace = 146;
public const int Narrowing = 147;
public const int New = 148;
public const int Next = 149;
public const int Not = 150;
public const int Nothing = 151;
public const int NotInheritable = 152;
public const int NotOverridable = 153;
public const int Object = 154;
public const int Of = 155;
public const int Off = 156;
public const int On = 157;
public const int Operator = 158;
public const int Option = 159;
public const int Optional = 160;
public const int Or = 161;
public const int Order = 162;
public const int OrElse = 163;
public const int Overloads = 164;
public const int Overridable = 165;
public const int Overrides = 166;
public const int ParamArray = 167;
public const int Partial = 168;
public const int Preserve = 169;
public const int Private = 170;
public const int Property = 171;
public const int Protected = 172;
public const int Public = 173;
public const int RaiseEvent = 174;
public const int ReadOnly = 175;
public const int ReDim = 176;
public const int Rem = 177;
public const int RemoveHandler = 178;
public const int Resume = 179;
public const int Return = 180;
public const int SByte = 181;
public const int Select = 182;
public const int Set = 183;
public const int Shadows = 184;
public const int Shared = 185;
public const int Short = 186;
public const int Single = 187;
public const int Skip = 188;
public const int Static = 189;
public const int Step = 190;
public const int Stop = 191;
public const int Strict = 192;
public const int String = 193;
public const int Structure = 194;
public const int Sub = 195;
public const int SyncLock = 196;
public const int Take = 197;
public const int Text = 198;
public const int Then = 199;
public const int Throw = 200;
public const int To = 201;
public const int True = 202;
public const int Try = 203;
public const int TryCast = 204;
public const int TypeOf = 205;
public const int UInteger = 206;
public const int ULong = 207;
public const int Unicode = 208;
public const int Until = 209;
public const int UShort = 210;
public const int Using = 211;
public const int Variant = 212;
public const int Wend = 213;
public const int When = 214;
public const int Where = 215;
public const int While = 216;
public const int Widening = 217;
public const int With = 218;
public const int WithEvents = 219;
public const int WriteOnly = 220;
public const int Xor = 221;
public const int AddHandler = 49;
public const int AddressOf = 50;
public const int Aggregate = 51;
public const int Alias = 52;
public const int And = 53;
public const int AndAlso = 54;
public const int Ansi = 55;
public const int As = 56;
public const int Ascending = 57;
public const int Assembly = 58;
public const int Auto = 59;
public const int Binary = 60;
public const int Boolean = 61;
public const int ByRef = 62;
public const int By = 63;
public const int Byte = 64;
public const int ByVal = 65;
public const int Call = 66;
public const int Case = 67;
public const int Catch = 68;
public const int CBool = 69;
public const int CByte = 70;
public const int CChar = 71;
public const int CDate = 72;
public const int CDbl = 73;
public const int CDec = 74;
public const int Char = 75;
public const int CInt = 76;
public const int Class = 77;
public const int CLng = 78;
public const int CObj = 79;
public const int Compare = 80;
public const int Const = 81;
public const int Continue = 82;
public const int CSByte = 83;
public const int CShort = 84;
public const int CSng = 85;
public const int CStr = 86;
public const int CType = 87;
public const int CUInt = 88;
public const int CULng = 89;
public const int CUShort = 90;
public const int Custom = 91;
public const int Date = 92;
public const int Decimal = 93;
public const int Declare = 94;
public const int Default = 95;
public const int Delegate = 96;
public const int Descending = 97;
public const int Dim = 98;
public const int DirectCast = 99;
public const int Distinct = 100;
public const int Do = 101;
public const int Double = 102;
public const int Each = 103;
public const int Else = 104;
public const int ElseIf = 105;
public const int End = 106;
public const int EndIf = 107;
public const int Enum = 108;
new public const int Equals = 109;
public const int Erase = 110;
public const int Error = 111;
public const int Event = 112;
public const int Exit = 113;
public const int Explicit = 114;
public const int False = 115;
public const int Finally = 116;
public const int For = 117;
public const int Friend = 118;
public const int From = 119;
public const int Function = 120;
public const int Get = 121;
new public const int GetType = 122;
public const int Global = 123;
public const int GoSub = 124;
public const int GoTo = 125;
public const int Group = 126;
public const int Handles = 127;
public const int If = 128;
public const int Implements = 129;
public const int Imports = 130;
public const int In = 131;
public const int Infer = 132;
public const int Inherits = 133;
public const int Integer = 134;
public const int Interface = 135;
public const int Into = 136;
public const int Is = 137;
public const int IsNot = 138;
public const int Join = 139;
public const int Key = 140;
public const int Let = 141;
public const int Lib = 142;
public const int Like = 143;
public const int Long = 144;
public const int Loop = 145;
public const int Me = 146;
public const int Mod = 147;
public const int Module = 148;
public const int MustInherit = 149;
public const int MustOverride = 150;
public const int MyBase = 151;
public const int MyClass = 152;
public const int Namespace = 153;
public const int Narrowing = 154;
public const int New = 155;
public const int Next = 156;
public const int Not = 157;
public const int Nothing = 158;
public const int NotInheritable = 159;
public const int NotOverridable = 160;
public const int Object = 161;
public const int Of = 162;
public const int Off = 163;
public const int On = 164;
public const int Operator = 165;
public const int Option = 166;
public const int Optional = 167;
public const int Or = 168;
public const int Order = 169;
public const int OrElse = 170;
public const int Overloads = 171;
public const int Overridable = 172;
public const int Overrides = 173;
public const int ParamArray = 174;
public const int Partial = 175;
public const int Preserve = 176;
public const int Private = 177;
public const int Property = 178;
public const int Protected = 179;
public const int Public = 180;
public const int RaiseEvent = 181;
public const int ReadOnly = 182;
public const int ReDim = 183;
public const int Rem = 184;
public const int RemoveHandler = 185;
public const int Resume = 186;
public const int Return = 187;
public const int SByte = 188;
public const int Select = 189;
public const int Set = 190;
public const int Shadows = 191;
public const int Shared = 192;
public const int Short = 193;
public const int Single = 194;
public const int Skip = 195;
public const int Static = 196;
public const int Step = 197;
public const int Stop = 198;
public const int Strict = 199;
public const int String = 200;
public const int Structure = 201;
public const int Sub = 202;
public const int SyncLock = 203;
public const int Take = 204;
public const int Text = 205;
public const int Then = 206;
public const int Throw = 207;
public const int To = 208;
public const int True = 209;
public const int Try = 210;
public const int TryCast = 211;
public const int TypeOf = 212;
public const int UInteger = 213;
public const int ULong = 214;
public const int Unicode = 215;
public const int Until = 216;
public const int UShort = 217;
public const int Using = 218;
public const int Variant = 219;
public const int Wend = 220;
public const int When = 221;
public const int Where = 222;
public const int While = 223;
public const int Widening = 224;
public const int With = 225;
public const int WithEvents = 226;
public const int WriteOnly = 227;
public const int Xor = 228;
public const int MaxToken = 222;
public const int MaxToken = 229;
static BitArray NewSet(params int[] values)
{
BitArray bitArray = new BitArray(MaxToken);
@ -261,6 +268,12 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -261,6 +268,12 @@ namespace ICSharpCode.NRefactory.Parser.VB
"<LiteralSingle>",
"<LiteralDecimal>",
"<LiteralDate>",
"<XmlOpenTag>",
"<XmlCloseTag>",
"<XmlStartInlineVB>",
"<XmlEndInlineVB>",
"<XmlCloseTagEmptyElement>",
"<XmlOpenEndTag>",
// ----- special character -----
"=",
":",
@ -387,6 +400,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -387,6 +400,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
"Is",
"IsNot",
"Join",
"Key",
"Let",
"Lib",
"Like",

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

File diff suppressed because it is too large Load Diff

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

@ -22,6 +22,12 @@ TOKENS @@ -22,6 +22,12 @@ TOKENS
LiteralSingle
LiteralDecimal
LiteralDate
XmlOpenTag
XmlCloseTag
XmlStartInlineVB
XmlEndInlineVB
XmlCloseTagEmptyElement
XmlOpenEndTag
/* ----- special character ----- */
"="
@ -150,6 +156,7 @@ TOKENS @@ -150,6 +156,7 @@ TOKENS
"Is"
"IsNot"
"Join"
"Key"
"Let"
"Lib"
"Like"
@ -326,23 +333,17 @@ Block = @@ -326,23 +333,17 @@ Block =
.
Expression =
(. isExpressionStart = true; .)
(. nextTokenIsPotentialStartOfXmlMode = true; .)
(
Literal (. isExpressionStart = false; .) |
( "(" (. isExpressionStart = false; .) Expression ")" ) |
( Identifier (. isExpressionStart = false; .) [ "(" "Of" TypeName { "," TypeName } ")" ] ) |
( "AddressOf" (. isExpressionStart = false; .) Expression) |
Literal |
( "(" Expression ")" ) |
( Identifier [ "(" "Of" TypeName { "," TypeName } ")" ] ) |
( "AddressOf" Expression) |
( "<" (. PushContext(Context.Xml); .) ANY ">" (. PopContext(); .) )
)
.
/*
XmlLiteralExpression =
"<"
( "!" | "?" )
.*/
PrimitiveTypeName =
"Byte" |
"SByte" |

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

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental
@ -15,7 +16,6 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental @@ -15,7 +16,6 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental
{
Stack<Context> stack = new Stack<Context>();
StringBuilder output = new StringBuilder();
bool isExpressionStart = false;
void PopContext()
{
@ -50,9 +50,18 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental @@ -50,9 +50,18 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental
public string Output {
get { return output.ToString(); }
}
public Context CurrentContext {
get { return stack.Any() ? stack.Peek() : Context.Global; }
}
public bool NextTokenIsPotentialStartOfXmlMode {
get { return nextTokenIsPotentialStartOfXmlMode; }
}
}
public enum Context {
public enum Context
{
Global,
Type,
Member,

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

File diff suppressed because it is too large Load Diff

37
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/VBNetParserTests.cs

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="siegfriedpammer@gmail.com" />
// <version>$Revision$</version>
// </file>
using System;
using NUnit.Framework;
namespace VBParserExperiment
{
[TestFixture]
public class VBNetParserTests
{
[Test]
[Ignore]
// TODO : check results
public void CommentAfterEnd()
{
RunTest(
@"Class Test
Sub A()
Dim a = <Test></Test><!-- a --> a
End Sub
End Class",
@""
);
}
void RunTest(string code, string result)
{
throw new NotImplementedException();
}
}
}

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

@ -51,6 +51,8 @@ @@ -51,6 +51,8 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TokenTests.cs" />
<Compile Include="VBNetParserTests.cs" />
<Compile Include="XmlModeLexerTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\NRefactory.csproj">

47
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/XmlModeLexerTests.cs

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="siegfriedpammer@gmail.com" />
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB;
using NUnit.Framework;
namespace VBParserExperiment
{
[TestFixture]
public class XmlModeLexerTests
{
ILexer GenerateLexer(StringReader sr)
{
return ParserFactory.CreateLexer(SupportedLanguage.VBNet, sr);
}
string TestStatement(string stmt)
{
return "Class Test\n" +
"Sub A()\n" +
stmt + "\n" +
"End Sub\n" +
"End Class";
}
[Test]
public void SimpleTag()
{
ILexer lexer = GenerateLexer(new StringReader(TestStatement("Dim x = <Test />")));
Assert.AreEqual(Tokens.Class, lexer.NextToken().Kind);
Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind);
Assert.AreEqual(Tokens.EOL, lexer.NextToken().Kind);
Assert.AreEqual(Tokens.Sub, lexer.NextToken().Kind);
Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind);
}
}
}

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

File diff suppressed because it is too large Load Diff

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

@ -8,8 +8,6 @@ using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute; @@ -8,8 +8,6 @@ using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute;
COMPILER VBNET
$frameDir=../Frames
/* START AUTOGENERATED TOKENS SECTION */
TOKENS
/* ----- terminal classes ----- */
@ -23,6 +21,12 @@ TOKENS @@ -23,6 +21,12 @@ TOKENS
LiteralSingle
LiteralDecimal
LiteralDate
XmlOpenTag
XmlCloseTag
XmlStartInlineVB
XmlEndInlineVB
XmlCloseTagEmptyElement
XmlOpenEndTag
/* ----- special character ----- */
"="
@ -151,6 +155,7 @@ TOKENS @@ -151,6 +155,7 @@ TOKENS
"Is"
"IsNot"
"Join"
"Key"
"Let"
"Lib"
"Like"
@ -337,7 +342,7 @@ ImportClause<out Using u> @@ -337,7 +342,7 @@ ImportClause<out Using u>
}
.)
) | ( (. string prefix = null; .)
"<" Identifier (. prefix = t.val; .) "=" LiteralString /* TODO support single-quote xml strings */ (. u = new Using(t.literalValue as string, prefix); .) ">"
"<" Identifier (. prefix = t.val; .) [ ":" Identifier (. prefix += ":" + t.val; .) ] "=" LiteralString /* TODO support single-quote xml strings */ (. u = new Using(t.literalValue as string, prefix); .) ">"
)
.
@ -372,7 +377,7 @@ NamespaceMemberDecl @@ -372,7 +377,7 @@ NamespaceMemberDecl
.
/* 4.9.1 */
TypeParameterList<. List<TemplateDefinition> templates .>
TypeParameterList<List<TemplateDefinition> templates>
(.
TemplateDefinition template;
.)
@ -428,7 +433,7 @@ TypeParameterConstraint<out TypeReference constraint> @@ -428,7 +433,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;
@ -765,7 +770,7 @@ EnumMemberDecl<out FieldDeclaration f> @@ -765,7 +770,7 @@ EnumMemberDecl<out FieldDeclaration f>
EndOfStmt
.
ClassMemberDecl<. ModifierList m, List<AttributeSection> attributes .> =
ClassMemberDecl<ModifierList m, List<AttributeSection> attributes> =
StructureMemberDecl<m, attributes>
.
@ -779,7 +784,7 @@ ClassBaseType<out TypeReference typeRef> @@ -779,7 +784,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>();
@ -1373,7 +1378,7 @@ AccessorDecls<out PropertyGetRegion getBlock, out PropertySetRegion setBlock> @@ -1373,7 +1378,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>
@ -1389,7 +1394,7 @@ GetAccessorDecl<. out PropertyGetRegion getBlock, List<AttributeSection> attribu @@ -1389,7 +1394,7 @@ GetAccessorDecl<. out PropertyGetRegion getBlock, List<AttributeSection> attribu
.
/* 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>();
@ -1413,7 +1418,7 @@ SetAccessorDecl<. out PropertySetRegion setBlock, List<AttributeSection> attribu @@ -1413,7 +1418,7 @@ SetAccessorDecl<. out PropertySetRegion setBlock, List<AttributeSection> attribu
.
/* 9.5 */
ConstantDeclarator<. List<VariableDeclaration> constantDeclaration .>
ConstantDeclarator<List<VariableDeclaration> constantDeclaration>
(.
Expression expr = null;
TypeReference type = null;
@ -1432,13 +1437,13 @@ ConstantDeclarator<. List<VariableDeclaration> constantDeclaration .> @@ -1432,13 +1437,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;
@ -1506,7 +1511,7 @@ VariableDeclaratorPartAfterIdentifier<. List<VariableDeclaration> fieldDeclarati @@ -1506,7 +1511,7 @@ VariableDeclaratorPartAfterIdentifier<. List<VariableDeclaration> fieldDeclarati
.
/* 6.8 */
ArrayInitializationModifier<. out List<Expression> arrayModifiers .>
ArrayInitializationModifier<out List<Expression> arrayModifiers>
(.
arrayModifiers = null;
.) =
@ -1514,7 +1519,7 @@ ArrayInitializationModifier<. out List<Expression> arrayModifiers .> @@ -1514,7 +1519,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;
@ -1561,7 +1566,7 @@ Charset<out CharsetModifier charsetModifier> @@ -1561,7 +1566,7 @@ Charset<out CharsetModifier charsetModifier>
.
/* 9.2.6 */
HandlesClause<. out List<string> handlesClause .>
HandlesClause<out List<string> handlesClause>
(.
handlesClause = new List<string>();
string name;
@ -1571,7 +1576,7 @@ HandlesClause<. out List<string> handlesClause .> @@ -1571,7 +1576,7 @@ HandlesClause<. out List<string> handlesClause .>
.
/* 7.8. */
InterfaceBase<. out List<TypeReference> bases .>
InterfaceBase<out List<TypeReference> bases>
(.
TypeReference type;
bases = new List<TypeReference>();
@ -1586,7 +1591,7 @@ InterfaceBase<. out List<TypeReference> bases .> @@ -1586,7 +1591,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;
@ -1603,7 +1608,7 @@ TypeImplementsClause<. out List<TypeReference> baseInterfaces .> @@ -1603,7 +1608,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;
@ -2062,7 +2067,7 @@ QueryExpr<out Expression expr> @@ -2062,7 +2067,7 @@ QueryExpr<out Expression expr>
.)
.
FromOrAggregateQueryOperator<. List<QueryExpressionClause> middleClauses .>
FromOrAggregateQueryOperator<List<QueryExpressionClause> middleClauses>
(.
QueryExpressionFromClause fromClause = null;
QueryExpressionAggregateClause aggregateClause = null;
@ -2073,7 +2078,7 @@ FromOrAggregateQueryOperator<. List<QueryExpressionClause> middleClauses .> @@ -2073,7 +2078,7 @@ FromOrAggregateQueryOperator<. List<QueryExpressionClause> middleClauses .>
(. middleClauses.Add(aggregateClause); .)
.
QueryOperator<. List<QueryExpressionClause> middleClauses .>
QueryOperator<List<QueryExpressionClause> middleClauses>
(.
QueryExpressionJoinVBClause joinClause = null;
QueryExpressionGroupVBClause groupByClause = null;
@ -2101,7 +2106,7 @@ QueryOperator<. List<QueryExpressionClause> middleClauses .> @@ -2101,7 +2106,7 @@ QueryOperator<. List<QueryExpressionClause> middleClauses .>
(. middleClauses.Add(groupByClause); .)
.
OrderByQueryOperator<. List<QueryExpressionClause> middleClauses .>
OrderByQueryOperator<List<QueryExpressionClause> middleClauses>
(.
QueryExpressionOrderClause orderClause = new QueryExpressionOrderClause();
orderClause.StartLocation = la.Location;
@ -2115,7 +2120,7 @@ OrderByQueryOperator<. List<QueryExpressionClause> middleClauses .> @@ -2115,7 +2120,7 @@ OrderByQueryOperator<. List<QueryExpressionClause> middleClauses .>
.)
.
OrderExpressionList<. out List<QueryExpressionOrdering> orderings .>
OrderExpressionList<out List<QueryExpressionOrdering> orderings>
(.
orderings = new List<QueryExpressionOrdering>();
QueryExpressionOrdering ordering = null;
@ -2184,7 +2189,7 @@ FromQueryOperator<out QueryExpressionFromClause fromClause> @@ -2184,7 +2189,7 @@ FromQueryOperator<out QueryExpressionFromClause fromClause>
.)
.
SelectQueryOperator<. List<QueryExpressionClause> middleClauses .>
SelectQueryOperator<List<QueryExpressionClause> middleClauses>
(.
QueryExpressionSelectVBClause selectClause = new QueryExpressionSelectVBClause();
selectClause.StartLocation = la.Location;
@ -2196,7 +2201,7 @@ SelectQueryOperator<. List<QueryExpressionClause> middleClauses .> @@ -2196,7 +2201,7 @@ SelectQueryOperator<. List<QueryExpressionClause> middleClauses .>
.)
.
DistinctQueryOperator<. List<QueryExpressionClause> middleClauses .>
DistinctQueryOperator<List<QueryExpressionClause> middleClauses>
(.
QueryExpressionDistinctClause distinctClause = new QueryExpressionDistinctClause();
distinctClause.StartLocation = la.Location;
@ -2208,7 +2213,7 @@ DistinctQueryOperator<. List<QueryExpressionClause> middleClauses .> @@ -2208,7 +2213,7 @@ DistinctQueryOperator<. List<QueryExpressionClause> middleClauses .>
.)
.
WhereQueryOperator<. List<QueryExpressionClause> middleClauses .>
WhereQueryOperator<List<QueryExpressionClause> middleClauses>
(.
QueryExpressionWhereClause whereClause = new QueryExpressionWhereClause();
whereClause.StartLocation = la.Location;
@ -2262,7 +2267,7 @@ AggregateQueryOperator<out QueryExpressionAggregateClause aggregateClause> @@ -2262,7 +2267,7 @@ AggregateQueryOperator<out QueryExpressionAggregateClause aggregateClause>
.)
.
LetQueryOperator<. List<QueryExpressionClause> middleClauses .>
LetQueryOperator<List<QueryExpressionClause> middleClauses>
(.
QueryExpressionLetVBClause letClause = new QueryExpressionLetVBClause();
letClause.StartLocation = la.Location;
@ -2274,7 +2279,7 @@ LetQueryOperator<. List<QueryExpressionClause> middleClauses .> @@ -2274,7 +2279,7 @@ LetQueryOperator<. List<QueryExpressionClause> middleClauses .>
.)
.
ExpressionRangeVariableDeclarationList<. List<ExpressionRangeVariable> variables .>
ExpressionRangeVariableDeclarationList<List<ExpressionRangeVariable> variables>
(.
ExpressionRangeVariable variable = null;
.) =
@ -2333,7 +2338,7 @@ JoinQueryOperator<out QueryExpressionJoinVBClause joinClause> @@ -2333,7 +2338,7 @@ JoinQueryOperator<out QueryExpressionJoinVBClause joinClause>
.)
.
CollectionRangeVariableDeclarationList<. List<CollectionRangeVariable> rangeVariables .>
CollectionRangeVariableDeclarationList<List<CollectionRangeVariable> rangeVariables>
(. CollectionRangeVariable variableDeclaration; .)
=
CollectionRangeVariableDeclaration<out variableDeclaration>
@ -2392,7 +2397,7 @@ MemberInitializer<out MemberInitializerExpression memberInitializer> @@ -2392,7 +2397,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;
@ -2406,7 +2411,7 @@ ArgumentList<. out List<Expression> arguments .> @@ -2406,7 +2411,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();
@ -2561,7 +2566,7 @@ RankList<out int i> @@ -2561,7 +2566,7 @@ RankList<out int i>
.
/* 7.12 */
TypeArgumentList<. List<TypeReference> typeArguments .>
TypeArgumentList<List<TypeReference> typeArguments>
(.
TypeReference typeref;
.) =
@ -2610,7 +2615,7 @@ Attribute<out ASTAttribute attribute> @@ -2610,7 +2615,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 = "";
@ -2685,7 +2690,7 @@ AttributeSection<out AttributeSection section> @@ -2685,7 +2690,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); .)
@ -3099,7 +3104,7 @@ EmbeddedStatement<out Statement statement> @@ -3099,7 +3104,7 @@ EmbeddedStatement<out Statement statement>
| LocalDeclarationStatement<out statement>
.
SingleLineStatementList<. List<Statement> list .>
SingleLineStatementList<List<Statement> list>
(. Statement embeddedStatement = null; .)
=
( "End" (. embeddedStatement = new EndStatement(); .)
@ -3230,7 +3235,7 @@ ResumeStatement<out ResumeStatement resumeStatement> @@ -3230,7 +3235,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;
@ -3312,7 +3317,7 @@ TryStatement<out Statement tryStatement> @@ -3312,7 +3317,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;

6
src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

@ -2704,7 +2704,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2704,7 +2704,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitMemberInitializerExpression(MemberInitializerExpression memberInitializerExpression, object data)
{
if (memberInitializerExpression.IsKey) {
outputFormatter.PrintIdentifier("Key"); // TODO : replace by token
outputFormatter.PrintToken(Tokens.Key);
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.Dot);
@ -2823,6 +2823,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2823,6 +2823,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.MustOverride);
outputFormatter.Space();
}
if ((modifier & Modifiers.Dim) == Modifiers.Dim) {
outputFormatter.PrintToken(Tokens.Dim);
outputFormatter.Space();
}
if ((modifier & Modifiers.Overloads) == Modifiers.Overloads) {
outputFormatter.PrintToken(Tokens.Overloads);
outputFormatter.Space();

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

@ -884,6 +884,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -884,6 +884,13 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Assert.AreEqual(Tokens.Join, lexer.NextToken().Kind);
}
[Test]
public void TestKey()
{
ILexer lexer = GenerateLexer(new StringReader("Key"));
Assert.AreEqual(Tokens.Key, lexer.NextToken().Kind);
}
[Test]
public void TestLet()
{

4
src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs

@ -176,7 +176,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -176,7 +176,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsFalse(ud.Usings[0].IsAlias);
Assert.IsTrue(ud.Usings[0].IsXml);
Assert.AreEqual("", ud.Usings[0].XmlPrefix);
Assert.AreEqual("xmlns", ud.Usings[0].XmlPrefix);
Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.Usings[0].Name);
}
@ -197,7 +197,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -197,7 +197,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsFalse(ud.Usings[0].IsAlias);
Assert.IsTrue(ud.Usings[0].IsXml);
Assert.AreEqual("avalonedit", ud.Usings[0].XmlPrefix);
Assert.AreEqual("xmlns:avalonedit", ud.Usings[0].XmlPrefix);
Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.Usings[0].Name);
}
#endregion

Loading…
Cancel
Save