Extending PHP support - facing problems with expansion of list of aliases
Steven Rémot <[email protected]> Sat, 02 Aug 2014 13:33:01 +0200
| Newsgroups | gmane.emacs.semantic |
|---|---|
| Message-ID | <[email protected]> |
Hi,
as I use PHP for my job, I'm currently working on enhancing PHP support
in CEDET, mainly by extending the current grammar.
So far, I have added :
- namespaces
- optional type annotation for function's arguments
- Better support for class fields and constants
I am working on a separated repository at the address :
https://bitbucket.org/stevenremot/cedet/
I wanted to talk about it and propose it to be included in the main
cedet repository later, when I have some more features, but I'm a
beginner in grammar writing, and I have difficulties to correctly create
tags for the PHP "use" statement.
This statement can be seen as a typedef. If you want to use a class
named A\B\C\Foo ("\" is the common namespace separator) by calling it
just "ABCFoo", you can type :
use A\B\C\Foo as ABCFoo;
If you want to call it Foo, you just have to type :
use \A\B\C\Foo;
My current work handles this well, and creates an alias tag for it.
However, you can also chain multiple renamings in a single use statement
like this :
use A\B\C\Bar, \A\B\Foo;
My current solution for handling this is :
use_statement
: T_USE use_declarations T_SEMI
(EXPANDTAG $2)
;
use_declarations
: use_declaration T_COMMA use_declarations
(append $3 (EXPANDTAG $1))
| use_declaration
(EXPANDTAG $1)
;
use_declaration
: namespaced_identifier T_AS IDENTIFIER
(ALIAS-TAG $3 "alias" $1)
| namespaced_identifier
(ALIAS-TAG (car (last (split-string $1 "\\\\"))) "alias" $1)
;
(My usage of ALIAS-TAG may be wrong, I did not really know how to handle
the second argument as I can't know the type of A\B\C\Foo for now)
But with these rules no tag is created on multiple renamings. I think
either my use of EXPANDTAG or my concatenation of aliases is wrong, but
I can't find any nice solution to fix it.
Does someone know how I could handle it ?
--
Steven Rémot
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
cedet-semantic mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cedet-semantic