Page 1 of 1
newbie: how to highlight function names ?
Posted: 17.12.2015 20:27
by runsun
How do I set up lexer to highlight function
name? The code looks like:
Code: Select all
function asc(c, n = 0) =
( // some text
c == chr(n) ? n : asc(c, n + 1)
);
I want to highlight the word "
asc".
Posted: 17.12.2015 21:09
by Alexey
Need
-create parser
-set its regex to "any word after word _function_"-- see regex syntax about "lookahead assertion"
-parser made. then set its style
Posted: 17.12.2015 23:21
by runsun
I did try that approach. The parser that I used:
It's been tested in
https://regex101.com nicely but doesn't seem to work in synwrite.
The detailed steps I tried:
1) Create a new lexer
2) Copy and paste the example code to the example code box
3) Create a parser named "p_func" with the above regex
4) Create a style named "s_func" and set background
5) Link s_func to p_func
Nothing happened. The following didn't match anything either:
Code: Select all
(?<=function )\w+
function \w+
(?<=function ).*
The following two match something:
Code: Select all
function .* ==> "function asc(c, n = 0) = "
function .*(?=\() ==> "function asc"
Posted: 18.12.2015 00:13
by Alexey
It works
(?<=function\s+)\w+
I test on new lexer
Posted: 18.12.2015 02:24
by runsun
Thx a lot, Alexey. I missed the \s.
Btw, thx for your effort on this wonderful editor. Being using Notepad++ for years, only recently I found that SynWrite is much more powerful in the lexer feature. Will spend more time trying out other features. Thx.