forked from micro-editor/micro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb.yaml
More file actions
87 lines (75 loc) · 2.74 KB
/
b.yaml
File metadata and controls
87 lines (75 loc) · 2.74 KB
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
filetype: B
detect:
filename: '\.b$'
# core control words + storage classes (Thompson B-ish)
signature: '\b(if|else|while|switch|case|default|break|return|goto|extrn|auto)\b'
rules:
# -------------------------
# Comments (B: /* ... */)
# -------------------------
- comment:
start: '/\*'
end: '\*/'
rules: []
# Optional: // line comments (convenient, not “original” B)
- comment:
start: '//'
end: '$'
rules: []
# -------------------------
# Strings + escapes
# -------------------------
- constant.string:
start: '"'
end: '"'
skip: '\\\\.'
rules:
# common escapes: \n \t \e \r \0 \" \\ \( \) \*
- constant.specialChar: '\\\\([0netr"\\\\\\*\\(\\)])'
# printf-ish: %s %c %d %o and %%
- constant.specialChar: '%(%|[scdo])'
- constant.string:
start: "'"
end: "'"
skip: '\\\\.'
rules:
- constant.specialChar: '\\\\([0netr"\\\\\\*\\(\\)])'
- constant.specialChar: '%(%|[scdo])'
# -------------------------
# Numbers
# (leading 0 commonly used for octal constants)
# -------------------------
- constant.number: '\b0[0-7]+\b'
- constant.number: '\b[0-9]+\b'
# -------------------------
# Keywords / storage (keep tight + old-school)
# -------------------------
- statement: '\b(if|else|while|switch|case|default|break|return|goto)\b'
- type: '\b(extrn|auto)\b'
# -------------------------
# Common B library calls (/etc/libb.a era list)
# -------------------------
- constant.builtin: '\b(char|getchr|putchr|exit|printf|seek|setuid|stat|time|unlink|wait|lchar|chdir|chmod|chown|close|creat|execl|execv|fork|fstat|getuid|intr|link|makdir|open|read|write|ctime)\b'
# -------------------------
# Labels and function-ish identifiers
# -------------------------
# label (often at bol)
- identifier: '^\s*[_A-Za-z][_A-Za-z0-9]*\s*:'
# function call/def name before '('
- identifier: '\b[_A-Za-z][_A-Za-z0-9]*\s*\('
# -------------------------
# Operators (order matters: longer first)
# Thompson-ish assignment operators in B are =+, =-, =*, =/, =%, =<<, =>>, =& , =|
# -------------------------
- symbol.operator: '(=<<|=>>|=\+|=-|=\*|=/|=%|=&|=\|)'
- symbol.operator: '(==|!=|<=|>=|<<|>>)'
- symbol.operator: '(\+\+|--|\*\*)'
- symbol.operator: '[-+*/%&|^~!=<>?:=]'
# -------------------------
# Brackets
# -------------------------
- symbol.brackets: '[(){}\[\]]'
# -------------------------
# Identifiers / variables (last so keywords win)
# -------------------------
- identifier: '\b[_A-Za-z][_A-Za-z0-9]*\b'