One of the potential problems is regular expressions facility of Emacs Lisp. First of all it uses quite inconvenient dialect of regexps. Many constructs need to be escaped with '\' (alternative (|) and grouping, for example). Second, ELisp doesn't have special syntax for regexps. You have to use strings, where slash has to be escaped again. So even simple regexp a|b turns to "a\\|b".
Two years ago I've written small regexp DSL for Emacs Lisp. Using this DSL you can express complex regular expressions readably.
So today I found regexp literal expression in espresso.el -- "[=(,:]\\(?:\\s-\\|\n\\)*\\(/\\)\\(?:\\\\/\\|[^/*]\\)\\(?:\\\\/\\|[^/]\\)*\\(/\\)", translated it to my DSL and got:
(redsl-to-regexp `(concat (char-set "=(,:") (* (or (whitespace) "\n")) (cap-group /) (or "\\/" (neg-char-set "/*")) (* (or "\\/" (neg-char-set "/"))) (cap-group /)))
which is simply wrong. It obviously fails for simple regexp -- /\\/
I tranformed it into:
(redsl-to-regexp `(concat (char-set "=(,:") (* (or (whitespace) "\n")) (cap-group /) (+ (or (neg-char-set "\\/") (concat "\\" (anychar)))) (cap-group /)))
which is logical and works. And ура ура I finally have working syntax highlighting in javascript mode!
I've uploaded regex-dsl to http://github.com/alk/elisp-regex-dsl and will send espresso.el fix soon.
I've uploaded regex-dsl to http://github.com/alk/elisp-regex-dsl and will send espresso.el fix soon.