[M3devel] UI, Trestle, native... Cocoa??

Rodney M. Bates rodney_bates at lcwb.coop
Wed Sep 29 18:47:46 CEST 2010



Darko wrote:
> 
> I don't understand where the payoff is in doing anything else when there is no way of reliably automating it and making it 
 > output something clean, putting you back to square one and having to hack anyway. A hacked parser of a C subset is the
> most direct and reliable route I think. I already have a little "programmable" parser which is half way there. It 
> understands expressions with function call syntax and lets you define infix, postfix, prefix and groupfix (eg "{ ... }") 
> operators with precedence. With a couple of extensions I think I can make the headers look like a series of simple
> declaration expressions. Throw in an exception mechanism which lets you insert hand made expressions when you encounter 
> specific symbols and it's done (plus generating the M3 interfaces, of course).
> 
>
Hmm.  I once wrote a C parser using Cocktail rex/lalr, with either Modula-2 or Modula-3 semantic actions to build
an AST.  The really tricky part was unwinding C's half-inside-out syntax for type definitions.  Without jumping into
the wars over which way is inside-out, C is nonetheless inconsistent.  Declarators are the unusual way, but only
with respect to one type, function parameters and array bounds being the usual way.  Programmer-defined specifiers are
the usual way.  Putting this into an AST involves selectively inverting, if it is to be an AS that makes any sense
of the recursive system of type constructors and type definitions.

Maybe I could drag that one out and spruce it up some way.

OTOH, C programmers almost never actually use the recursive system of types except for a few well-known idioms
of fixed shape and depth, so maybe a parser/AST builder that only handles a severe subset is adequate.



More information about the M3devel mailing list