[Mono-list] Patch for mcs

Gaurav Vaish Gaurav Vaish <gaurav.vaish@gmail.com>
Fri, 29 Oct 2004 20:34:24 +0530


------=_Part_1786_29286204.1099062264202
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi Lupus/Miguel,

  I am working (better: resumed work) on mcsdoc (Master C# Document
Generator) - an extension of the "/doc" flag.

  The problem is that everytime there's a change in mcs, I need to
update my private copy manually since I have made some changes in core
mcs as well.

   I am attaching a patch to the latest mcs (mcs/mcs module) source.

   I would great if you can include this patch. This patch in no way
hampers the working of mcs. I've cross checked by running tests on the
old and new mcs.



Cheers,
Gaurav Vaish
http://csdoc.sf.net
http://gallery.mastergaurav.org
--------------------------------

------=_Part_1786_29286204.1099062264202
Content-Type: text/plain; name="DIFF_MCS"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="DIFF_MCS"

diff -u ./cs-parser.jay /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsd=
oc/mcs/cs-parser.jay
--- ./cs-parser.jay=092004-10-29 16:01:28.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/cs-parser.jay=
=092004-10-29 20:20:48.000000000 +0530
@@ -733,6 +733,8 @@
=20
 =09=09=09current_container =3D current_class;
 =09=09=09RootContext.Tree.RecordDecl (name.GetName (true), current_class);
+=09=09=09current_class.Documentation =3D lexer.GetDocs();
+=09=09=09//lexer.SaveDocument();
 =09=09}
 =09  }
 =09  opt_class_base
@@ -809,6 +811,8 @@
 =09=09=09=09(Attributes) $1, l);
=20
 =09=09=09current_container.AddConstant (c);
+=09=09=09c.Documentation =3D lexer.GetDocs();
+=09=09=09//lexer.SaveDocument();
 =09=09}
 =09  }
 =09;
@@ -861,6 +865,8 @@
 =09=09=09=09=09=09 (Attributes) $1, l);
=20
 =09=09=09current_container.AddField (field);
+=09=09=09field.Documentation =3D lexer.GetDocs();
+=09=09=09//lexer.SaveDocument();
 =09=09}
 =09  }
 =09| opt_attributes
@@ -939,6 +945,8 @@
=20
 =09=09method.Block =3D (ToplevelBlock) $3;
 =09=09current_container.AddMethod (method);
+=09=09method.Documentation =3D lexer.GetDocs();
+=09=09//lexer.SaveDocument();
=20
 =09=09current_local_parameters =3D null;
 =09=09iterator_container =3D null;
@@ -991,6 +999,9 @@
 =09=09=09=09=09    (int) $2, false, name, (Parameters) $6,
 =09=09=09=09=09    (Attributes) $1, lexer.Location);
=20
+=09=09method.Documentation =3D lexer.GetDocs();
+=09=09//lexer.SaveDocument();
+
 =09=09current_local_parameters =3D (Parameters) $6;
 =09=09$$ =3D method;
 =09  }
@@ -1171,6 +1182,8 @@
 =09=09=09prop.SetYields ();
 =09=09
 =09=09current_container.AddProperty (prop);
+=09=09prop.Documentation =3D lexer.GetDocs();
+=09=09//lexer.SaveDocument();
 =09=09implicit_value_parameter_type =3D null;
 =09=09iterator_container =3D null;
 =09  }
@@ -1281,6 +1294,8 @@
=20
 =09=09=09current_container =3D current_class;
 =09=09=09RootContext.Tree.RecordDecl (name.GetName (true), current_class);
+=09=09=09current_class.Documentation =3D lexer.GetDocs();
+=09=09=09//lexer.SaveDocument();
 =09=09}
 =09  }
 =09  opt_class_base
