Hmm...
Here's the latest diff.
Rest is same as in previous patch. However, in this I have a change
in the definition of "enum_declaration" in cs-parser.jay:
New definition looks like:
---------------------------------------------------
enum_declaration
: opt_attributes
opt_modifiers
ENUM IDENTIFIER
opt_enum_base
{
mcsdoc_docs = lexer.GetDocs();
//lexer.SaveDocument();
}
enum_body
opt_semicolon
{
---------------------------------------------------
I have appropriately updated the code after "opt_semicolon {" to
take care of the enum_body.
The reason is that I cannot collect the document after the
declaration has started. I need to collect the document immediately
after the enum bases are defined.
Although, it is based on the assumption that there will be no code like:
enum name /* comment can fool me */ : char
{
...
}
But, it's ok. It's consistent with other types. It will be fooled
everywhere, unless I moved the collection of the docs immediately
after "ENUM" or "CLASS" etc.
Please include this as the final patch.
Cheers,
Gaurav Vaish
http://csdoc.sf.net
http://gallery.mastergaurav.org
-----------------------------------
diff -u ./class.cs /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/class.cs
--- ./class.cs 2004-10-29 16:01:28.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/class.cs 2004-10-30
16:52:08.000000000 +0530
@@ -829,6 +829,20 @@
}
}
+ private TypeExpr baseClassType = null;
+
+ /// <summary>
+ /// Returns the type of the base class
+ /// </summary>
+ /// <remarks>master's hack</remarks>
+ public Type BaseType
+ {
+ get
+ {
+ return baseClassType.Type;
+ }
+ }
+
//
// Emits the instance field initializers
//
@@ -897,10 +911,10 @@
}
- /// <remarks>
+ /// <summary>
/// The pending methods that need to be implemented
- // (interfaces or abstract methods)
- /// </remarks>
+ /// (interfaces or abstract methods)
+ /// </summary>
public PendingImplementation Pending;
public abstract void Register ();
@@ -1147,6 +1161,12 @@
if (error)
return null;
+ //master's hack
+ if(baseClassType == null)
+ {
+ baseClassType = parent;
+ }
+
if (parent == null) {
if (Kind == Kind.Class){
if (RootContext.StdLib)
@@ -1555,20 +1575,20 @@
/// Only, we need to use this for types which are _being_ defined
because MS'
/// implementation can't take care of that.
/// </summary>
- //
- // FIXME: return an empty static array instead of null, that cleans up
- // some code and is consistent with some coding conventions I just
found
- // out existed ;-)
- //
- //
- // Notice that in various cases we check if our field is non-null,
- // something that would normally mean that there was a bug elsewhere.
- //
- // The problem happens while we are defining p-invoke methods, as those
- // will trigger a FindMembers, but this happens before things are
defined
- //
- // Since the whole process is a no-op, it is fine to check for null
here.
- //
+ /// <remarks>
+ /// FIXME: return an empty static array instead of null, that cleans up
+ /// some code and is consistent with some coding conventions I just
found
+ /// out existed ;-)
+ ///
+ ///
+ /// Notice that in various cases we check if our field is non-null,
+ /// something that would normally mean that there was a bug elsewhere.
+ ///
+ /// The problem happens while we are defining p-invoke methods, as
those
+ /// will trigger a FindMembers, but this happens before things are
defined
+ ///
+ /// Since the whole process is a no-op, it is fine to check for null
here.
+ /// </remarks>
public override MemberList FindMembers (MemberTypes mt, BindingFlags
bf,
MemberFilter filter, object
criteria)
{
@@ -5991,7 +6011,7 @@
}
}
- /// </summary>
+ /// <summary>
/// Gigantic workaround for lameness in SRE follows :
/// This class derives from EventInfo and attempts to basically
/// wrap around the EventBuilder so that FindMembers can quickly
diff -u ./cs-parser.jay
/cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/cs-parser.jay
--- ./cs-parser.jay 2004-10-29 16:01:28.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/cs-parser.jay
2004-10-30 17:32:30.000000000 +0530
@@ -59,7 +59,7 @@
/// <summary>
/// Used to determine if we are parsing the get/set pair
/// of an indexer or a property
- /// </summmary>
+ /// </summary>
bool parsing_indexer;
///
@@ -81,7 +81,8 @@
/// The current file.
///
SourceFile file;
-
+
+ string mcsdoc_docs;
/// Current attribute target
string current_attr_target;
@@ -733,6 +734,8 @@
current_container = current_class;
RootContext.Tree.RecordDecl (name.GetName (true),
current_class);
+ current_class.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
}
}
opt_class_base
@@ -809,6 +812,8 @@
(Attributes) $1, l);
current_container.AddConstant (c);
+ c.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
}
}
;
@@ -861,6 +866,8 @@
(Attributes) $1, l);
current_container.AddField (field);
+ field.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
}
}
| opt_attributes
@@ -939,6 +946,8 @@
method.Block = (ToplevelBlock) $3;
current_container.AddMethod (method);
+ method.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
current_local_parameters = null;
iterator_container = null;
@@ -991,6 +1000,9 @@
(int) $2, false, name, (Parameters) $6,
(Attributes) $1, lexer.Location);
+ method.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
+
current_local_parameters = (Parameters) $6;
$$ = method;
}
@@ -1171,6 +1183,8 @@
prop.SetYields ();
current_container.AddProperty (prop);
+ prop.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
implicit_value_parameter_type = null;
iterator_container = null;
}
@@ -1281,6 +1295,8 @@
current_container = current_class;
RootContext.Tree.RecordDecl (name.GetName (true),
current_class);
+ current_class.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
}
}
opt_class_base
@@ -1362,8 +1378,11 @@
{
MemberName name = (MemberName) $4;
- $$ = new Method (current_class, (Expression) $3, (int) $2, true,
+ Method im = new Method (current_class, (Expression) $3, (int) $2, true,
name, (Parameters) $6, (Attributes) $1,
lexer.Location);
+ im.Documentation = lexer.GetDocs();
+ $$ = im;
+ //lexer.SaveDocument();
}
| opt_attributes opt_new VOID namespace_or_type_name
OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
@@ -1371,8 +1390,11 @@
{
MemberName name = (MemberName) $4;
- $$ = new Method (current_class, TypeManager.system_void_expr, (int) $2,
+ Method im = new Method (current_class, TypeManager.system_void_expr,
(int) $2,
true, name, (Parameters) $6, (Attributes) $1,
lexer.Location);
+ im.Documentation = lexer.GetDocs();
+ $$ = im;
+ //lexer.SaveDocument();
}
;
@@ -1388,9 +1410,12 @@
{
InterfaceAccessorInfo pinfo = (InterfaceAccessorInfo) $7;
- $$ = new Property (current_class, (Expression) $3, (int) $2, true,
+ Property ip = new Property (current_class, (Expression) $3, (int) $2,
true,
new MemberName ((string) $4), (Attributes) $1,
pinfo.Get, pinfo.Set, lexer.Location);
+ ip.Documentation = lexer.GetDocs();
+ $$ = ip;
+ //lexer.SaveDocument();
}
| opt_attributes
opt_new
@@ -1412,9 +1437,12 @@
interface_event_declaration
: opt_attributes opt_new EVENT type IDENTIFIER SEMICOLON
{
- $$ = new EventField (current_class, (Expression) $4, (int) $2, true,
+ EventField ie = new EventField (current_class, (Expression) $4, (int)
$2, true,
new MemberName ((string) $5), null,
(Attributes) $1, lexer.Location);
+ ie.Documentation = lexer.GetDocs();
+ $$ = ie;
+ //lexer.SaveDocument();
}
| opt_attributes opt_new EVENT type error {
CheckIdentifierToken (yyToken);
@@ -1441,10 +1469,13 @@
{
InterfaceAccessorInfo info = (InterfaceAccessorInfo) $10;
- $$ = new Indexer (current_class, (Expression) $3,
+ Indexer ii = new Indexer (current_class, (Expression) $3,
new MemberName (TypeContainer.DefaultIndexerName),
(int) $2, true, (Parameters) $6, (Attributes) $1,
info.Get, info.Set, lexer.Location);
+ ii.Documentation = lexer.GetDocs();
+ $$ = ii;
+ //lexer.SaveDocument();
}
;
@@ -1474,6 +1505,9 @@
// Note again, checking is done in semantic analysis
current_container.AddOperator (op);
+ op.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
+
current_local_parameters = null;
iterator_container = null;
}
@@ -1646,8 +1680,11 @@
opt_constructor_initializer
{
Location l = (Location) oob_stack.Pop ();
- $$ = new Constructor (current_class, (string) $1, 0, (Parameters) $3,
+ Constructor ctor = new Constructor (current_class, (string) $1, 0,
(Parameters) $3,
(ConstructorInitializer) $6, l);
+ ctor.Documentation = lexer.GetDocs();
+ $$ = ctor;
+ //lexer.SaveDocument();
}
;
@@ -1712,6 +1749,8 @@
d.Block = (ToplevelBlock) $7;
current_container.AddMethod (d);
+ d.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
}
}
;
@@ -1731,7 +1770,8 @@
lexer.Location);
current_container.AddEvent (e);
-
+ e.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
}
}
| opt_attributes
@@ -1765,6 +1805,8 @@
loc);
current_container.AddEvent (e);
+ e.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
implicit_value_parameter_type = null;
}
}
@@ -1881,6 +1923,8 @@
get_block, set_block, loc);
current_container.AddIndexer (indexer);
+ indexer.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
current_local_parameters = null;
implicit_value_parameter_type = null;
@@ -1921,6 +1965,10 @@
opt_modifiers
ENUM IDENTIFIER
opt_enum_base
+ {
+ mcsdoc_docs = lexer.GetDocs();
+ //lexer.SaveDocument();
+ }
enum_body
opt_semicolon
{
@@ -1930,7 +1978,7 @@
Enum e = new Enum (current_namespace, current_container, (Expression)
$5, (int) $2,
full_name, (Attributes) $1, enum_location);
- foreach (VariableDeclaration ev in (ArrayList) $6) {
+ foreach (VariableDeclaration ev in (ArrayList) $7) {
e.AddEnumMember (ev.identifier,
(Expression)
ev.expression_or_array_initializer,
ev.Location, ev.OptAttributes);
@@ -1939,7 +1987,7 @@
string name = full_name.GetName ();
current_container.AddEnum (e);
RootContext.Tree.RecordDecl (name, e);
-
+ e.Documentation = mcsdoc_docs;
}
;
@@ -1981,7 +2029,10 @@
enum_member_declaration
: opt_attributes IDENTIFIER
{
- $$ = new VariableDeclaration ((string) $2, null, lexer.Location,
(Attributes) $1);
+ VariableDeclaration vd = new VariableDeclaration ((string) $2, null,
lexer.Location, (Attributes) $1);
+ vd.Documentation = lexer.GetDocs();
+ $$ = vd;
+ //lexer.SaveDocument();
}
| opt_attributes IDENTIFIER
{
@@ -1989,7 +2040,10 @@
}
ASSIGN expression
{
- $$ = new VariableDeclaration ((string) $2, $5, lexer.Location,
(Attributes) $1);
+ VariableDeclaration vd = new VariableDeclaration ((string) $2, $5,
lexer.Location, (Attributes) $1);
+ vd.Documentation = lexer.GetDocs();
+ $$ = vd;
+ //lexer.SaveDocument();
}
;
@@ -2007,7 +2061,9 @@
current_container.AddDelegate (del);
RootContext.Tree.RecordDecl (name.GetName (true), del);
- }
+ del.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
+ }
| opt_attributes
opt_modifiers
DELEGATE VOID member_name
@@ -2023,6 +2079,8 @@
current_container.AddDelegate (del);
RootContext.Tree.RecordDecl (name.GetName (true), del);
+ del.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
}
;
@@ -3006,6 +3064,8 @@
current_container = current_class;
RootContext.Tree.RecordDecl (name.GetName (true),
current_class);
+ current_class.Documentation = lexer.GetDocs();
+ //lexer.SaveDocument();
}
}
opt_class_base
@@ -4103,6 +4163,12 @@
public Location Location;
public Attributes OptAttributes;
+ /// <summary>
+ /// Holds the doc-comments.
+ /// </summary>
+ /// <remarks>master's hack</remarks>
+ public string Documentation;
+
public VariableDeclaration (string id, object eoai, Location l, Attributes
opt_attrs)
{
this.identifier = id;
diff -u ./cs-tokenizer.cs
/cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/cs-tokenizer.cs
--- ./cs-tokenizer.cs 2004-10-04 15:05:32.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/cs-tokenizer.cs
2004-10-30 17:27:12.000000000 +0530
@@ -54,6 +54,37 @@
bool any_token_seen = false;
static Hashtable tokenValues;
+ //----------------------------------------------
+ // Adding support for documentation.
+ // Modified by Gaurav Vaish
+ // master's hack
+ //----------------------------------------------
+
+ #region Modification1
+
+ private string commentString = "";
+ private bool isCollectingDocs = true;
+
+ public void SaveDocument()
+ {
+ commentString = "";
+ isCollectingDocs = true;
+ }
+
+ public void StopCollectingDocs()
+ {
+ isCollectingDocs = false;
+ }
+
+ public string GetDocs()
+ {
+ string retVal = commentString.Trim();
+ SaveDocument();
+ return retVal;
+ }
+
+ #endregion
+
private static Hashtable TokenValueName
{
get {
@@ -1857,14 +1888,43 @@
}
// Handle double-slash comments.
+ #region Modification2
if (c == '/'){
int d = peekChar ();
-
+ // master's hack
+ int afterComment = 0;
+
if (d == '/'){
getChar ();
+ // master's hack
+ if(isCollectingDocs)
+ {
+ commentString += "//";
+ }
while ((d = getChar ()) != -1 && (d !=
'\n') && d != '\r')
+ {
+ // master's hack
+ if(isCollectingDocs)
+ {
+ commentString +=
(char)d;
+ }
col++;
+ }
if (d == '\n'){
+ //master's hack
+ if(isCollectingDocs)
+ {
+ commentString += '\n';
+ }
+ // master's hack
+ ///*
+ afterComment = peekChar();
+ if(afterComment == '\r' ||
afterComment=='\n')
+ {
+
//Console.WriteLine("Delimiting // comment. \n\"" + commentString + "\"");
+ commentString = "";
+ }
+ //*/
line++;
ref_line++;
col = 0;
@@ -1875,8 +1935,24 @@
} else if (d == '*'){
getChar ();
+ // master's hack
+ if(isCollectingDocs)
+ commentString += "/*";
+
while ((d = getChar ()) != -1){
+ // master's hack
+ if(isCollectingDocs)
+ {
+ commentString +=
(char)d;
+ }
if (d == '*' && peekChar () ==
'/'){
+ // master's hack
+ if(isCollectingDocs)
+ {
+ commentString
+= "/";
+
//Console.WriteLine("Stop of /**/ comment. \n\"" + commentString + "\"");
+ }
+ StopCollectingDocs();
getChar ();
col++;
break;
@@ -1888,11 +1964,21 @@
any_token_seen |=
tokens_seen;
tokens_seen = false;
}
+ // master's hack
+ /*
+ afterComment = peekChar();
+ if(afterComment == '\r' ||
afterComment=='\n')
+ {
+
Console.WriteLine("Delimiting /* comment. \n\"" + commentString + "\"");
+ commentString = "";
+ }
+ //*/
}
continue;
}
goto is_punct_label;
}
+ #endregion
if (is_identifier_start_character ((char)c)){
diff -u ./decl.cs /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/decl.cs
--- ./decl.cs 2004-10-29 16:01:28.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/decl.cs 2004-10-30
17:26:32.000000000 +0530
@@ -151,6 +151,12 @@
/// </summary>
internal Flags caching_flags;
+ /// <summary>
+ /// Holds the doc-comments.
+ /// </summary>
+ /// <remarks>master's hack</remarks>
+ public string Documentation;
+
public MemberCore (TypeContainer parent, MemberName name, Attributes
attrs,
Location loc)
: base (attrs)
diff -u ./driver.cs /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/driver.cs
--- ./driver.cs 2004-09-23 16:08:04.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/driver.cs 2004-10-30
17:33:32.000000000 +0530
@@ -8,6 +8,8 @@
// (C) 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com)
//
+using MCSDoc;
+
namespace Mono.CSharp
{
using System;
diff -u ./ecore.cs /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/ecore.cs
--- ./ecore.cs 2004-10-29 16:01:30.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/ecore.cs 2004-10-29
20:16:26.000000000 +0530
@@ -157,6 +157,12 @@
protected Type type;
protected Location loc;
+ /// <summary>
+ /// Holds the doc-comments.
+ /// </summary>
+ /// <remarks>master's hack</remarks>
+ public string Documentation;
+
public Type Type {
get {
return type;
diff -u ./mcs.exe.sources
/cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/mcs.exe.sources
--- ./mcs.exe.sources 2004-09-14 19:41:52.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/mcs.exe.sources
2004-10-30 16:22:06.000000000 +0530
@@ -34,3 +34,4 @@
../class/Mono.CSharp.Debugger/MonoSymbolTable.cs
../class/Mono.CSharp.Debugger/MonoSymbolWriter.cs
../class/corlib/Mono.Security.Cryptography/CryptoConvert.cs
+MCSDocUtils.cs
diff -u ./parameter.cs
/cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/parameter.cs
--- ./parameter.cs 2004-10-29 16:01:30.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/parameter.cs
2004-10-30 15:51:34.000000000 +0530
@@ -526,7 +526,7 @@
/// boolean whether this is an out or ref parameter.
///
/// Note that the returned type will not contain any dereference in
this
- /// case (ie, you get "int" for a ref int instead of "int&"
+ /// case (ie, you get "int" for a ref int instead of "int&")
/// </summary>
public Type GetParameterInfo (EmitContext ec, int idx, out
Parameter.Modifier mod)
{
diff -u ./statement.cs
/cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/statement.cs
--- ./statement.cs 2004-10-29 16:01:30.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/statement.cs
2004-10-30 15:50:46.000000000 +0530
@@ -25,7 +25,7 @@
/// <summary>
/// Resolves the statement, true means that all sub-statements
/// did resolve ok.
- // </summary>
+ /// </summary>
public virtual bool Resolve (EmitContext ec)
{
return true;
diff -u ./support.cs
/cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/support.cs
--- ./support.cs 2004-10-17 11:59:28.000000000 +0530
+++ /cygdrive/d/gvaish/Projects/SF/csdoc/csdoc/src/mcsdoc/mcs/support.cs
2004-10-30 15:49:22.000000000 +0530
@@ -367,10 +367,10 @@
int pos; // index into buffer[]
int preamble_size;
- /// <remarks>
+ /// <summary>
/// The difference to the StreamReader's BaseStream.Position is that
this one is reliable; ie. it
- // always reports the correct position and if it's modified, it
also takes care of the buffered data.
- /// </remarks>
+ /// always reports the correct position and if it's modified, it
also takes care of the buffered data.
+ /// </summary>
public int Position {
get {
return buffer_start +
reader.CurrentEncoding.GetByteCount (buffer, 0, pos);