[Monodevelop-patches-list] r2184 - in trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory: . src src/CodeDOM src/Lexer src/Parser/AST src/Parser/AST/TypeLevel src/Parser/generated
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Fri Jan 28 02:20:57 EST 2005
Author: jluke
Date: 2005-01-28 02:20:57 -0500 (Fri, 28 Jan 2005)
New Revision: 2184
Modified:
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/AssemblyInfo.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/CodeDOM/CodeDOMVisitor.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Lexer/Lexer.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Main.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/AbstractASTVisitor.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/IASTVisitor.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/LookupTableVisitor.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/TypeLevel/TypeReference.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/Parser.cs
trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/cs.ATG
Log:
update from SD, fixes a couple things
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog 2005-01-28 07:20:57 UTC (rev 2184)
@@ -1,3 +1,9 @@
+2005-01-28 John Luke <john.luke at gmail.com>
+
+ * src/*: Merged in sync with #D parser.
+ makes catch (Exception e) { e. } work and a few
+ other small fixes
+
2004-05-24 Lluis Sanchez Gual <lluis at ximian.com>
* src/Parser/AST/AbstractNode.cs: Lazily create children arraylist.
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am 2005-01-28 07:20:57 UTC (rev 2184)
@@ -1,3 +1,8 @@
+DLL = ICSharpCode.SharpRefactory.dll
+TEST = test-parser.exe
+
+REFS = -r:System.Drawing.dll
+
FILES = \
src/Lexer/Reader/IReader.cs \
src/Lexer/Reader/FileReader.cs \
@@ -109,26 +114,21 @@
build_sources = $(addprefix $(srcdir)/, $(FILES))
-DLL = ICSharpCode.SharpRefactory.dll
-
-REFS = /r:System.Drawing.dll
-
all: $(DLL)
$(DLL): $(FILES)
- @ $(CSC) /out:$(DLL) /target:library $(REFS) $(build_sources) \
+ $(CSC) /out:$(DLL) /target:library $(REFS) $(build_sources) \
&& cp $(DLL) $(top_builddir)/build/bin/.
-test-parser.exe : $(DLL) src/Main.cs
- @ $(CSC) /out:$@ /r:$(DLL) src/Main.cs
+test: $(TEST)
-run : test-parser.exe
- @ MONO_PATH=`dirname $(DLL)` $(RUNTIME) test-parser.exe $(TEST_SOURCE)
+$(TEST): $(DLL) src/Main.cs
+ $(CSC) -out:$@ -r:$(DLL) src/Main.cs
assemblydir = $(libdir)/monodevelop/bin
assembly_DATA = $(DLL)
-CLEANFILES = $(DLL) $(DLL).mdb
+CLEANFILES = $(DLL) $(DLL).mdb $(TEST)
EXTRA_DIST = $(FILES)
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/AssemblyInfo.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/AssemblyInfo.cs 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/AssemblyInfo.cs 2005-01-28 07:20:57 UTC (rev 2184)
@@ -23,7 +23,7 @@
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
-[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.3.1768")]
// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/CodeDOM/CodeDOMVisitor.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/CodeDOM/CodeDOMVisitor.cs 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/CodeDOM/CodeDOMVisitor.cs 2005-01-28 07:20:57 UTC (rev 2184)
@@ -100,15 +100,15 @@
attr |= MemberAttributes.Abstract;
// if ((modifier & Modifier.None) != 0)
// attr |= MemberAttributes.AccessMask;
-// if ((modifier & Modifier.None) != 0)
-// attr |= MemberAttributes.Assembly;
+ if ((modifier & Modifier.Internal) != 0)
+ attr |= MemberAttributes.Assembly;
if ((modifier & Modifier.Const) != 0)
attr |= MemberAttributes.Const;
+ if ((modifier & Modifier.Protected) != 0)
+ attr |= MemberAttributes.Family;
+ if ((modifier & Modifier.Protected) != 0 && (modifier & Modifier.Internal) != 0)
+ attr |= MemberAttributes.FamilyAndAssembly;
// if ((modifier & Modifier.None) != 0)
-// attr |= MemberAttributes.Family;
-// if ((modifier & Modifier.None) != 0)
-// attr |= MemberAttributes.FamilyAndAssembly;
-// if ((modifier & Modifier.None) != 0)
// attr |= MemberAttributes.FamilyOrAssembly;
if ((modifier & Modifier.Sealed) != 0)
attr |= MemberAttributes.Final;
@@ -792,6 +792,10 @@
case UnaryOperatorType.Minus:
if (unaryOperatorExpression.Expression is PrimitiveExpression) {
PrimitiveExpression expression = (PrimitiveExpression)unaryOperatorExpression.Expression;
+ if (expression.Value is System.UInt32 || expression.Value is System.UInt16) {
+ return new CodePrimitiveExpression(Int32.Parse("-" + expression.StringValue));
+ }
+
if (expression.Value is int) {
return new CodePrimitiveExpression(- (int)expression.Value);
}
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Lexer/Lexer.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Lexer/Lexer.cs 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Lexer/Lexer.cs 2005-01-28 07:20:57 UTC (rev 2184)
@@ -308,12 +308,12 @@
reader.GetNext();
++col;
isfloat = true;
- } else if (Char.ToUpper(reader.Peek()) == 'M') { // double type suffix (obsolete, double is default)
+ } else if (Char.ToUpper(reader.Peek()) == 'D') { // double type suffix (obsolete, double is default)
suffix.Append(reader.Peek());
reader.GetNext();
++col;
isdouble = true;
- } else if (Char.ToUpper(reader.Peek()) == 'D') { // decimal value
+ } else if (Char.ToUpper(reader.Peek()) == 'M') { // decimal value
suffix.Append(reader.Peek());
reader.GetNext();
++col;
@@ -372,6 +372,22 @@
return new Token(Tokens.Literal, x, y, stringValue, 0d);
}
}
+
+ double d = 0;
+ if (!Double.TryParse(digit, ishex ? NumberStyles.HexNumber : NumberStyles.Integer, null, out d)) {
+ errors.Error(y, x, String.Format("Can't parse integral constant {0}", digit));
+ return new Token(Tokens.Literal, x, y, stringValue.ToString(), 0);
+ }
+ if (d < long.MinValue || d > long.MaxValue) {
+ islong = true;
+ isunsigned = true;
+ }
+ else if (d < uint.MinValue || d > uint.MaxValue) {
+ islong = true;
+ }
+ else if (d < int.MinValue || d > int.MaxValue) {
+ isunsigned = true;
+ }
if (islong) {
if (isunsigned) {
try {
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Main.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Main.cs 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Main.cs 2005-01-28 07:20:57 UTC (rev 2184)
@@ -12,6 +12,7 @@
class MainClass
{
+/*
public static StringCollection SearchDirectory(string directory, string filemask)
{
return SearchDirectory(directory, filemask, true);
@@ -74,12 +75,12 @@
}
Console.ReadLine();
}
-
+*/
public static void Main (string[] args)
{
// PrettyPrintDirectories();
Parser p = new Parser();
- string fileName = "C:\\a.cs";
+ string fileName = args[0];
Console.Write("Converting : " + fileName);
p.Parse(new Lexer(new FileReader(fileName)));
if (p.Errors.count == 0) {
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/AbstractASTVisitor.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/AbstractASTVisitor.cs 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/AbstractASTVisitor.cs 2005-01-28 07:20:57 UTC (rev 2184)
@@ -20,9 +20,9 @@
#region ICSharpCode.SharpRefactory.Parser.IASTVisitor interface implementation
public virtual object Visit(INode node, object data)
{
- Console.WriteLine("Warning: INode visited");
- Console.WriteLine("Visitor was: " + this.GetType());
- Console.WriteLine("Node was : " + node.GetType());
+ //Console.WriteLine("Warning: INode visited");
+ //Console.WriteLine("Visitor was: " + this.GetType());
+ //Console.WriteLine("Node was : " + node.GetType());
return node.AcceptChildren(this, data);
}
@@ -312,7 +312,7 @@
ret = ifElseStatement.EmbeddedStatement.AcceptVisitor(this, data);
}
if (ifElseStatement.EmbeddedElseStatement != null) {
- ret = ifElseStatement.EmbeddedStatement.AcceptVisitor(this, data);
+ ret = ifElseStatement.EmbeddedElseStatement.AcceptVisitor(this, data);
}
return ret;
}
@@ -499,6 +499,14 @@
}
return statementExpression.Expression.AcceptVisitor(this, data);
}
+
+ public virtual object Visit(UnsafeStatement unsafeStatement, object data)
+ {
+ if (unsafeStatement.Block == null) {
+ return null;
+ }
+ return unsafeStatement.Block.AcceptVisitor(this, data);
+ }
#endregion
#region Expressions
@@ -524,10 +532,16 @@
}
public virtual object Visit(InvocationExpression invocationExpression, object data)
{
+ object result = data;
if (invocationExpression.TargetObject != null) {
- return invocationExpression.TargetObject.AcceptVisitor(this, data);
+ result = invocationExpression.TargetObject.AcceptVisitor(this, data);
}
- return data;
+ if (invocationExpression.Parameters != null) {
+ foreach (INode n in invocationExpression.Parameters) {
+ n.AcceptVisitor(this, data);
+ }
+ }
+ return result;
}
public virtual object Visit(IdentifierExpression identifierExpression, object data)
{
@@ -577,7 +591,11 @@
}
public virtual object Visit(IndexerExpression indexerExpression, object data)
{
- return indexerExpression.TargetObject.AcceptVisitor(this, data);
+ object res = indexerExpression.TargetObject.AcceptVisitor(this, data);
+ foreach (INode n in indexerExpression.Indices) {
+ n.AcceptVisitor(this, data);
+ }
+ return res;
}
public virtual object Visit(ThisReferenceExpression thisReferenceExpression, object data)
{
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/IASTVisitor.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/IASTVisitor.cs 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/IASTVisitor.cs 2005-01-28 07:20:57 UTC (rev 2184)
@@ -59,6 +59,7 @@
object Visit(FixedStatement fixedStatement, object data);
object Visit(CheckedStatement checkedStatement, object data);
object Visit(UncheckedStatement uncheckedStatement, object data);
+ object Visit(UnsafeStatement unsafeStatement, object data);
// Expressions
object Visit(PrimitiveExpression primitiveExpression, object data);
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/LookupTableVisitor.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/LookupTableVisitor.cs 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/LookupTableVisitor.cs 2005-01-28 07:20:57 UTC (rev 2184)
@@ -42,6 +42,9 @@
public void AddVariable(TypeReference typeRef, string name, Point startPos, Point endPos)
{
+ if (name == null || name.Length == 0) {
+ return;
+ }
ArrayList list;
if (variables[name] == null) {
variables[name] = list = new ArrayList();
@@ -79,5 +82,32 @@
}
return foreachStatement.EmbeddedStatement.AcceptVisitor(this, data);
}
+
+ public override object Visit(TryCatchStatement tryCatchStatement, object data)
+ {
+ if (tryCatchStatement == null) {
+ return data;
+ }
+ if (tryCatchStatement.StatementBlock != null) {
+ tryCatchStatement.StatementBlock.AcceptVisitor(this, data);
+ }
+ if (tryCatchStatement.CatchClauses != null) {
+ foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) {
+ if (catchClause != null) {
+ if (catchClause.Type != null && catchClause.VariableName != null) {
+ AddVariable(new TypeReference (catchClause.Type),
+ catchClause.VariableName,
+ catchClause.StatementBlock.StartLocation,
+ catchClause.StatementBlock.EndLocation);
+ }
+ catchClause.StatementBlock.AcceptVisitor(this, data);
+ }
+ }
+ }
+ if (tryCatchStatement.FinallyBlock != null) {
+ return tryCatchStatement.FinallyBlock.AcceptVisitor(this, data);
+ }
+ return data;
+ }
}
}
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/TypeLevel/TypeReference.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/TypeLevel/TypeReference.cs 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/AST/TypeLevel/TypeReference.cs 2005-01-28 07:20:57 UTC (rev 2184)
@@ -48,6 +48,12 @@
types.Add("ushort", "System.UInt16");
types.Add("void", "System.Void");
}
+
+ public static ICollection PrimitiveTypes {
+ get {
+ return types.Keys;
+ }
+ }
public string Type {
get {
@@ -87,7 +93,7 @@
string GetSystemType(string type)
{
- if (types[type] != null) {
+ if (types.ContainsKey(type)) {
return (string)types[type];
}
return type;
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/Parser.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/Parser.cs 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/Parser.cs 2005-01-28 07:20:57 UTC (rev 2184)
@@ -4115,7 +4115,7 @@
}
#line 1793 "cs.ATG"
- string val = t.val;
+ string val = t.val; t.val = "";
Expect(13);
Expect(1);
@@ -4976,4 +4976,4 @@
};
} // end Parser
-}
\ No newline at end of file
+}
Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/cs.ATG
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/cs.ATG 2005-01-28 02:10:38 UTC (rev 2183)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Parser/generated/cs.ATG 2005-01-28 07:20:57 UTC (rev 2184)
@@ -1790,7 +1790,7 @@
"bool" | "byte" | "char" | "decimal" | "double"
| "float" | "int" | "long" | "object" | "sbyte"
| "short" | "string" | "uint" | "ulong" | "ushort"
- ) (. string val = t.val; .) "." ident (. pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); .)
+ ) (. string val = t.val; t.val = "" .) "." ident (. pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); .)
/*--- this access: */
| "this" (. pexpr = new ThisReferenceExpression(); .)
/*--- base access: */
More information about the Monodevelop-patches-list
mailing list