[Geany] Recognising PHP code (and perhaps others)

Etienne MELEARD etienne.meleard at xxxxx
Tue Dec 14 11:03:41 UTC 2010


Le 14/12/2010 11:58, Lex Trotman a écrit :
> On 14 December 2010 21:38, Murray Collingwood
> <murray at focus-computing.com.au>  wrote:
>    
>> Hi Lex
>>
>> Thanks for your response.
>>
>> One simple solution would be to drop the trailing bracket from the regex.
>> Do you think this would be an acceptable change?
>>      
> Unfortunately then the parser would not be able to identify the
> argument list for one line declarations (notice that the  \\(.*\\) is
> in () as a capture group) and that would mean no arglist, or worse an
> incorrect arglist, for those declarations that work right at the
> moment.
>
> Maybe the regex could be changed to \\([^)]\\)? making the ) optional
> and if its not there counting all the rest of the line as the
> arguments.  Its not pretty, but at least the function should be
> recognised.
>
> Anyone else's thoughts?
>
> Cheers
> Lex
>
> PS I don't know much PHP, but I should note that if a ) can occur
> anywhere in the declaration then no regex is correct.
>    
Yeah, declarations can be like this to describe optionnal arguments and 
their default values :

     function foo($arg1, $arg2 = array('random', 'stuff'), $arg3 = 'bar') {
         // ...
     }

Hope im clear enough ...
>    
>> Cheers
>> Murray
>>
>>
>> On 14 December 2010 18:34, Lex Trotman<elextr at gmail.com>  wrote:
>>      
>>> On 14 December 2010 18:23, Murray Collingwood
>>> <murray at focus-computing.com.au>  wrote:
>>>        
>>>> Hello (first time on this list)
>>>>
>>>> Just a question, maybe something I can hack, maybe something somebody
>>>> else
>>>> needs to hack?
>>>>
>>>> I have php code that looks like this:
>>>>
>>>>       function puctstatus($puctid) {
>>>>          ...
>>>>       }
>>>>
>>>> The 'Symbols' list in the sidebar then lists for me the function name
>>>> and
>>>> all is good.
>>>>
>>>> However if my code is like this:
>>>>
>>>>        function puctstatus($puctid,
>>>>                                    $category,
>>>>                                    $flags) {
>>>>           .....
>>>>        }
>>>>
>>>> Then the function is not recognised and does not appear in the symbols
>>>> list.
>>>>
>>>> Is there a file somewhere full of regex type codes that I can edit to
>>>> modify
>>>> this or is it all hardcoded in a program somewhere?
>>>>          
>>> Yes there is a regex, but its hard coded.
>>>
>>> This is it, where ALPHA and ALNUM are the ranges you would expect
>>>
>>> "^[ \t]*[(public|protected|private|static|final)[ \t]*]*[
>>> \t]*function[ \t]+&?[ \t]*([" ALPHA "_][" ALNUM
>>> "_]*)[[:space:]]*(\\(.*\\))"
>>>
>>> I'd guess the problem is that \\(.*\\) matches anything in () after
>>> the function name but the regex code only matches against a line at a
>>> time and has no way of continuing the match beyond a line.
>>>
>>> The only way to go beyond a line seems to be to use a character by
>>> character hardcoded parser such as C uses.
>>>
>>> In tagmanager/php.c there is a bunch of code that looks like someone
>>> started to do it, status unknown.
>>>
>>> Cheers
>>> Lex
>>>
>>>        
>>>> Cheers
>>>> mc
>>>>
>>>>
>>>>
>>>> --
>>>> Murray Collingwood
>>>> Focus Computing
>>>> p +61 415 24 26 24
>>>> http://www.focus-computing.com.au
>>>>
>>>> _______________________________________________
>>>> Geany mailing list
>>>> Geany at uvena.de
>>>> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
>>>>
>>>>
>>>>          
>>> _______________________________________________
>>> Geany mailing list
>>> Geany at uvena.de
>>> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
>>>        
>>
>>
>> --
>> Murray Collingwood
>> Focus Computing
>> p +61 415 24 26 24
>> http://www.focus-computing.com.au
>>
>> _______________________________________________
>> Geany mailing list
>> Geany at uvena.de
>> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
>>
>>
>>      
> _______________________________________________
> Geany mailing list
> Geany at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
>
>    




More information about the Users mailing list