[Geany] Recognising PHP code (and perhaps others)

Murray Collingwood murray at xxxxx
Tue Dec 14 20:34:32 UTC 2010


Hi guys

I see your point - in the meantime I'm coding this way:

function abc($parm, // )
                  $p2,
                  $p3) {
  ...
}

This solves my immediate problem (having function names appear in the
Symbols list).

Cheers
mc


On 14 December 2010 22:39, Lex Trotman <elextr at gmail.com> wrote:

> On 14 December 2010 22:03, Etienne MELEARD <etienne.meleard at cru.fr> wrote:
> > 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 ...
>
> Thanks, clearly nested brackets and multiline declarations are beyond
> the regex system.  It needs someone with C and PHP capability to
> create a proper parser similar to the one used for C.
>
> Cheers
> Lex
>
> >>
> >>
> >>>
> >>> 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
> >>
> >>
> >
> > _______________________________________________
> > 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/users/attachments/20101215/606d98cf/attachment.html>


More information about the Users mailing list