[gtksourceview/gnome-3-24] language-specs: Add ABNF language specification



commit 157c5e099defb190ea00d676bd03211ac9766020
Author: Philip Withnall <philip tecnocode co uk>
Date:   Tue Dec 6 17:09:01 2016 +0000

    language-specs: Add ABNF language specification
    
    This is a style for Augmented Backus–Naur Form, as defined in RFC 5234:
     • https://tools.ietf.org/html/rfc5234https://en.wikipedia.org/wiki/Augmented_Backus%E2%80%93Naur_form
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775719

 data/language-specs/Makefile.am     |    1 +
 data/language-specs/abnf.lang       |  110 +++++++++++++++++++++++++++++++++++
 po/POTFILES.skip                    |    1 +
 tests/syntax-highlighting/file.abnf |   19 ++++++
 4 files changed, 131 insertions(+), 0 deletions(-)
---
diff --git a/data/language-specs/Makefile.am b/data/language-specs/Makefile.am
index 6477189..eab5ac3 100644
--- a/data/language-specs/Makefile.am
+++ b/data/language-specs/Makefile.am
@@ -2,6 +2,7 @@ TESTS = check-language.sh
 
 LANGUAGES =                    \
        actionscript.lang       \
+       abnf.lang               \
        ada.lang                \
        ansforth94.lang         \
        asp.lang                \
diff --git a/data/language-specs/abnf.lang b/data/language-specs/abnf.lang
new file mode 100644
index 0000000..f7b7bdc
--- /dev/null
+++ b/data/language-specs/abnf.lang
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ This file is part of GtkSourceView
+
+ Author: Philip Withnall <philip tecnocode co uk>
+ Copyright (C) 2016 Philip Withnall <philip tecnocode co uk>
+
+ 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, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+-->
+
+<!--
+References:
+       https://en.wikipedia.org/wiki/Augmented_Backus%E2%80%93Naur_form
+       https://tools.ietf.org/html/rfc5234
+       https://tools.ietf.org/html/rfc7405
+-->
+<language id="abnf" _name="ABNF" version="2.0" _section="Source">
+  <metadata>
+    <property name="globs">*.abnf</property>
+    <property name="line-comment-start">;</property>
+  </metadata>
+
+  <styles>
+    <style id="comment"     _name="Comment"            map-to="def:comment"/>
+    <style id="rulename"    _name="Rule Name"          map-to="def:type"/>
+    <style id="binary"      _name="Binary number"      map-to="def:base-n-integer"/>
+    <style id="decimal"     _name="Decimal number"     map-to="def:decimal"/>
+    <style id="hexadecimal" _name="Hexadecimal number" map-to="def:base-n-integer"/>
+    <style id="string"      _name="String"             map-to="def:string"/>
+  </styles>
+
+  <definitions>
+    <define-regex id="rulename">([a-zA-Z][a-zA-Z0-9-]*|&lt;[a-zA-Z][a-zA-Z0-9-]*&gt;)</define-regex>
+
+    <context id="line-comment" style-ref="comment" end-at-line-end="true" class="comment" 
class-disabled="no-spell-check">
+      <start>;</start>
+      <include>
+        <context ref="def:in-line-comment"/>
+      </include>
+    </context>
+
+    <context id="rulename">
+      <match>(\%{rulename})</match>
+      <include>
+        <context sub-pattern="1" style-ref="rulename"/>
+      </include>
+    </context>
+
+    <context id="terminal-binary" style-ref="binary">
+      <match>%b[0-1]+(\-[0-1]+|(\.[0-1]+)*)</match>
+    </context>
+
+    <context id="terminal-decimal" style-ref="decimal">
+      <match>%d[0-9]+(\-[0-9]+|(\.[0-9]+)*)</match>
+    </context>
+
+    <context id="terminal-hexadecimal" style-ref="hexadecimal">
+      <match>%x[0-9a-fA-F]+(\-[0-9a-fA-F]+|(\.[0-9a-fA-F]+)*)</match>
+    </context>
+
+    <context id="terminal-string" style-ref="string">
+      <match>"[ !#$%&amp;'\(\)\*\+,\-\./0-9:;&lt;=&gt;\?@A-Z\[\\\]\^_`a-z\{\|\}~]*"</match>
+    </context>
+
+    <context id="terminal">
+      <include>
+        <context ref="terminal-binary"/>
+        <context ref="terminal-decimal"/>
+        <context ref="terminal-hexadecimal"/>
+        <context ref="terminal-string"/>
+      </include>
+    </context>
+
+    <context id="element">
+      <include>
+        <context ref="rulename"/>
+        <context ref="terminal"/>
+      </include>
+    </context>
+
+    <context id="abnf">
+      <include>
+        <context ref="line-comment"/>
+        <context id="rule">
+          <start>^\s*(\%{rulename})\s*=/?</start>
+          <end>^(?!\s)</end>
+          <include>
+            <context sub-pattern="1" where="start" style-ref="rulename"/>
+            <context ref="element"/>
+            <context ref="line-comment"/>
+          </include>
+        </context>
+      </include>
+    </context>
+  </definitions>
+</language>
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 693348c..729233f 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -5,6 +5,7 @@ tests/test-search.ui
 tests/test-widget.ui
 tests/test-scheme.xml
 data/language-specs/actionscript.lang
+data/language-specs/abnf.lang
 data/language-specs/ada.lang
 data/language-specs/ansforth94.lang
 data/language-specs/asp.lang
diff --git a/tests/syntax-highlighting/file.abnf b/tests/syntax-highlighting/file.abnf
new file mode 100644
index 0000000..50c7ae8
--- /dev/null
+++ b/tests/syntax-highlighting/file.abnf
@@ -0,0 +1,19 @@
+; An ABNF file. Here’s a whole-line comment.
+
+rule1 = rule2 /
+        %b1010 /    ; mid-rule comment
+        %d100
+rule1 =/ %x20-25 /
+         %x30.31
+
+rule2 = "some-string" / "a"  ; here’s a comment at the end of a rule
+
+rule3=rule1 rule2
+
+rule4 = (rule3 rule1) / (rule1 *rule2)
+
+rule5 = 1*rule1 /
+        *2rule2 /
+        1*3rule3 /
+        2rule1 /
+        *1( rule4 rule3 )


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