dotgnu-general
[Top][All Lists]
Advanced

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

[DotGNU]A design for comment , dfa2c# ?


From: Gopal V
Subject: [DotGNU]A design for comment , dfa2c# ?
Date: Sun, 18 May 2003 20:50:21 +0530
User-agent: Mutt/1.2.5i

Hi,
        This is going to be part of DotGNU shortly , we need to
construct a state machine which works well and efficently ..
It's for cleaning up the XML parser into a good structure .

It's a DFA with epsilon transitions ... and I'm looking for 
a good syntax format ...

%{
        // rest of code
        public override bool Read()
        {
                .... locals
%}

%macro read $1 = ReadChar()
%macro peek $1 = PeekChar()
%macro alphanum (($1 >= 'A' && $1 <= 'Z') || ($1 >='a' && $1<='z'))

%state START
        : '<'  --> opening_tag
        | alphanum --> text
        | '&' --> entity
        | NONE --> empty  
        | OTHER --> error
        ;

%state END 

Seemed to be a good idea with 

%action START %{
        // action for start ...
%}

etc...

Which will form a large method of the form...

START:
        c = ReadChar();
        do
        {
                // action;
        }while(false);
        c = PeekChar();
        if(c == '<')
        {
#ifdef TRACE
                Trace.WriteLine(" got '&' going to closing_tag");
#endif
#ifdef DEBUG_STACK
        .......
#endif 
                goto opening_tag;
        }
        ...
END:
        return true;
ERROR:
        return false;
        etc...

That being the basic idea of the whole process , I'll be very happy 
if I get some companion for the journey .. The convertor will be written
in C , using Flex , Bison , and if possible TreeCC ..

The convertor will also convert the DFA into a visual graph using 
something like graphviz ... For documentation and debugging purposes.

I need all the help , I can especially from minddog and any other person
hanging around .. Relatively simple convertor , possibly ... 

As much as I detest goto's all around code , in this case I make an
exception as it is faster than a switch() statement system where there
are no fall throughs. And inlining code in this way will speed it up
no end .. I would have used an array , but that would slow down things
by adding a register flush & array bounds check.

Hopefully this might solve a lot of our problems while incremental
features are added to the XML parser ... (like for example <!DOCTYPE
starting off without affecting comment parsing code). Also it should
promise a lot of optimisations (DFA state reduction etc...)

Also I would like comments from the XML whizes and compiler design gurus 
about the idea , syntax or design.

So how about it ?
Gopal
-- 
The difference between insanity and genius is measured by success


reply via email to

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