Browse Source

extended ExpressionFinder: now works with local variables and member variables

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/vbnet@5868 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Siegfried Pammer 16 years ago
parent
commit
f5211322eb
  1. 1
      src/Libraries/NRefactory/Project/NRefactory.csproj
  2. 20
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.atg
  3. 1
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/ExpressionFinder.cs
  4. 1661
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Parser.cs
  5. 3
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/PushParser.frame
  6. 125
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Experimental/Test/ParserTests.cs

1
src/Libraries/NRefactory/Project/NRefactory.csproj

@ -140,6 +140,7 @@ @@ -140,6 +140,7 @@
<None Include="Src\Parser\Frames\Parser.frame" />
<None Include="Src\Parser\VBNet\Experimental\ExpressionFinder.atg">
<Generator>CocoParserGenerator</Generator>
<CustomToolNamespace>ICSharpCode.NRefactory.Parser.VBNet.Experimental</CustomToolNamespace>
</None>
<None Include="Src\Parser\VBNet\Experimental\Parser.frame">
<DependentUpon>ExpressionFinder.atg</DependentUpon>

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

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
@ -261,11 +262,12 @@ ImportsStatement = @@ -261,11 +262,12 @@ ImportsStatement =
.
AttributeBlock =
"<" { ANY } ">" [ EOL ]
"<" (. PushContext(Context.Attribute); .) { ANY } ">" (. PopContext(); .) [ EOL ]
.
NamespaceMemberDeclaration =
NamespaceDeclaration | TypeDeclaration
NamespaceDeclaration |
TypeDeclaration
.
NamespaceDeclaration =
@ -286,20 +288,26 @@ TypeDeclaration = @@ -286,20 +288,26 @@ TypeDeclaration =
MemberDeclaration =
(. PushContext(Context.Member); .)
{ AttributeBlock } { MemberModifier }
(
MemberVariableOrConstantDeclaration |
SubOrFunctionDeclaration
)
(. PopContext(); .)
.
SubOrFunctionDeclaration =
{ AttributeBlock } { MemberModifier } ("Sub" | "Function")
("Sub" | "Function")
(. PushContext(Context.IdentifierExpected); .) ANY (. PopContext(); .)
[ "(" [ ParameterList ] ")" ] [ "As" TypeName ]
Block
"End" ("Sub" | "Function") StatementTerminator
.
MemberVariableOrConstantDeclaration =
[ "Const" ] Identifier [ "As" TypeName ] [ "=" Expression ] StatementTerminator
.
ParameterList =
Parameter { "," Parameter }
.
@ -443,7 +451,9 @@ MemberModifier = @@ -443,7 +451,9 @@ MemberModifier =
"NotOverridable" |
"Overrides" |
"Overloads" |
"Partial"
"Partial" |
"WithEvents" |
"Dim"
.
ParameterModifier =

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

@ -59,6 +59,7 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental @@ -59,6 +59,7 @@ namespace ICSharpCode.NRefactory.Parser.VBNet.Experimental
IdentifierExpected,
Body,
Xml,
Attribute,
Debug
}
}

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

File diff suppressed because it is too large Load Diff

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

@ -25,9 +25,6 @@ If not otherwise stated, any source code generated by Coco/R (other than @@ -25,9 +25,6 @@ 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.Collections.Generic;
-->namespace
partial class ExpressionFinder {

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

@ -58,6 +58,131 @@ exit Global @@ -58,6 +58,131 @@ exit Global
);
}
[Test]
public void MemberWithXmlLiteral()
{
RunTest(
@"Class Test
Private xml As XElement = <b>
Public Sub New()
Dim x = <a>
End Sub
End Class
",
@"enter Global
enter Type
enter Member
enter IdentifierExpected
exit IdentifierExpected
enter IdentifierExpected
exit IdentifierExpected
enter Xml
exit Xml
exit Member
enter Member
enter IdentifierExpected
exit IdentifierExpected
enter Body
enter IdentifierExpected
exit IdentifierExpected
enter Xml
exit Xml
exit Body
exit Member
exit Type
exit Global
"
);
}
[Test]
public void GlobalAttributeTest()
{
RunTest(
@"<assembly: CLSCompliant(True)>
Class Test
Public Sub New()
Dim x = 5
End Sub
End Class
",
@"enter Global
enter Attribute
exit Attribute
enter Type
enter Member
enter IdentifierExpected
exit IdentifierExpected
enter Body
enter IdentifierExpected
exit IdentifierExpected
exit Body
exit Member
exit Type
exit Global
"
);
}
[Test]
public void ClassAttributeTest()
{
RunTest(
@"<Serializable>
Class Test
Public Sub New()
Dim x = 5
End Sub
End Class
",
@"enter Global
enter Attribute
exit Attribute
enter Type
enter Member
enter IdentifierExpected
exit IdentifierExpected
enter Body
enter IdentifierExpected
exit IdentifierExpected
exit Body
exit Member
exit Type
exit Global
"
);
}
[Test]
public void MethodAttributeTest()
{
RunTest(
@"Class Test
<Test>
Public Sub New()
Dim x = 5
End Sub
End Class
",
@"enter Global
enter Type
enter Member
enter Attribute
exit Attribute
enter IdentifierExpected
exit IdentifierExpected
enter Body
enter IdentifierExpected
exit IdentifierExpected
exit Body
exit Member
exit Type
exit Global
"
);
}
void RunTest(string code, string expectedOutput)
{
ExpressionFinder p = new ExpressionFinder();

Loading…
Cancel
Save