[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] ruby syntax highlight patterns REDUX
From: |
John M. Gabriele |
Subject: |
Re: [Nano-devel] ruby syntax highlight patterns REDUX |
Date: |
Sun, 28 May 2006 23:22:56 -0700 (PDT) |
--- "John M. Gabriele" <address@hidden> wrote:
>
>
> --- "John M. Gabriele" <address@hidden> wrote:
>
> > [snip] Here's a first try -- [snip]
>
> I'd forgotten a few keywords, and also backticks (i.e. "shell
> commands"). Fixed "Symbols". Also changed the colors just a bit
> to be more palatable. The only critical thing to fix now is to
> get the comment highlighting not to interfere with expression
> substitution inside double-quoted strings.
>
> Here's what we've got so far:
>
> --------------------------- snip ---------------------------
>
> ## Here is an example for Ruby.
> syntax "ruby" "\.rb$"
>
> ## Asciibetical list of reserved words.
> color yellow
> "\<(__FILE__|__LINE__|BEGIN|END|alias|and|begin|break|case|class)\>"
> color yellow
> "\<(def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module)\>"
> color yellow
> "\<(next|nil|not|or|redo|rescue|retry|return|self|super|then|true)\>"
> color yellow "\<(undef|unless|until|when|while|yield)\>"
>
> ## Shell command expansion is in `backticks` or like %x{this}.
> color brightblue "`[^`]*`"
> color brightblue "%x\{[^}]*\}"
>
> ## Strings, double-quoted.
> color green ""[^"]*""
> color green "%[QW]?\{[^}]*\}"
>
> # Strings, single-quoted.
> color green "'[^']*'"
> color green "%[qw]\{[^}]*\}"
>
> ## Expression substitution. These are for inside double-quoted strings. "Like
> #{this}."
> ## Really, this one should *only* be for inside "", %{}, %Q{}, %W{}, or ``.
> XXX
> color brightgreen "#\{[^}]*\}"
>
> ## Symbols.
> color magenta ":[a-zA-Z0-9_]+\>"
>
> ## Regular expressions.
> ## Whoops. These shouldn't highlight inside strings. XXX
> color red "/[^/]*/[iomx]*"
> color red "%r\{[^}]*\}[iomx]*"
>
> ## Comments.
> ## How do I make this work everywhere *except* inside a string? XXX
> color cyan "#.*$"
>
> ## Some common markers.
> color brightcyan "(XXX|TODO|FIXME)"
>
> --------------------------- snip ---------------------------
>
> [snip]
>
> ---John
Ok, few small fixes:
- fixed double quotes so I can have a \" inside them:
color green ""([^"]|(\"))*""
Also fixed it for single quotes, but for some reason needed
an extra backslash: color green "'([^']|(\\'))*'"
- moved regexes above strings and backticks so they wouldn't
highlight inside them. Also changed them to brightmagenta.
- moved symbols way up so they wouldn't highlight
inside strings, regexes, and backticks.
- moved single quotes *below* expression substitution so
now you don't get #{this} highlit in single quoted strings.
- symbols, as done above, doesn't work right when you have
something Like::this in your code. To fix that, I tried
color magenta "([^:]|^):[a-zA-Z0-9_]+\>"
but the trouble with that is, for example, the first '[' in
foo[:bar] gets highlit...
- still trying to get a '#' character to not highlight inside
strings...
---John
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com