[gtksourceview] added regex support to javascript preventing incorrect highlight of them as end-multiline-comment
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] added regex support to javascript preventing incorrect highlight of them as end-multiline-comment
- Date: Thu, 26 May 2011 14:25:48 +0000 (UTC)
commit 077be6f4f174952d09d5af6477003375ea5ca982
Author: Jim R. Wilson <wilson jim r gmail com>
Date: Wed May 25 17:37:08 2011 +0100
added regex support to javascript preventing incorrect highlight of them as end-multiline-comment
https://bugzilla.gnome.org/show_bug.cgi?id=600241
data/language-specs/javascript.lang | 36 +++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/data/language-specs/javascript.lang b/data/language-specs/javascript.lang
index 5214178..42cd15d 100644
--- a/data/language-specs/javascript.lang
+++ b/data/language-specs/javascript.lang
@@ -34,6 +34,7 @@
</metadata>
<styles>
+ <style id="escape" _name="Escaped Character" map-to="def:special-char"/>
<style id="null-value" _name="Null Value" map-to="def:special-constant"/>
<style id="undefined-value" _name="Undefined Value" map-to="def:special-constant"/>
<style id="boolean" _name="Boolean value" map-to="def:boolean"/>
@@ -43,10 +44,44 @@
<style id="properties" _name="Properties" map-to="def:statement"/>
<style id="constructors" _name="Constructors" map-to="def:type"/>
<style id="future-words" _name="Future Reserved Keywords" map-to="def:error"/>
+ <style id="regex" _name="Regular Expression" map-to="def:string"/>
</styles>
<definitions>
+ <!--regex-->
+ <define-regex id="regex-opts">[iomx]*[neus]?[iomx]*</define-regex>
+
+ <!--contexts NOT used in the main context-->
+ <context id="escape" style-ref="escape">
+ <match>\\((0-7){3}|(x[a-fA-F0-9]{2})|(c\S)|([CM]-\S)|(M-C-\S)|.)</match>
+ </context>
+
+ <context id="regex-bracketed" style-ref="escape" style-inside="true">
+ <start>(?<!\\)[[]</start>
+ <end>(?<!\\)]</end>
+ </context>
+
+ <!--contexts used in the main context-->
+ <context id="regex-simple" style-ref="regex">
+ <start extended="true">
+ ((?<=([(]|\s))|^)
+ \/
+ (?=
+ ([^/\\]*(\\.))*
+ [^/]*
+ \/
+ \%{regex-opts}
+ ([),;.]|\s|$)
+ )</start>
+ <end>\/\%{regex-opts}</end>
+ <include>
+ <context ref="escape"/>
+ <context ref="def:line-continue"/>
+ <context ref="regex-bracketed"/>
+ </include>
+ </context>
+
<!--
There was a long discussion on ##javascript on freenode between
'katspaugh', 'joo' and 'prog_' on whether 'undefined' should be
@@ -298,6 +333,7 @@
<context ref="properties"/>
<context ref="constructors"/>
<context ref="future-words"/>
+ <context ref="regex-simple"/>
</include>
</context>
<!--main context-->
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]