help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I get emacs to highlight subroutine calls in c-mode.


From: jan
Subject: Re: How do I get emacs to highlight subroutine calls in c-mode.
Date: 17 Oct 2003 10:40:42 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

"Javier Oviedo" <email_joviedo@yahoo.com> writes:

> This is pretty cool. Could this be adapted to also work for calls
> through function pointers? That would be quite nice!!
> 
> Example:
> (*someStructure.someCallTable->someFunctionPointer)((void *)&test);

("\\<\\(\\sw+\\)[ \t\n)]*(" 1 font-lock-function-call-face)

This version will do the job, however, being more general it also runs
the risk of getting false positive matches. I can't think of any cases
off the top of my head.

You can still get false negatives, for example:

(*someStructure.someCallTable->someFunctionPointer)
     /* comment */
     ((void *)&test);

or

some_function_array[0]();

but I think it's best not to handle those cases unless you actually
write code like that.

The basic problem is that regular expressions aren't powerful enough
to describe a language like C (or almost any other language for that
matter). They cannot be made to understand operator precedence or
remove redundant parenthesis or handle any kind of nesting. In other
words they really have no understanding of the structure of the code
and the font tables are reduced to making guesses by matching against
simple text patterns.

-- 
jan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]