summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Westman <james@jwestman.net>2023-05-16 14:45:21 -0500
committerJames Westman <james@jwestman.net>2023-05-16 20:58:05 -0500
commit5f3847eb59cb28680da2d80b13f1f1c32b5688a3 (patch)
tree779f7abf0ff458c2f8a3f4d3ac11387b9c54d493
parent052aac9772ef2e76f4ea9d9f2c27fa0d806254ab (diff)
downloadgtksourceview-5f3847eb59cb28680da2d80b13f1f1c32b5688a3.tar.gz
language-specs: Add support for Blueprint
-rw-r--r--data/language-specs/blueprint.lang344
-rw-r--r--po/POTFILES.skip1
-rw-r--r--tests/syntax-highlighting/file.blp34
3 files changed, 379 insertions, 0 deletions
diff --git a/data/language-specs/blueprint.lang b/data/language-specs/blueprint.lang
new file mode 100644
index 00000000..8443df31
--- /dev/null
+++ b/data/language-specs/blueprint.lang
@@ -0,0 +1,344 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ This file is part of GtkSourceView
+
+ Author: James Westman <james@jwestman.net>
+ Copyright (C) 2023 James Westman <james@jwestman.net>
+
+ 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/>.
+
+-->
+<language id="blueprint" name="Blueprint" version="2.0" _section="Other">
+ <metadata>
+ <property name="globs">*.blp</property>
+ <property name="mimetypes">text/x-blueprint</property>
+ <property name="block-comment-start">/*</property>
+ <property name="block-comment-end">*/</property>
+ <property name="line-comment-start">//</property>
+ </metadata>
+
+ <styles>
+
+ <!-- global -->
+ <style id="comment" name="Comment" map-to="def:comment"/>
+ <style id="translator" name="Translator Comment" map-to="def:emphasis"/>
+ <style id="keyword" name="Keyword" map-to="def:keyword"/>
+ <style id="namespace" name="Namespace" map-to="def:type"/>
+ <style id="class" name="Class" map-to="def:type"/>
+ <style id="function" name="Function" map-to="def:function"/>
+ <style id="property" name="Property" map-to="def:identifier"/>
+ <style id="identifier" name="Identifier" map-to="def:identifier"/>
+ <style id="builtin" name="Builtin" map-to="def:builtin"/>
+ <style id="child_type" name="Child Type" map-to="def:identifier"/>
+
+ <!-- data types -->
+ <style id="escape" name="Escape Sequence" map-to="def:special-char"/>
+ <style id="string" name="String" map-to="def:string"/>
+ <style id="boolean" name="Boolean" map-to="def:boolean"/>
+ <style id="null" name="Null" map-to="def:special-constant"/>
+ <style id="number" name="Number" map-to="def:number"/>
+ </styles>
+
+ <definitions>
+ <define-regex id="ident">[A-Za-z_][\d\w\-_]*</define-regex>
+ <define-regex id="quoted">("(\\"|[^"\n])+"|'(\\'|[^'\n])+')</define-regex>
+ <define-regex id="number">[-+]?((\d[0-9a-zA-Z_]*(\.[0-9a-zA-Z_]+)?)|(\.[0-9_]+))</define-regex>
+ <define-regex id="comment">(/\*[\s\S]*\*/|\/\/[^\n]*)</define-regex>
+ <define-regex id="op">[:=\.=\|&lt;&gt;\+\-/\*]+</define-regex>
+ <define-regex id="escape">\\n|\\"|\\'</define-regex>
+
+ <context id="type">
+ <include>
+ <context style-ref="class">
+ <match>\$\s*\%{ident}</match>
+ </context>
+ <context>
+ <match>(?:(\%{ident})\s*(\.)\s*)?(\%{ident})</match>
+ <include>
+ <context sub-pattern="1" style-ref="namespace"/>
+ <context sub-pattern="3" style-ref="class"/>
+ </include>
+ </context>
+ </include>
+ </context>
+
+ <context id="value">
+ <include>
+ <context>
+ <start>(typeof)\s*&lt;</start>
+ <end>&gt;</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="keyword"/>
+ <context ref="type"/>
+ </include>
+ </context>
+ <context style-ref="boolean">
+ <match>true|false</match>
+ </context>
+ <context style-ref="null">
+ <match>null</match>
+ </context>
+ <context style-ref="builtin">
+ <match>template</match>
+ </context>
+ <context style-ref="number">
+ <match>\%{number}</match>
+ </context>
+ <context style-ref="string">
+ <start>"</start>
+ <end>"</end>
+ <include>
+ <context style-ref="escape">
+ <match>\%{escape}</match>
+ </context>
+ </include>
+ </context>
+ <context style-ref="string">
+ <start>'</start>
+ <end>'</end>
+ <include>
+ <context style-ref="escape">
+ <match>\%{escape}</match>
+ </context>
+ </include>
+ </context>
+ <context style-ref="identifier">
+ <match>\%{ident}</match>
+ </context>
+ </include>
+ </context>
+
+ <context id="comment">
+ <include>
+ <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="multiline-comment" style-ref="comment" class="comment" class-disabled="no-spell-check">
+ <start>/\*</start>
+ <end>\*/</end>
+ <include>
+ <context ref="def:in-comment"/>
+ <context id="translator-comment" style-ref="translator">
+ <match case-sensitive="false">translators:</match>
+ </context>
+ </include>
+ </context>
+ </include>
+ </context>
+
+ <context id="content">
+ <include>
+ <context ref="comment"/>
+
+ <!-- Keywords -->
+ <context style-ref="keyword">
+ <keyword>after</keyword>
+ <keyword>bidirectional</keyword>
+ <keyword>bind-property</keyword>
+ <keyword>bind</keyword>
+ <keyword>default</keyword>
+ <keyword>destructive</keyword>
+ <keyword>disabled</keyword>
+ <keyword>inverted</keyword>
+ <keyword>no-sync-create</keyword>
+ <keyword>suggested</keyword>
+ <keyword>swapped</keyword>
+ <keyword>sync-create</keyword>
+ <keyword>template</keyword>
+ </context>
+
+ <!-- Translated strings -->
+ <context>
+ <start>(C?_)\s*\(</start>
+ <end>\)</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="function" />
+ <context ref="content"/>
+ </include>
+ </context>
+
+ <!-- Cast expressions -->
+ <context>
+ <start>(as)\s*&lt;</start>
+ <end>&gt;</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="keyword"/>
+ <context ref="type"/>
+ </include>
+ </context>
+
+ <!-- Closures -->
+ <context id="closure">
+ <start>(\$?\%{ident})\s*\(</start>
+ <end>\)</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="function"/>
+ <context ref="content"/>
+ </include>
+ </context>
+
+ <!-- Objects -->
+ <context>
+ <start extended="true">
+ (?:
+ (?:(\%{ident})\s*\.\s*)?(\%{ident})
+ | (\$\s*\%{ident})
+ )
+ (?:\s+(\%{ident}))?
+ \s*
+ \{
+ </start>
+ <end>\}</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="namespace"/>
+ <context where="start" sub-pattern="2" style-ref="class"/>
+ <context where="start" sub-pattern="3" style-ref="class"/>
+ <context where="start" sub-pattern="4" style-ref="identifier"/>
+ <context ref="block-content"/>
+ </include>
+ </context>
+
+ <context ref="value"/>
+ </include>
+ </context>
+
+ <context id="block-content">
+ <include>
+ <!-- Templates -->
+ <context id="template">
+ <start>template</start>
+ <include>
+ <context where="start" sub-pattern="0" style-ref="keyword"/>
+ <context ref="type"/>
+ <context end-parent="true">
+ <start>{</start>
+ <end>}</end>
+ <include>
+ <context ref="block-content"/>
+ </include>
+ </context>
+ </include>
+ </context>
+
+ <!-- Import statements -->
+ <context id="using">
+ <match extended="true">
+ (using)
+ \s+
+ (\%{ident})
+ \s+
+ (\%{number})
+ </match>
+ <include>
+ <context sub-pattern="1" style-ref="keyword"/>
+ <context sub-pattern="2" style-ref="namespace"/>
+ <context sub-pattern="3" style-ref="namespace"/>
+ </include>
+ </context>
+
+ <!-- Menus -->
+ <context>
+ <start extended="true">
+ (menu|submenu|section)
+ (?:\s+(\%{ident}))?
+ \s*
+ \{
+ </start>
+ <end>}</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="keyword"/>
+ <context where="start" sub-pattern="2" style-ref="identifier"/>
+ <context ref="block-content"/>
+ </include>
+ </context>
+
+ <!-- Nested blocks -->
+ <context>
+ <start>(responses|items|mime-types|patterns|suffixes|marks|widgets|strings|styles)\s*\[</start>
+ <end>]</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="keyword"/>
+ <context ref="block-content"/>
+ </include>
+ </context>
+
+ <context>
+ <start>(accessibility|setters|layout|item)\s*\{</start>
+ <end>}</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="keyword"/>
+ <context ref="block-content"/>
+ </include>
+ </context>
+
+ <context>
+ <start>(condition|mark|item)\s*\(</start>
+ <end>\)</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="keyword"/>
+ <context ref="block-content"/>
+ </include>
+ </context>
+
+ <context style-ref="child_type">
+ <start>\[</start>
+ <end>\]</end>
+ <include>
+ <context>
+ <match>(action)\s+(response)\s*=\s*(?:(\%{ident})|(\%{number}))</match>
+ <include>
+ <context sub-pattern="1" style-ref="keyword"/>
+ <context sub-pattern="1" style-ref="identifier"/>
+ <context sub-pattern="3" style-ref="identifier"/>
+ <context sub-pattern="4" style-ref="number"/>
+ </include>
+ </context>
+ <context style-ref="keyword">
+ <keyword>default</keyword>
+ <keyword>internal-child</keyword>
+ </context>
+ <context style-ref="child_type">
+ <match>\%{ident}</match>
+ </context>
+ </include>
+ </context>
+
+ <!-- Properties and signals -->
+ <context>
+ <start>(\%{ident}(?:::\%{ident})?)\s*(:|=>)</start>
+ <end>;</end>
+ <include>
+ <context where="start" sub-pattern="1" style-ref="property"/>
+ <context ref="content"/>
+ </include>
+ </context>
+
+ <context ref="content"/>
+ </include>
+ </context>
+
+ <context id="blueprint" class="no-spell-check">
+ <include>
+ <context ref="comment"/>
+ <context ref="block-content"/>
+ </include>
+ </context>
+ </definitions>
+</language>
+
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 63c15447..cd3bb70f 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -16,6 +16,7 @@ data/language-specs/automake.lang
data/language-specs/awk.lang
data/language-specs/bennugd.lang
data/language-specs/bibtex.lang
+data/language-specs/blueprint.lang
data/language-specs/bluespec.lang
data/language-specs/boo.lang
data/language-specs/cg.lang
diff --git a/tests/syntax-highlighting/file.blp b/tests/syntax-highlighting/file.blp
new file mode 100644
index 00000000..ffea5004
--- /dev/null
+++ b/tests/syntax-highlighting/file.blp
@@ -0,0 +1,34 @@
+using Gtk 4.0;
+using Adw 1;
+
+template $MyTemplate : Gtk.Window {
+ hello: world | there;
+ translated: C_("test", "String");
+ numbers: 0x1_000_000;
+ types: typeof<Adjustment>;
+
+ notify::something => $respond_somehow() swapped;
+
+ working: bind-property template.idle inverted;
+ status: bind $get_status(template.idle, true, 10) as <$MyStatus>.string;
+
+ Dialog {
+ [action response=0 default]
+ Button btn {}
+ [action response=cancel]
+ Button btn2 {}
+ }
+
+ Adw.Breakpoint {
+ condition ("max-width: 100")
+ setters {
+ label.foo: 10;
+ }
+ }
+}
+
+menu my-menu {
+ submenu {
+ attribute: "yes";
+ }
+}