nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] ruby syntax highlighting patterns


From: David Lawrence Ramsey
Subject: Re: [Nano-devel] ruby syntax highlighting patterns
Date: Mon, 22 May 2006 10:06:04 -0400
User-agent: Thunderbird 1.5.0.2 (X11/20060420)

John M. Gabriele wrote:
> I found some Ruby syntax highlighting patterns in the ruby-talk
> archives:
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/93305
>
> With the small corrections noted here
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/93453 ,
> and some of my own additions (noted below) including changing the
> first line to just "\.rb$", the patterns are:

<snip>

Interesting.  I hope the legal business gets sorted out soon (since the
Python regexes are from someone on a Gentoo forum with no contact
information that I can find, are they problematic too?).  I've done a
little research on Ruby and tweaked the regexes to simplify them when
possible.  Do the attached regexes still work as expected?

## Here is an example for Ruby.
##
syntax "ruby" "\.rb$"
## General
color white ".+"
## Operators
color brightyellow 
"::|\*\*|!|~|\*|/|%|\+|-|&|<<|>>|\|\^|>|>=|<|<=|<=>|\|\||!=|=~|!~|&&|\+=|-=|=|\.\.|\.\.\.|\<not\>|\<and\>|\<or\>"
## Keywords
color brightyellow 
"\<(BEGIN|END|alias|and|begin|break|case|class|def|defined|do|else|elsif|end|ensure|for|if|in|module|next|not|or|redo|rescue|retry|return|self|super|then|undef|unless|until|when|while|yield)\>"
## false, nil, true
color magenta "\<(false|nil|true)\>"
## Above must not match 'nil?'
color white "\<nil\?"
## External stuff
color brightgreen "\<(load|require|%!|%Q|%q|%r|%x)"
## Iterators
icolor brightgreen "\|[0-9A-Z_]*\|"
## Constants
color yellow "\<[A-Z][0-9A-Za-z_]*\>"
## Symbols
icolor yellow "([        ]|^):(@|@@|\$)?[0-9A-Z_]+\>"
## Strings
color green "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'"
icolor green "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)"
## Backticks
color green "`(\\.|[^\\"])*`" "%x\{[^}]*\}"
## Regular expressions
color green "/(\\.|[^\\/])*/[imox]*" "%r\{[^}]*\}[imox]"
## Escapes
color red "\\["'abefnrst\\]" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'" 
"(\\c|\\C-|\\M-|\\M-\\C-)."
## Expression substitution
icolor red "#\{[^}]*\}|#(@|@@|\$)[0-9A-Z_]+"
## Simple comments
color cyan "#([^{].*)?$"
## Shebang
color brightcyan "^#!.*"
## Multiline comments
color cyan start="^=begin" end="^=end"

reply via email to

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