summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gryk <gryk@uchc.edu>2021-03-11 21:47:45 +0000
committerChristian Hergert <christian@hergert.me>2021-03-11 21:47:45 +0000
commit9bac286ff1cf8be72d2eb4f5d11f1b2e398e758e (patch)
tree64935d583b3ce87022504d344c945e26f36d0d8c
parentc405ecfc36065dfd6dd52593b41adca9e7fad263 (diff)
downloadgtksourceview-9bac286ff1cf8be72d2eb4f5d11f1b2e398e758e.tar.gz
star.lang: add STAR file format for scientific domains
-rw-r--r--data/language-specs/star.lang96
-rw-r--r--tests/syntax-highlighting/file.str23
2 files changed, 119 insertions, 0 deletions
diff --git a/data/language-specs/star.lang b/data/language-specs/star.lang
new file mode 100644
index 00000000..90186f17
--- /dev/null
+++ b/data/language-specs/star.lang
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ This file is part of GtkSourceView
+
+ Author: Michael R. Gryk <gryk@uchc.edu>
+ Copyright (c) 2020-2021 Michael R. Gryk <gryk@uchc.edu>
+
+ GtkSourceView is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ GtkSourceView is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, see <http://www.gnu.org/licenses/>.
+
+ STAR is the file format used by the Protein Data Bank (mmCIF) and BioMagResBank (NMR-STAR) among others
+ For more information, see:
+ Hall, S.R. The STAR File: A New Format for Electronic Data Transfer and Archiving. J. Chem. Inf. Comput. 31, 326-333 (1991).
+ Hall, S.R. & Spadaccini, N. The STAR File: Detailed Specifications. J. Chem. Inf. Comput. 34, 505-508 (1994).
+
+ -->
+<language id="star" name="STAR" version="2.0" _section="Scientific">
+ <metadata>
+ <property name="globs">*.str;*.cif;*.mif</property>
+ <property name="line-comment-start">#</property>
+ </metadata>
+
+ <styles>
+ <style id="comment" _name="Comment" map-to="def:comment"/>
+ <style id="data-name" _name="Data Name (key)" map-to="def:identifier"/>
+ <style id="keyword" _name="Keyword" map-to="def:keyword"/>
+ <style id="framecode" _name="Frame Code" map-to="def:type"/>
+ <style id="string" _name="String (value)" map-to="def:string"/>
+ <style id="data-value" _name="Data Value" />
+ </styles>
+
+ <default-regex-options case-sensitive="false"/>
+
+ <definitions>
+ <define-regex id="starChars">[!-~]+</define-regex>
+
+ <context id="comment" end-at-line-end="true" style-ref="comment" class="comment">
+ <start>#</start>
+ </context>
+ <context id="data-value" class="no-spell-check">
+ <match>\%{starChars}</match>
+ </context>
+ <context id="data-name" style-ref="data-name" class="no-spell-check">
+ <match>_\%{starChars}</match>
+ </context>
+ <context id="framecode" style-ref="framecode" class="no-spell-check">
+ <match>\$\%{starChars}</match>
+ </context>
+ <context id="quote-string" style-ref="string" end-at-line-end="true" class="string">
+ <start>"</start>
+ <end>"\s</end>
+ </context>
+ <context id="apos-string" style-ref="string" end-at-line-end="true" class="string">
+ <start>'</start>
+ <end>'\s</end>
+ </context>
+ <context id="semi-string" style-ref="string" end-at-line-end="false" class="string">
+ <start>^;</start>
+ <end>^;</end>
+ </context>
+
+ <context id="keywords" style-ref="keyword">
+ <keyword>data_\%{starChars}</keyword>
+ <keyword>save_\%{starChars}</keyword>
+ <keyword>save_</keyword>
+ <keyword>loop_</keyword>
+ <keyword>stop_</keyword>
+ <keyword>global_</keyword>
+ </context>
+
+ <context id="star">
+ <include>
+ <context ref="comment"/>
+ <context ref="data-name"/>
+ <context ref="keywords"/>
+ <context ref="framecode"/>
+ <context ref="semi-string"/>
+ <context ref="quote-string"/>
+ <context ref="apos-string"/>
+ <context ref="data-value"/>
+ </include>
+ </context>
+
+ </definitions>
+</language>
diff --git a/tests/syntax-highlighting/file.str b/tests/syntax-highlighting/file.str
new file mode 100644
index 00000000..1fcc4087
--- /dev/null
+++ b/tests/syntax-highlighting/file.str
@@ -0,0 +1,23 @@
+#File level comment
+data_blockname
+ _key1 value1 #key-value pair
+ _key2
+ value2#notacomment
+
+ save_frame
+
+ loop_ # tabular data
+
+ _col1
+ _col2
+
+ value1 "valu"e2" 'O'Connor' #string rules
+;
+multi-line strings need semi-colon delimiters
+;
+ stop_ # This is NMR-STAR syntax
+
+ save_
+
+global_
+ _key1 valueGlobal