KDev-PG-Qt and unions

Milian Wolff mail at milianw.de
Sat Apr 24 02:30:19 UTC 2010


Jonathan Schmidt-Dominé - Developer, 24.04.2010:
> Hi Milian!

Hey,

and just for the record: it was / is friday night, of course I'm not asleep :P
 
> I've now written a mediocre algorithm to compute an optimal layout for the
> ASTs. But of course a union is not enough, there should be some bits
> indicating which attributes are valid and which are not.

While a union might not be "enough" it's imo already much better than what we 
have right now. Afaik most / many AST nodes in the PHP plugin have exclusive 
member variables which are perfect usecases for an union imo.

> How should they be managed? We could use flags, we could generate inline-
> functions like bool hasA() and bool hasB(), we could use one integer-value
> for every possible combination and a table or a switch statement to
> determine if a variable is available.

This sounds too complicated to me. Imo the AST thingies should stay as simple 
as possible, meaning only member variables, no functions. flags etc. are only 
valid for the "bool" cases (i.e.: has this AST node the flag XYZ set). I have 
to admit that I don't know a single PHP ast node that has something like that. 
Well maybe classes that are either interfaces or classes... But again: a union 
would solve most of it.

And in PHP we already use flags to store e.g. modifiers just by inserting custom 
Cpp code. So imo nothing has to be improved in that regard.

> And of course we have to explain the
> user that he should never use a goto-statement in the parser-rules. :D
> There could even be an option to set the value indicating a combination
> manually...

Keep the syntax as-is and optimize where possible. I had the idea with the 
unions and really like it because it looks non-disruptive. One can simple 
implement it in the PG and the users don't have to care about it. Just the way 
it should be.

Bye
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20100424/023a7c83/attachment.sig>


More information about the KDevelop-devel mailing list