[Monodevelop-patches-list] r2392 - trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding
John Luke <jluke@cfl.rr.com>
jluke at mono-cvs.ximian.com
Sat Mar 26 00:50:18 EST 2005
Author: jluke
Date: 2005-03-26 00:50:18 -0500 (Sat, 26 Mar 2005)
New Revision: 2392
Modified:
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/
trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/parse.cs
Log:
improve my little test program
Property changes on: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding
___________________________________________________________________
Name: svn:ignore
- Makefile
Makefile.in
CSharpBinding.dll
CSharpBinding.dll.mdb
CSharpBinding.pidb
CSharpBindingExecutionManager.cs
+ Makefile
Makefile.in
CSharpBinding.dll
CSharpBinding.dll.mdb
CSharpBinding.pidb
CSharpBindingExecutionManager.cs
parse.exe
parse.mdb
Modified: trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/parse.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/parse.cs 2005-03-26 03:12:10 UTC (rev 2391)
+++ trunk/MonoDevelop/Core/src/AddIns/BackendBindings/CSharpBinding/parse.cs 2005-03-26 05:50:18 UTC (rev 2392)
@@ -4,43 +4,63 @@
using ICSharpCode.SharpRefactory.Parser;
using CSharpBinding.Parser;
-// recurse a dir for .cs files
-// and print out parsing errors
-class parse
+// print out parsing errors
+// from a dir recursively
+// or a single file
+class ParserTest
{
- static void Main (string[] args)
+ static Parser p = new Parser ();
+ static Lexer lexer;
+ static int counter = 0;
+ static int errors = 0;
+
+ static int Main (string[] args)
{
if (args.Length == 1 && Directory.Exists (args[0]))
- new parse (args[0]);
+ Parse (new DirectoryInfo (args[0]));
+ else if (args.Length == 1 && File.Exists (args[0]))
+ Parse (new FileInfo (args[0]));
else
- PrintUsage ();
+ return PrintUsage ();
+
+ Console.WriteLine ("{0} out of {1} failed to parse correctly", errors, counter);
+ return 0;
}
- static void PrintUsage ()
+ static int PrintUsage ()
{
Console.WriteLine ("usage: parse.exe <dir>");
+ return 0;
}
- parse (string dir)
+ static void Parse (FileInfo file)
{
- string[] files = Directory.GetFiles (dir, "*.cs");
- if (files.Length < 1)
- return;
-
- Parser p = new Parser ();
- Lexer lexer;
-
- foreach (string f in files) {
- lexer = new Lexer (new FileReader (f));
+ if (file.Exists) {
+ lexer = new Lexer (new FileReader (file.FullName));
p.Parse (lexer);
CSharpVisitor v = new CSharpVisitor ();
v.Visit (p.compilationUnit, null);
v.Cu.ErrorsDuringCompile = p.Errors.count > 0;
- if (v.Cu.ErrorsDuringCompile)
- Console.WriteLine ("errors in parsing " + f);
+ if (v.Cu.ErrorsDuringCompile) {
+ Console.WriteLine ("errors in parsing " + file.FullName);
+ errors ++;
+ }
+ else {
+ counter ++;
+ }
+
foreach (ErrorInfo error in p.Errors.ErrorInformation)
Console.WriteLine (error.ToString ());
}
}
+
+ static void Parse (DirectoryInfo dir)
+ {
+ foreach (FileInfo f in dir.GetFiles ("*.cs"))
+ Parse (f);
+
+ foreach (DirectoryInfo di in dir.GetDirectories ())
+ Parse (di);
+ }
}
More information about the Monodevelop-patches-list
mailing list