[code] [textadept] Lexer rule for function names

From: Joshua Krämer <joshua.att.kraemer.link>
Date: Tue, 15 Jan 2019 21:57:53 +0100

Dear list,

I would like to extend the ansi_c lexer to highlight function names in
function definitions. As a test, in the following two lines, I would
like only the word "function" to be highlighted:

struct test *function () {};
struct test function () {};
if () {} else if () {};

I have tried the following rule (inserted on line 13), but it does not work:

lex:add_rule('function', -P('}') * (lexer.space^0 * lexer.word)^1 *
lpeg.S(' \t*')^1 * token(lexer.FUNCTION, lexer.word) * lexer.space^0 *
lexer.delimited_range('()', false, true, true))

It highlights "struct test *function" on the first line.

Could somebody please help me with this rule?

Thank you and kind regards,

You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 15 Jan 2019 - 15:57:53 EST

This archive was generated by hypermail 2.2.0 : Wed 16 Jan 2019 - 06:37:27 EST