-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plumbing.sublime-syntax
111 lines (105 loc) · 3.24 KB
/
Plumbing.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
%YAML 1.2
---
name: Plumbing
file_extensions:
- plumbing
scope: source.plumbing
variables:
action_objects: \b(?:plumb)\b
action_verbs: \b(?:client|start|to)\b
common_ports: \b(?:edit|image|postscript|(see|send|show)mail|web)\b
include: \b(?:include)\b
pattern_objects: \b(?:arg|attr|data|dst|src|type)\b
pattern_types: \b(?:text)\b
pattern_verbs: \b(?:add|is(?:file)?|matches|set)\b
special_ports: \b(?:none)\b
variable_name: (?:[[:alpha:]_][[:alnum:]_]*)
builtin_vars: (?:\d+|attr|data|dir|dst|file|type|src|wdir)
contexts:
main:
- include: comments
# Include keyword
- match: '{{include}}'
scope: keyword.control.import.plumbing
push: include_line
# Rules consist of actions and patterns.
# The "objects" differing between pattern and action are marked as constants and functions;
# this is not semantically correct though,
# as the entities are usually user-defined,
# but otherwise the result is a soup of keywords in a single color.
- match: '{{pattern_objects}}'
scope: entity.name.constant.plumbing
push:
- pattern_rule
- match: '{{action_objects}}'
scope: entity.name.function.plumbing
push:
- action_rule
# Assignments
# TODO: how are strings handled on the rhs?
- match: '({{variable_name}})\s+(=)\s+(\w+)'
captures:
1: variable.other.plumbing
2: keyword.operator.assignment.plumbing
3: string.unquoted.plumbing
comments:
# Comments begin with a '#' and finish at the end of the line
- match: \#
scope: punctuation.definition.comment.plumbing
push:
- meta_scope: comment.line.number-sign.plumbing
- match: $
pop: true
# This is buggy, as it accepts more than a single word
include_line:
# The /sys/lib/plumb/basic file
- match: '\b(basic)\b'
scope: support.constant.plumbing
# Anything else is treated as a string
- match: '\w+'
scope: string.unquoted.plumbing
- match: $
pop: true
# Common definitions for rules
rule:
# Comments
- include: comments
# Strings
- match: "'"
scope: punctuation.definition.string.begin.plumbing
push: string
# Variables, either numbered ($0) or named ($foo)
- match: '(\$)(\d+|{{variable_name}})'
captures:
0: variable.parameter.plumbing
1: punctuation.definition.variable.plumbing
# Common plumber ports provided by the system
- match: '{{common_ports}}'
scope: support.constant.plumbing
- match: $
pop: true
pattern_rule:
- meta_scope: meta.rule.pattern.plumbing
- include: rule
- match: '{{pattern_verbs}}'
scope: keyword.operator.word.plumbing
- match: '{{pattern_types}}'
scope: constant.language.plumbing
- match: $
pop: true
action_rule:
- meta_scope: meta.rule.action.plumbing
- include: rule
- match: '{{action_verbs}}'
scope: keyword.other.plumbing
- match: '{{special_ports}}'
scope: constant.language.plumbing
- match: $
pop: true
string:
- meta_scope: string.quoted.single.plumbing
- match: '\\.'
scope: constant.character.escape.plumbing
- match: "'"
scope: punctuation.definition.string.end.plumbing
pop: true