@@ -1362,8 +1377,11 @@
 =09  {
 =09=09MemberName name =3D (MemberName) $4;
=20
-=09=09$$ =3D new Method (current_class, (Expression) $3, (int) $2, true,
+=09=09Method im =3D new Method (current_class, (Expression) $3, (int) $2, =
true,
 =09=09=09=09 name, (Parameters) $6, (Attributes) $1, lexer.Location);
+=09=09im.Documentation =3D lexer.GetDocs();
+=09=09$$ =3D im;
+=09=09//lexer.SaveDocument();
 =09  }
 =09| opt_attributes opt_new VOID namespace_or_type_name
 =09  OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
@@ -1371,8 +1389,11 @@
 =09  {
 =09=09MemberName name =3D (MemberName) $4;
=20
-=09=09$$ =3D new Method (current_class, TypeManager.system_void_expr, (int=
) $2,
+=09=09Method im =3D new Method (current_class, TypeManager.system_void_exp=
r, (int) $2,
 =09=09=09=09 true, name, (Parameters) $6,  (Attributes) $1, lexer.Location=
);
+=09=09im.Documentation =3D lexer.GetDocs();
+=09=09$$ =3D im;
+=09=09//lexer.SaveDocument();
 =09  }
 =09;
=20
@@ -1388,9 +1409,12 @@
 =09  {
                 InterfaceAccessorInfo pinfo =3D (InterfaceAccessorInfo) $7=
;
=20
-=09=09$$ =3D new Property (current_class, (Expression) $3, (int) $2, true,
+=09=09Property ip =3D new Property (current_class, (Expression) $3, (int) =
$2, true,
 =09=09=09=09   new MemberName ((string) $4), (Attributes) $1,
 =09=09=09=09   pinfo.Get, pinfo.Set, lexer.Location);
+=09=09ip.Documentation =3D lexer.GetDocs();
+=09=09$$ =3D ip;
+=09=09//lexer.SaveDocument();
 =09  }
 =09| opt_attributes
 =09  opt_new
@@ -1412,9 +1436,12 @@
 interface_event_declaration
 =09: opt_attributes opt_new EVENT type IDENTIFIER SEMICOLON
 =09  {
-=09=09$$ =3D new EventField (current_class, (Expression) $4, (int) $2, tru=
e,
+=09=09EventField ie =3D new EventField (current_class, (Expression) $4, (i=
nt) $2, true,
 =09=09=09=09     new MemberName ((string) $5), null,
 =09=09=09=09     (Attributes) $1, lexer.Location);
+=09=09ie.Documentation =3D lexer.GetDocs();
+=09=09$$ =3D ie;
+=09=09//lexer.SaveDocument();
 =09  }
 =09| opt_attributes opt_new EVENT type error {
 =09=09CheckIdentifierToken (yyToken);
@@ -1441,10 +1468,13 @@
 =09  {
 =09=09InterfaceAccessorInfo info =3D (InterfaceAccessorInfo) $10;
=20
-=09=09$$ =3D new Indexer (current_class, (Expression) $3,
+=09=09Indexer ii =3D new Indexer (current_class, (Expression) $3,
 =09=09=09=09  new MemberName (TypeContainer.DefaultIndexerName),
 =09=09=09=09  (int) $2, true, (Parameters) $6, (Attributes) $1,
 =09=09=09=09  info.Get, info.Set, lexer.Location);
+=09=09ii.Documentation =3D lexer.GetDocs();
+=09=09$$ =3D ii;
+=09=09//lexer.SaveDocument();
 =09  }
 =09;
=20
@@ -1474,6 +1504,9 @@
 =09=09// Note again, checking is done in semantic analysis
 =09=09current_container.AddOperator (op);
=20
+=09=09op.Documentation =3D lexer.GetDocs();
+=09=09//lexer.SaveDocument();
+
 =09=09current_local_parameters =3D null;
 =09=09iterator_container =3D null;
 =09  }
@@ -1646,8 +1679,11 @@
 =09  opt_constructor_initializer
 =09  {
 =09=09Location l =3D (Location) oob_stack.Pop ();
-=09=09$$ =3D new Constructor (current_class, (string) $1, 0, (Parameters) =
$3,
+=09=09Constructor ctor =3D new Constructor (current_class, (string) $1, 0,=
 (Parameters) $3,
 =09=09=09=09      (ConstructorInitializer) $6, l);
+=09=09ctor.Documentation =3D lexer.GetDocs();
+=09=09$$ =3D ctor;
+=09=09//lexer.SaveDocument();
 =09  }
 =09;
=20
@@ -1712,6 +1748,8 @@
 =09=09 =20
 =09=09=09d.Block =3D (ToplevelBlock) $7;
 =09=09=09current_container.AddMethod (d);
+=09=09=09d.Documentation =3D lexer.GetDocs();
+=09=09=09//lexer.SaveDocument();
 =09=09}
 =09  }
 =09;
@@ -1731,7 +1769,8 @@
 =09=09=09=09lexer.Location);
=20
 =09=09=09current_container.AddEvent (e);
-=09=09=09=09      =20
+=09=09=09e.Documentation =3D lexer.GetDocs();
+=09=09=09//lexer.SaveDocument();
 =09=09}
 =09  }
 =09| opt_attributes
@@ -1765,6 +1804,8 @@
 =09=09=09=09loc);
 =09=09=09
 =09=09=09current_container.AddEvent (e);
