Browse Source

NRefactory Unit Tests working again

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5901 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 15 years ago
parent
commit
4e76347386
  1. 35
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  2. 34
      src/Libraries/NRefactory/Project/Src/Parser/Frames/Parser.frame
  3. 4675
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  4. 2
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  5. 42
      src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs

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

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

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

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

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

File diff suppressed because it is too large Load Diff

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

@ -342,7 +342,7 @@ ImportClause<out Using u>
} }
.) .)
) | ( (. string prefix = null; .) ) | ( (. string prefix = null; .)
"<" Identifier (. prefix = t.val; .) [ ":" Identifier (. prefix += ":" + t.val; .) ] "=" LiteralString /* TODO support single-quote xml strings */ (. u = new Using(t.literalValue as string, prefix); .) ">" XmlOpenTag Identifier (. prefix = t.val; .) "=" LiteralString (. u = new Using(t.literalValue as string, prefix); .) XmlCloseTag
) )
. .

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

@ -200,6 +200,48 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual("xmlns:avalonedit", ud.Usings[0].XmlPrefix); Assert.AreEqual("xmlns:avalonedit", ud.Usings[0].XmlPrefix);
Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.Usings[0].Name); Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.Usings[0].Name);
} }
[Test]
public void VBNetXmlNamespaceSingleQuotedUsingTest()
{
string program = "Imports <xmlns='http://icsharpcode.net/sharpdevelop/avalonedit'>";
IParser parser = ParserFactory.CreateParser(SupportedLanguage.VBNet, new StringReader(program));
parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput);
CompilationUnit unit = parser.CompilationUnit;
Assert.AreEqual(1, unit.Children.Count);
Assert.IsTrue(unit.Children[0] is UsingDeclaration);
UsingDeclaration ud = (UsingDeclaration)unit.Children[0];
Assert.AreEqual(1, ud.Usings.Count);
Assert.IsFalse(ud.Usings[0].IsAlias);
Assert.IsTrue(ud.Usings[0].IsXml);
Assert.AreEqual("xmlns", ud.Usings[0].XmlPrefix);
Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.Usings[0].Name);
}
[Test]
public void VBNetXmlNamespaceSingleQuotedWithPrefixUsingTest()
{
string program = "Imports <xmlns:avalonedit='http://icsharpcode.net/sharpdevelop/avalonedit'>";
IParser parser = ParserFactory.CreateParser(SupportedLanguage.VBNet, new StringReader(program));
parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput);
CompilationUnit unit = parser.CompilationUnit;
Assert.AreEqual(1, unit.Children.Count);
Assert.IsTrue(unit.Children[0] is UsingDeclaration);
UsingDeclaration ud = (UsingDeclaration)unit.Children[0];
Assert.AreEqual(1, ud.Usings.Count);
Assert.IsFalse(ud.Usings[0].IsAlias);
Assert.IsTrue(ud.Usings[0].IsXml);
Assert.AreEqual("xmlns:avalonedit", ud.Usings[0].XmlPrefix);
Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.Usings[0].Name);
}
#endregion #endregion
} }
} }

Loading…
Cancel
Save