dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]Call for volunteers: HTML pretty printer


From: Gopal V
Subject: Re: [DotGNU]Call for volunteers: HTML pretty printer
Date: Wed, 28 May 2003 08:50:28 +0530
User-agent: Mutt/1.2.5i

If memory serves me right, j_post wrote:
> > The tool, tentatively named "cssrc2html", would take a C# source file and
> > format it as HTML, color-coding the keywords, comments, and what-not. 
> >
> Anyone want to test it?
> Jeff

I gotta really ask you this ... why did you write your own scanner for 
C# ?.. I think you could have gotten away with a simple flex scanner 
and saved a lot of work and code as well.

You could have gotten away with just

#define CLOSE_AND_OPEN(stream,type,color) \
                do\
                {\
                        if(previous!=TOK_##type)\
                        { \
                                CSSrcGenClosingTag(previous);\
                                CSSrcGenOpeningTag(TOK_##type);\
                                previous = TOK_#type;\
                        }\
                }\
                while(0)

        switch(yylex())
        {
                case TOK_KEYWORD:
                        CLOSE_AND_OPEN(outStream, KEYWORD, "cs-keyword");
                        fputs(yytext,outStream);
                        break;
                        ...
        }

You have spent such a lot of work on the scanner , that HTML gen has 
suffered , so to speak . I can only say that I don't like the HTML it 
generates .. As far as possible , try to stick to XML compatible HTML 
syntax . Your code seems to have gone too deep into <font> hell :-)

Convert all \n into <br/> and all tabs into &nbsp;&nbsp;&nbsp;&nbsp;
etc...

You might even define the formatting as classes and use a .css file to 
set the colors & highlights instead of hard-coding them in HTML ..

<font class="lineno">1 </font>
<font class="cskeyword">using</font> <font class="csidentifier">System</font>
<font class="cspunct">;</font>

Modularize, Simplify and well -- Use the Force ;-)

Gopal
-- 
The difference between insanity and genius is measured by success


reply via email to

[Prev in Thread] Current Thread [Next in Thread]