+=09=09=09e.Documentation =3D lexer.GetDocs();
+=09=09=09//lexer.SaveDocument();
 =09=09=09implicit_value_parameter_type =3D null;
 =09=09}
 =09  }
@@ -1881,6 +1922,8 @@
 =09=09=09=09       get_block, set_block, loc);
=20
 =09=09current_container.AddIndexer (indexer);
+=09=09indexer.Documentation =3D lexer.GetDocs();
+=09=09//lexer.SaveDocument();
 =09=09
 =09=09current_local_parameters =3D null;
 =09=09implicit_value_parameter_type =3D null;
@@ -1939,6 +1982,8 @@
 =09=09string name =3D full_name.GetName ();
 =09=09current_container.AddEnum (e);
 =09=09RootContext.Tree.RecordDecl (name, e);
+=09=09e.Documentation =3D lexer.GetDocs();
+=09=09//lexer.SaveDocument();
=20
 =09  }
 =09;
@@ -1981,7 +2026,10 @@
 enum_member_declaration
 =09: opt_attributes IDENTIFIER=20
 =09  {
-=09=09$$ =3D new VariableDeclaration ((string) $2, null, lexer.Location, (=
Attributes) $1);
+=09=09VariableDeclaration vd =3D new VariableDeclaration ((string) $2, nul=
l, lexer.Location, (Attributes) $1);
+=09=09vd.Documentation =3D lexer.GetDocs();
+=09=09$$ =3D vd;
+=09=09//lexer.SaveDocument();
 =09  }
 =09| opt_attributes IDENTIFIER
 =09  {
@@ -1989,7 +2037,10 @@
 =09  }
           ASSIGN expression
 =09  {=20
-=09=09$$ =3D new VariableDeclaration ((string) $2, $5, lexer.Location, (At=
tributes) $1);
+=09=09VariableDeclaration vd =3D new VariableDeclaration ((string) $2, $5,=
 lexer.Location, (Attributes) $1);
+=09=09vd.Documentation =3D lexer.GetDocs();
+=09=09$$ =3D vd;
+=09=09//lexer.SaveDocument();
 =09  }
 =09;
=20
@@ -2007,7 +2058,9 @@
=20
 =09=09current_container.AddDelegate (del);
 =09=09RootContext.Tree.RecordDecl (name.GetName (true), del);
-=09  }=09
+=09=09del.Documentation =3D lexer.GetDocs();
+=09=09//lexer.SaveDocument();
+=09  }
 =09| opt_attributes
 =09  opt_modifiers
 =09  DELEGATE VOID member_name
@@ -2023,6 +2076,8 @@
=20
 =09=09current_container.AddDelegate (del);
 =09=09RootContext.Tree.RecordDecl (name.GetName (true), del);
+=09=09del.Documentation =3D lexer.GetDocs();
+=09=09//lexer.SaveDocument();
 =09  }
 =09;
=20
@@ -3006,6 +3061,8 @@
=20
 =09=09=09current_container =3D current_class;
 =09=09=09RootContext.Tree.RecordDecl (name.GetName (true), current_class);
+=09=09=09current_class.Documentation =3D lexer.GetDocs();
+=09=09=09//lexer.SaveDocument();
 =09=09}
 =09  }
 =09  opt_class_base
