Tagged: regular expressions, syntax highlighting
- AuthorPosts
- February 1, 2014 at 4:33 am #17951MeirParticipant
Can anybody give me an example of how do I use regular expressions in syntax highlighting file (*.esy) to do either one of the following:
1. How to not consider'$#myArray'
a comment? (In Perl, the highest value of the index in@myArray
can be obtained as$#myArray
)
2. How do I treat a Perl keyword as a variable name when it is prefixed with a ‘sigil’ namely'$', '@', '%'
or'&'
? (For example,'date'
is a keyword, but$date
is a perfectly legal variable name.)
3. Similar to the above, how do I treat a Perl object method name as such, even if it is a keyword? (For example, the'warn'
part of$myObject->warn
is a ‘method’ of the object'$myObject'
, not a Perl keyword.)March 24, 2014 at 10:21 am #18131Yutaka EmuraKeymasterHi Meir,
1. Currently, there is no smart way, but you can specify “# ” as a line comment (insert a space at the end of ‘#”), and make sure to use a space after ‘#’ for every comment line.
2.3. You could use regular expressions – negative lookbehind search (?)warn , but that could slow down the process.
Thanks!
March 27, 2014 at 3:43 am #18142MeirParticipantThanks Yutaka,
Your suggestion cannot be used universally. e.g., when my legacy code has some commented-out segments, they now come back to life. Also, frames such as:
#########
#
#########
are considered “code”.But your syntax does refer to RegEx:
#Keyword color=4,word=on,rightall=off,case=off,insidetag=off,regexp=off,rightall2=off
What does
regexp=on
do?And finally, Can the RegEx-enhanced syntax highlighting files be moved up your priority list please?
January 28, 2016 at 12:10 am #20598MeirParticipantDear Yutaka,
I am trying desperately to make the syntax highlighting of perl accept ‘$#’ as color = 4 and not as $ followed by comment. So far no success :-(
The relevant lines I tried:#Keyword color=4,word=off,rightall=off,case=off,insidetag=off,regexp=on,rightall2=off /\$\#/
Please complete the RegExp…
Many, many thanks
— Meir
January 28, 2016 at 2:51 pm #20599Yutaka EmuraKeymasterHello Meir,
This looks good. What exactly is the issue here?
You may post screenshots or send me screenshots to provide more information.Thank you,
- AuthorPosts
- You must be logged in to reply to this topic.