help-source-highlight
[Top][All Lists]
Advanced

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

Re: [Help-source-highlight] regexp in javascript.lang (3rd try!)


From: gnombat
Subject: Re: [Help-source-highlight] regexp in javascript.lang (3rd try!)
Date: Sun, 21 Dec 2008 15:40:49 -0600
User-agent: Thunderbird 2.0.0.18 (X11/20081105)

Lorenzo Bettini wrote:
address@hidden wrote:
include "c_comment.lang"

keyword =
"abstract|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|final|finally|for|function|goto|if|implements|in|instanceof|interface|native|new|null|private|protected|prototype|public|return|static|super|switch|synchronized|throw|throws|this|transient|true|try|typeof|var|volatile|while|with"

(symbol,normal,symbol) = `(\+\+|--|\)|\])(\s*)(/=?(?![*/]))`
(number,normal,symbol) =
`(0x[[:xdigit:]]+|(?:[[:digit:]]*\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?)(\s*)(/(?![*/]))`
(normal,symbol) = `([[:alpha:]$_][[:alnum:]$_]*\s*)(/=?(?![*/]))`

regexp = '/(\\.|[^*\\/])(\\.|[^\\/])*/[gim]*'

include "number.lang"

include "c_string.lang"

include "symbols.lang"

cbracket = "{|}"

include "function.lang"


Actually it works also this way, and it reuses most of java.lang (see the attached file);

what do you think?

The keyword definition has to occur before the definitions with the division operator in order to correctly match things like this:

/* unusual, but valid JavaScript */
throw /foo/;

/* this is more likely to occur in practice */
function f() {
  return /foo/;
}

/* or this */
function g(bar) {
  return /foo/.test(bar);
}




reply via email to

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