[C2hs] Re: [Gtk2hs-devel] A new lexer/parser for c2hs

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Wed Jun 8 12:15:41 EDT 2005


On Wed, 2005-06-08 at 21:12 +1000, Manuel M T Chakravarty wrote:
> Duncan Coutts:
> > On Wed, 2005-06-01 at 22:16 +1000, Manuel M T Chakravarty wrote:
> > > Sounds good to me.
> > 
> > You can review the cleaned up versions of the lexer and parser here:
> > http://cvs.sourceforge.net/viewcvs.py/gtk2hs/gtk2hs/tools/c2hs/c/CLexer2.x?only_with_tag=branch-0-9-8&view=markup
> > http://cvs.sourceforge.net/viewcvs.py/gtk2hs/gtk2hs/tools/c2hs/c/CParser2.y?only_with_tag=branch-0-9-8&view=markup
> 
> Looks great!  Just two minor points:
> 
> * In CLexer2.idkwtok, why didn't you use string literals (but explicit 
>   lists of characters instead)?

Because GHC translates the former into a sequence of string comparisons,
but the latter using its effecient pattern matching algorithm. So the
former is a linear search, the latter is more like a trie. It makes a
significant difference to the speed of the lexer. We could of course use
an explicit trie data structure if we had one to hand.

> * I also prefer lines with max. 80 characters (I usually work on my 
>   laptop and its screen is not that big).

Ok, I'll see if I can reformat it before submitting it.

> I take it that the new version works fine on the whole of gtk2hs.

Yes it works for me and Axel on a number of platforms (Linux, Solaris,
Windows). The Gtk2Hs release candidate uses it.

> So, if you would prepare a patch against the mainline c2hs in the darcs
> repo, I'd be more than happy to replace the existing lexer and parser
> with your new version.

Great! I fear I may have to leave the required build system changes to
you. We're using a different build system.

Duncan



More information about the C2hs mailing list