Skip to content

Commit 14e165e

Browse files
committed
Add GTKSourceView syntax
1 parent 7acad44 commit 14e165e

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
/out/
77
/store/
88
/optimizations/
9-
OwnLang.iml
9+
OwnLang.iml
10+
*.sh

editors/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ import Prism from 'prismjs';
1313
import definePrismOwnLang from './prismjs/own-language.js'
1414
definePrismOwnLang(Prism)
1515
```
16+
17+
## GTKSourceView
18+
19+
Place `ownlang.lang` in `/usr/share/gtksourceview-3.0/language-specs/ownlang.lang`

editors/gtksourceview/ownlang.lang

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<language id="ownlang" name="OwnLang" version="2.0" _section="Source">
3+
<metadata>
4+
<property name="mimetypes">text/x-own</property>
5+
<property name="globs">*.own</property>
6+
<property name="line-comment-start">//</property>
7+
<property name="block-comment-start">/*</property>
8+
<property name="block-comment-end">*/</property>
9+
</metadata>
10+
11+
<styles>
12+
<style id="comment" name="Comment" map-to="def:comment"/>
13+
<style id="escaped-character" name="Escaped Character" map-to="def:special-char"/>
14+
<style id="string" name="String" map-to="def:string"/>
15+
<style id="keyword" name="Keyword" map-to="def:keyword"/>
16+
<style id="boolean" name="Boolean value" map-to="def:boolean"/>
17+
<style id="number" name="Number" map-to="def:decimal"/>
18+
<style id="type" name="Data Type" map-to="def:type"/>
19+
</styles>
20+
21+
<definitions>
22+
23+
<define-regex id="escaped-character" extended="true">
24+
\\( # leading backslash
25+
[\\\"\'nrbtf] | # escaped character
26+
[0-9]{1,3} | # latin encoded char
27+
u[0-9]{1,4} # unicode char
28+
)
29+
</define-regex>
30+
31+
<context id="string" style-ref="string" end-at-line-end="true" class="string"
32+
class-disabled="no-spell-check">
33+
<start>"</start>
34+
<end>"</end>
35+
<include>
36+
<context id="escaped-character" style-ref="escaped-character">
37+
<match>\%{escaped-character}</match>
38+
</context>
39+
</include>
40+
</context>
41+
42+
<context id="keywords" style-ref="keyword">
43+
<keyword>print</keyword>
44+
<keyword>println</keyword>
45+
<keyword>if</keyword>
46+
<keyword>else</keyword>
47+
<keyword>while</keyword>
48+
<keyword>for</keyword>
49+
<keyword>do</keyword>
50+
<keyword>break</keyword>
51+
<keyword>continue</keyword>
52+
<keyword>def</keyword>
53+
<keyword>return</keyword>
54+
<keyword>use</keyword>
55+
<keyword>match</keyword>
56+
<keyword>case</keyword>
57+
<keyword>extract</keyword>
58+
<keyword>include</keyword>
59+
<keyword>class</keyword>
60+
<keyword>new</keyword>
61+
</context>
62+
63+
<context id="boolean" style-ref="boolean">
64+
<keyword>false</keyword>
65+
<keyword>true</keyword>
66+
</context>
67+
68+
<context id="numeric" style-ref="number">
69+
<match extended="true">
70+
(\b([0-9]+|0[xX][0-9a-fA-F]+)[Ll]?\b|
71+
\b(([0-9]+[Ee][-]?[0-9]+|
72+
([0-9]*\.[0-9]+|[0-9]+\.)([Ee][-]?[0-9]+)?)))
73+
</match>
74+
</context>
75+
76+
<context id="ownlang" class="no-spell-check">
77+
<include>
78+
<context ref="def:c-like-comment" style-ref="comment"/>
79+
<context ref="def:c-like-comment-multiline" style-ref="comment"/>
80+
<context ref="def:c-like-close-comment-outside-comment"/>
81+
<context ref="boolean"/>
82+
<context ref="numeric"/>
83+
<context ref="string"/>
84+
<context ref="keywords"/>
85+
</include>
86+
</context>
87+
88+
</definitions>
89+
</language>

0 commit comments

Comments
 (0)