Ticket #4644: turtle.syntax

File turtle.syntax, 4.4 KB (added by zaytsev, 6 days ago)
Line 
1#
2# Turtle syntax highlighting
3# for MC Editor/CoolEdit
4#
5# Copyright 2020, Jonas Smedegaard <dr@jones.dk>
6#
7# This program is free software:
8# you can redistribute it and/or modify it
9# under the terms of the GNU General Public License
10# as published by the Free Software Foundation,
11# either version 3 of the License,
12# or (at your option) any later version.
13#
14# 2020-04-12  Jonas Smedegaard <dr@jones.dk>
15#  * Initial public release.
16#
17# Reference:
18#   https://www.w3.org/TeamSubmission/turtle/
19
20context default lightgray
21    spellcheck
22
23# declarations
24    keyword whole @base magenta
25    keyword whole @prefix magenta
26
27    keyword whole a yellow
28
29    keyword ^^ brightmagenta
30
31# Collection
32    keyword ( brightmagenta
33    keyword ) brightmagenta
34
35# Shorthand prefix
36    keyword wholeleft \{abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\}\[\abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-\]: cyan
37    keyword wholeleft : cyan
38
39# Anonymous node
40    keyword wholeleft _: cyan
41    keyword [ cyan
42    keyword ] cyan
43
44# Decimal integers
45    keyword whole \{0123456789\}\[0123456789\] yellow
46    keyword whole \{-+\}\{0123456789\}\[0123456789\] yellow
47
48# Decimal floating point arbitrary precision number
49    keyword whole \{0123456789\}.\[0123456789\] yellow
50    keyword whole .\{0123456789\}\[0123456789\] yellow
51    keyword whole \{-+\}\{0123456789\}.\[0123456789\] yellow
52    keyword whole \{-+\}.\{0123456789\}\[0123456789\] yellow
53
54# Decimal floating point double/fixed precision number
55    keyword whole \{0123456789\}.\[0123456789\]\{eE\}\{0123456789\}\[0123456789\] yellow
56    keyword whole \{0123456789\}.\[0123456789\]\{-+\}\{eE\}\{0123456789\}\[0123456789\] yellow
57    keyword whole .\{0123456789\}\[0123456789\]\{eE\}\{0123456789\}\[0123456789\] yellow
58    keyword whole .\{0123456789\}\[0123456789\]\{-+\}\{eE\}\{0123456789\}\[0123456789\] yellow
59    keyword whole \{-+\}\{0123456789\}.\[0123456789\]\{eE\}\{0123456789\}\[0123456789\] yellow
60    keyword whole \{-+\}\{0123456789\}.\[0123456789\]\{-+\}\{eE\}\{0123456789\}\[0123456789\] yellow
61    keyword whole \{-+\}.\{0123456789\}\[0123456789\]\{eE\}\{0123456789\}\[0123456789\] yellow
62    keyword whole \{-+\}.\{0123456789\}\[0123456789\]\{-+\}\{eE\}\{0123456789\}\[0123456789\] yellow
63
64# Boolean
65    keyword whole true yellow
66    keyword whole false yellow
67
68# Language
69    keyword wholeright @\{abcdefghijklmnopqrstuvwxyz\}\[abcdefghijklmnopqrstuvwxyz0123456789-\]\[abcdefghijklmnopqrstuvwxyz0123456789\] brightmagenta
70    keyword wholeright @\{abcdefghijklmnopqrstuvwxyz\}\[abcdefghijklmnopqrstuvwxyz0123456789\] brightmagenta
71
72# Punctuation
73    keyword , white
74    keyword ; white
75#    keyword . black white
76    keyword . white brightmagenta
77
78# URL
79#    keyword whole <*> brightred
80context < > brightred
81
82# TODO: enable when context ending at newline doesn't ruin next context
83# syntax violation
84#    keyword  +\n black red
85
86# String escape
87    keyword \\u\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\} brightgreen
88    keyword \\U\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\} brightgreen
89    keyword \\\{tnr>\\} brightgreen
90
91# Single-line literals
92context exclusive " " green
93    spellcheck
94
95# TODO: enable when context ending at newline doesn't ruin next context
96# syntax violation
97#    keyword +\n black red
98
99# String escape
100    keyword \\u\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\} brightgreen
101    keyword \\U\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\} brightgreen
102    keyword \\\{tnr"\\} brightgreen
103
104# Multi-line literals
105context """ """ green
106    spellcheck
107
108# String escape
109    keyword \\u\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\} brightgreen
110    keyword \\U\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\}\{0123456789abcdef\} brightgreen
111    keyword \\\{tnr"\\} brightgreen
112
113# Comment
114context linestart # \n brown
115    spellcheck
116
117# Ideally we would have defined comments with "context linestart \[\s\]# ...",
118# but contexts can't start with a character class. So we define comments twice.
119context linestart \s\[\s\]# \n brown
120    spellcheck