logo back up home forward   further reading more topics »

XES - Programmers Guide - nodeComment

for information about XES schema see these pages.

Comment

Allows comments to be inserted anywhere in program

<xs:complexType name="commentType" mixed="true">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:any processContents="lax"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>

These are possible changes as described here.

How do you think comments should be handled in XES? I think it is very important that the original source code can be reconstructed fully without altering comments. The coding and decoding process will alter whitespace and a possible small change to the position of the comment, but there should be no more.
To do this any node type can have a comment under it, I guess this makes the DTD or schema more complicated, would it be better to move comments out from some node types?

The issues are explained here in terms of encoding Java but there are similar constructs in other languages and as far as possible the encoding should be language independent.

Current Method
--------------
Currently I use the method from the java parser at the sun site:

<"/**" ~["/"]> { input_stream.backup(1); } :
IN_FORMAL_COMMENT

<IN_FORMAL_COMMENT>
SPECIAL_TOKEN :
{
<FORMAL_COMMENT: "*/" > : DEFAULT

Then everywhere a token is read in the file a checkForComment method is called as follows:

t = "package" {checkForComment(t);}

This checkForComment method extracts the special token, puts the text in a nodeComment and then pushes the nodeComment so it will appear in the right place in the tree.

Required Method
---------------
What I thought is that, if the formal comment occurs just before a method, class or parameter definition, then the javaDoc information is parsed to extract metadata to be stored under the method, class or parameter definition nodes. For example given the following comment before a comment definition:
/**
* Returns an Image object that can then be painted on the screen.
* @param url an absolute URL giving the base location of the image
* name the location of the image, relative to the url argument
* @return the image at the specified URL
* @see Image
*/

I suggest we create nodeReturn and nodeSee nodes and put them under the method definition node (along with a nodeComment to hold the residual unstructured string).
Then nodeParam nodes need to be created for url and name and put under the appropriate parameter nodes which is itself under the method definition node.

I think it would also be good to consider how this can be combined with metadata from the new Java 5 Annotations syntax.

This mixture of structured and unstructured information seems very difficult to me, so I would very much appreciate any help,


metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Processing XML with Java: A Guide to SAX, DOM, JDOM, JAXP, and TrAX

Other Java books

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover JBuilder - There is also a free version of Jbuilder at borland website . However its licence conditions are quite restrictive so you may prefer another java IDE.

Can this page be improved?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

progam

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

for xml encoding: http://sourceforge.net/projects/xes/

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.