[Geany-devel] question about templates

Enrico Tröger enrico.troeger at xxxxx
Tue Jul 14 19:19:34 UTC 2009


On Mon, 13 Jul 2009 02:52:54 +0200, Andreas wrote:

>On Thu, 9 Jul 2009 16:25:09 +0200
>Enrico Tröger <enrico.troeger at uvena.de> wrote:
>> >Well, parse_cpp_function_at_line() *should* actually work with haxe
>> >then at first glance. Maybe symbols_get_current_function does
>> >something wrong? I'll try to debug it ...  
>> Cool, much appreciated.
>
>Seems like the symbol parser for haxe is the cause. 
>There are many different parsers in the /tagmanager directory. Where do
>they come from?

Almost all are identical (minus a few different header includes and
other very minor changes) with the parsers from the Ctags project
(http://ctags.sourceforge.net).


>The ActionScript parser e.g. uses some regex and recognizes function
>scopes quite good at least. The haxe parser does without regex and
>misses all private functions e.g.

There are two types of parsers: regex based parsers which parse each
line of the file on its own and apply regular expressions to find
symbols. An example for this is the PHP parser (and the Actionscript
parser you mentioned). While this is pretty easy to implement, it is
also not completely accurate in some cases but this depends on the
language. E.g. for PHP it works pretty fine except when you have
multiline comments which contain the keyword 'function', e.g.
/* some test
 * function foo_bar is commented out because it doesn't work
 */
then the parser will find 'foo_bar' as a PHP function because the regex
matches. And there is no easy way to get rid of this mistake because
the regex based parsing is done line by line without any state
information of previous lines. That is, the parser doesn't know there
is an open multi line line comment when it sees the line " * function
foo_bar ...".

The other type of parsers are more complex, they parse the file either
character by character or also line by line but then keep state
information of previous lines to detect and properly handle multi line
comments or wrapped lines or whatever.

To summarise it, regex based parsers are probably easier to implement
but are also more likely to produce wrong results due to less
information they have about the parsed line.


>Is there some documentation for writing a tagmanager parser somewhere?

On the Ctags project website I found
http://ctags.sourceforge.net/EXTENDING.html.

Regards,
Enrico

-- 
Get my GPG key from http://www.uvena.de/pub.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20090714/b8832e4e/attachment.pgp>


More information about the Devel mailing list