@@ -4103,6 +4160,12 @@
 =09public Location Location;
 =09public Attributes OptAttributes;
=20
+=09/// <summary>
+=09/// Holds the doc-comments.
+=09/// </summary>
+=09/// <remarks>master's hack</remarks>
+=09public string Documentation;
+
 =09public VariableDeclaration (string id, object eoai, Location l, Attribu=
tes opt_attrs)
 =09{
 =09=09this.identifier =3D id;
diff -u ./cs-tokenizer.cs /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mc=
sdoc/mcs/cs-tokenizer.cs
--- ./cs-tokenizer.cs=092004-10-04 15:05:32.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/cs-tokenizer.=
cs=092004-10-29 20:01:08.000000000 +0530
@@ -54,6 +54,37 @@
 =09=09bool any_token_seen =3D false;
 =09=09static Hashtable tokenValues;
=20
+=09=09//----------------------------------------------
+=09=09// Adding support for documentation.
+=09=09// Modified by Gaurav Vaish
+=09=09// master's hack
+=09=09//----------------------------------------------
+
+=09=09#region Modification1=09=09
+
+=09=09private string    commentString =3D "";
+=09=09private bool      isCollectingDocs =3D true;
+
+=09=09public void SaveDocument()
+=09=09{
+=09=09=09commentString =3D "";
+=09=09=09isCollectingDocs =3D true;
+=09=09}
+
+=09=09public void StopCollectingDocs()
+=09=09{
+=09=09=09isCollectingDocs =3D false;
+=09=09}
+
+=09=09public string GetDocs()
+=09=09{
+=09=09=09string retVal =3D commentString.Trim();
+=09=09=09SaveDocument();
+=09=09=09return retVal;
+=09=09}
+
+=09=09#endregion
+
 =09=09private static Hashtable TokenValueName
 =09=09{
 =09=09=09get {
@@ -1857,26 +1888,63 @@
 =09=09=09=09}
=20
 =09=09=09=09// Handle double-slash comments.
+=09=09=09=09#region Modification2
 =09=09=09=09if (c =3D=3D '/'){
 =09=09=09=09=09int d =3D peekChar ();
-=09=09=09=09
+=09=09=09=09=09// master's hack
+=09=09=09=09=09int afterComment =3D 0;
+
 =09=09=09=09=09if (d =3D=3D '/'){
 =09=09=09=09=09=09getChar ();
+=09=09=09=09=09=09// master's hack
+=09=09=09=09=09=09if(isCollectingDocs)
+=09=09=09=09=09=09{
+=09=09=09=09=09=09=09commentString +=3D "//";
+=09=09=09=09=09=09}
 =09=09=09=09=09=09while ((d =3D getChar ()) !=3D -1 && (d !=3D '\n') && d =
!=3D '\r')
+=09=09=09=09=09=09{
+=09=09=09=09=09=09=09// master's hack
+=09=09=09=09=09=09=09if(isCollectingDocs)
+=09=09=09=09=09=09=09{
+=09=09=09=09=09=09=09=09commentString +=3D (char)d;
+=09=09=09=09=09=09=09}
 =09=09=09=09=09=09=09col++;
+=09=09=09=09=09=09}
 =09=09=09=09=09=09if (d =3D=3D '\n'){
+=09=09=09=09=09=09=09//master's hack
+=09=09=09=09=09=09=09if(isCollectingDocs)
+=09=09=09=09=09=09=09{
+=09=09=09=09=09=09=09=09commentString +=3D '\n';
+=09=09=09=09=09=09=09}
 =09=09=09=09=09=09=09line++;
 =09=09=09=09=09=09=09ref_line++;
 =09=09=09=09=09=09=09col =3D 0;
 =09=09=09=09=09=09}
+=09=09=09=09=09=09// master's hack
+=09=09=09=09=09=09afterComment =3D peekChar();
+=09=09=09=09=09=09if(afterComment =3D=3D '\r' || afterComment=3D=3D'\n')
+=09=09=09=09=09=09{
+=09=09=09=09=09=09=09//Console.WriteLine("Delimiting // comment. \n\"" + c=
ommentString + "\"");
+=09=09=09=09=09=09=09commentString =3D "";
+=09=09=09=09=09=09}
 =09=09=09=09=09=09any_token_seen |=3D tokens_seen;
 =09=09=09=09=09=09tokens_seen =3D false;
 =09=09=09=09=09=09continue;
 =09=09=09=09=09} else if (d =3D=3D '*'){
 =09=09=09=09=09=09getChar ();
=20
+=09=09=09=09=09=09// master's hack
+=09=09=09=09=09=09if(isCollectingDocs)
+=09=09=09=09=09=09=09commentString +=3D "/*";
+
 =09=09=09=09=09=09while ((d =3D getChar ()) !=3D -1){
 =09=09=09=09=09=09=09if (d =3D=3D '*' && peekChar () =3D=3D '/'){
+=09=09=09=09=09=09=09=09// master's hack
+=09=09=09=09=09=09=09=09if(isCollectingDocs)
+=09=09=09=09=09=09=09=09{
+=09=09=09=09=09=09=09=09=09//Console.WriteLine("Stop of /**/ comment. \n\"=
" + commentString + "\"");
+=09=09=09=09=09=09=09=09=09commentString +=3D "*/";
+=09=09=09=09=09=09=09=09}
 =09=09=09=09=09=09=09=09getChar ();
 =09=09=09=09=09=09=09=09col++;
 =09=09=09=09=09=09=09=09break;
@@ -1888,11 +1956,21 @@
 =09=09=09=09=09=09=09=09any_token_seen |=3D tokens_seen;
 =09=09=09=09=09=09=09=09tokens_seen =3D false;
 =09=09=09=09=09=09=09}
+=09=09=09=09=09=09=09// master's hack
+=09=09=09=09=09=09=09///*
+=09=09=09=09=09=09=09afterComment =3D peekChar();
+=09=09=09=09=09=09=09if(afterComment =3D=3D '\r' || afterComment=3D=3D'\n'=
)
+=09=09=09=09=09=09=09{
+=09=09=09=09=09=09=09=09Console.WriteLine("Delimiting /* comment. \n\"" + =
commentString + "\"");
+=09=09=09=09=09=09=09=09commentString =3D "";
+=09=09=09=09=09=09=09}
+=09=09=09=09=09=09=09//*/
 =09=09=09=09=09=09}
 =09=09=09=09=09=09continue;
 =09=09=09=09=09}
 =09=09=09=09=09goto is_punct_label;
 =09=09=09=09}
+=09=09=09=09#endregion
=20
 =09=09=09=09
 =09=09=09=09if (is_identifier_start_character ((char)c)){
diff -u ./decl.cs /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs=
/decl.cs
--- ./decl.cs=092004-10-29 16:01:28.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/decl.cs=09200=
4-10-29 20:18:12.000000000 +0530
@@ -151,6 +151,12 @@
 =09=09/// </summary>
 =09=09internal Flags caching_flags;
=20
+=09=09/// <summary>
+=09=09/// Holds the doc-comments.
+=09=09/// </summary>
+=09=09/// <remarks>master's hack</remarks>
+=09=09public string Documentation;
+
 =09=09public MemberCore (TypeContainer parent, MemberName name, Attributes=
 attrs,
 =09=09=09=09   Location loc)
 =09=09=09: base (attrs)
diff -u ./ecore.cs /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mc=
s/ecore.cs
--- ./ecore.cs=092004-10-29 16:01:30.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/ecore.cs=0920=
04-10-29 20:16:26.000000000 +0530
@@ -157,6 +157,12 @@
 =09=09protected Type type;
 =09=09protected Location loc;
 =09=09
+=09=09/// <summary>
+=09=09/// Holds the doc-comments.
+=09=09/// </summary>
+=09=09/// <remarks>master's hack</remarks>
+=09=09public string Documentation;
+
 =09=09public Type Type {
 =09=09=09get {
 =09=09=09=09return type;
Only in /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs: genericp=
arser.cs
Only in /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs: interfac=
e.cs
Only in /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs: makefile
Only in /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs: makefile=
.gnu
Only in /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs: makefile=
.old

------=_Part_1786_29286204.1099062264202--