Re: regexp in javascript.lang (3rd try!)
Lorenzo Bettini <[email protected]> Mon, 22 Dec 2008 14:58:07 +0100
| Newsgroups | gmane.comp.gnu.source-highlight.general |
|---|---|
| Message-ID | <[email protected]> |
OK so the only solution is the one you had proposed :-) it's quite a pity not re-using java.lang, but that's not a big deal, is it? ;-) cheers Lorenzo [email protected] wrote: > Lorenzo Bettini wrote: >> [email protected] 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); > } > > > _______________________________________________ > Help-source-highlight mailing list > [email protected] > http://lists.gnu.org/mailman/listinfo/help-source-highlight -- Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino ICQ# lbetto, 16080134 (GNU/Linux User # 158233) HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com http://www.myspace.com/supertrouperabba BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com http://www.gnu.org/software/src-highlite http://www.gnu.org/software/gengetopt http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net