Re: [Geany-devel] [Patch] - Improve PHP parser (call tips)

2010-04-14 Thread Harold Aling
2010/3/7 Enrico Tröger enrico.troe...@uvena.de:
 On Fri, 5 Mar 2010 12:21:25 -0800 (PST), Can wrote:

Hi,
The following patch adds call tips for functions in PHP code.
The regex pattern for function parameters is not optimal, but should
work for most cases. When you have a problem, send the relevant
function definition so that I can improve the patch.

 Awesome (though I still think it'd be better in thelong term to write
 a C-based, real parser insteaf of fiddling with regexps).
...
 For the meantime, committed.

I just found a 'bug' in the code:

function my_func($var1, $var2 = array(), $var3 = NULL) { ... } only
shows my_func($var1, $var2 = array()

So it stops at the first ) it finds instead of the real closing ).

-H-
___
Geany-devel mailing list
Geany-devel@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel


Re: [Geany-devel] Function Definition

2010-04-14 Thread Enzo Matrix
  So this brings me to my questions, is there an easy way to 
determine if
 the current position in the editor is part of a 
function or not?  If so
 is there an easy way to get the function
 definition?  If not could
 someone maybe point me to some 
tutorials about parsing text in c.
 
If you turn on your statusbar, will see the scope this show the function that 
you are now in. It is still buggy with php syntax but it is good point to start 
according me.
Your idea is good, i like it, this will provide easy way to documenting the 
code, go ahead!



  Оригинално писмо 
 От:  jordan  
 Относно: [Geany-devel] Function Definition
 До: geany-devel@uvena.de
 Изпратено на: Сряда, 2010, Април 14 15:25:15 EEST

 I'm trying to write a plug-in that among other things adds a function
 header.Unfortunately this is also my first C program so it has been
 more of  a learning experience then anything, but I'm finally at the
 point where it sort of works.
 
 So far it has been a trial and error sort of thing using devhelp and
 various web sites, but now I am at the point where I need some guidance
 that is Geany specific.  Currently my plug-in reads the current line and
 breaks it down, however it's my understanding that some C programmers
 may break a function definition over several lines, in which case my
 plug-in would not work properly.  I would also like to make it so the
 function definition for whatever the current function is would be used.
 
 So this brings me to my questions, is there an easy way to determine if
 the current position in the editor is part of a function or not?  If so
 is there an easy way to get the function definition?  If not could
 someone maybe point me to some tutorials about parsing text in c.
 
 Also I was wondering if it's possible to use Valgrind to profile a plug-in?
 
 Also currently the header that is generated by my plug-in c style multi
 line hard coded, and I was wondering if at some time more of the methods
 in templates.c would be opened up to the API? 
 
 -Jordan
 ___
 Geany-devel mailing list
 Geany-devel@uvena.de
 http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
 
 ___
Geany-devel mailing list
Geany-devel@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel


Re: [Geany-devel] Function Definition

2010-04-14 Thread Colomban Wendling
Hi Jordan,

jordan a écrit :
 I'm trying to write a plug-in that among other things adds a function
 header.Unfortunately this is also my first C program so it has been
 more of  a learning experience then anything, but I'm finally at the
 point where it sort of works.
What does your plugin, apart adding a function header? I'm curious.
And hum, I'm working on something similar to this part: a generic
documentation generator [1].

 Currently my plug-in reads the current line and
 breaks it down, however it's my understanding that some C programmers
 may break a function definition over several lines, in which case my
 plug-in would not work properly.
Yes. Many programmers (I'm of these) breaks function definition in
multiple line, actually I do something like this:

return_type
function_name (type arg1,
   type arg2,
   ...)

…and of course it is a little harder to naively parse (not so much in
facts, but doesn't allow what you do).

 I would also like to make it so the
 function definition for whatever the current function is would be used.
 
 So this brings me to my questions, is there an easy way to determine if
 the current position in the editor is part of a function or not?  If so
 is there an easy way to get the function definition?  If not could
 someone maybe point me to some tutorials about parsing text in c.
As Enzo said, there is the scope to determine if a particular line is
part of a function or not, but its is not supported by every tag
generator used by Geany. What I personally chose was to walk the tag
list and find the tag closest to the current line. Tweaking this way a
bit gives quite good results.

And for the function definition, see the tag list, there is everything
you probably want (or almost). One missing thing is the argument list –
I personally chose to fix this with a regular expression, but there
might be better solutions; for example if hard-coded things are
acceptable, a custom argument parser is a somewhat easy task.

 Also currently the header that is generated by my plug-in c style multi
 line hard coded, and I was wondering if at some time more of the methods
 in templates.c would be opened up to the API? 
I don't know exactly your goals, but Geany's templates are not complete.
if I'm right: they are very simple, which is good, but doesn't support
things like loops and so (as far as I know, tell me if I'm wrong).
Since I didn't find any template parser in C, I written my own [2] for
the needs of the plugin I write. It is heavily more complex, but OTOH
more powerful… choice is not easy, is it? :D If you're interested, feel
free to use it.

Regards,
Colomban

[1] no it's not dead, you'll see soon (for those who understand ^^)
[2] http://ctpl.tuxfamily.org/ ; but if you're interested, wait for the
upcoming 0.2 release that will be somewhat different in its API. It's
almost ready and can be found in the git master.
___
Geany-devel mailing list
Geany-devel@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel