-
Notifications
You must be signed in to change notification settings - Fork 0
/
Forth.sublime-syntax
132 lines (116 loc) · 4.03 KB
/
Forth.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
%YAML 1.2
---
# Simplified syntax for any Forth-like language.
# Inspired from "forth.lang" in the GtkSourceView project.
name: Forth
file_extensions:
- fs
- fth
- f4
scope: source.forth
contexts:
main:
- include: comments
- include: preprocessors
- include: definitions
- include: strings
- include: keywords
- include: locals
- include: numbers
comments:
- include: line-comments
- include: paren-comments
- include: block-comments
- include: doc-comments
- include: debug-comments
strings:
- include: s-strings
- include: tilde-strings
- include: comment-strings
- include: error-strings
definitions:
- match: (?<![^\s])(?i:POSTPONE|\[COMPILE\]|\[CHAR\]|\['\]|COMPILE|CHAR|[DFT]?VALUE|[2FT]?VARIABLE|[DS]?FVARIABLE|[T]?USER|[T]?CODE|[DZFT]?LOCAL|[2FT]?CONSTANT|TCONSTANT-|TSUB|=\:|==\:|DEFER|HC\:|[VHTM]?\:)\s+[^\s]+(?![^\s])
scope: storage.type.forth
locals:
- match: (?<![^\s])(?i:[DFZ]?LOCALS)\|\s+[^\|]+[\|](?![^\s])
scope: variable.locals.forth
keywords:
- match: (?<![^\s])(?i:\[IF\]|\[ELSE\]|\[THEN\]|\[DEFINED\]|\[UNDEFINED\]|\?DEF|\?UNDEF|THROW|CASE|ENDCASE|OF|ENDOF|FOR|NEXT|IF[,]?|ELSE[,]?|THEN[,]?|ENDIF[,]?|BEGIN[,]?|WHILE[,]?|REPEAT[,]?|UNTIL[,]?|AGAIN[,]?|DO|LOOP|\?DO|\+LOOP|LEAVE|\?LEAVE|UNLOOP|EXIT|\?EXIT|PAR|ENDPAR|STARTP|ENDP|PRIVATE|PRIVATES|DEPRIVE|FORGET|IMMEDIATE|ALSO|ONLY|FORTH|DEFINITIONS|HEADERLESS|\:ABOUT|DOES>|FORGET>|CREATE|\:NONAME|;)(?![^\s])
scope: keyword.control.forth
s-strings:
- match: (?<![^\s])(?i:S|[.]|EVAL|C|Z|,)"\s
scope: punctuation.definition.string.begin.forth
push:
- meta_scope: string.quoted.double.forth
- match: (")\s
scope: punctuation.definition.string.end.forth
pop: true
tilde-strings:
- match: (?<![^\s])(\.~)\s
scope: punctuation.definition.string.begin.forth
push:
- meta_scope: string.tilde.forth
- match: (~)
scope: punctuation.definition.string.end.forth
pop: true
comment-strings:
- match: (?<![^\s])(\.\()\s
scope: punctuation.definition.string.begin.forth
push:
- meta_scope: string.comment.forth
- match: \)
scope: punctuation.definition.string.end.forth
pop: true
error-strings:
- match: (?<![^\s])(?i:ABORT|\?ERROR)"\s
scope: punctuation.definition.string.begin.forth
push:
- meta_scope: string.error.forth
- match: (")\s
scope: punctuation.definition.string.end.forth
pop: true
numbers:
- match: (?<![^\s])([$][-+]?[A-F0-9.]+|[#][-+]?[0-9.]+|[%][-+]?[0-1.]+|[-+]?[0-9.]+|[-+]?[0-9]+[.]?[0-9]*[eE][0-9]*|'[^\s]'|[\^][A-Za-z]|TRUE|FALSE)(?![^\s])
scope: constant.numeric.forth
preprocessors:
- match: (?<![^\s])(?i:NEEDS|INCLUDE|IN|MARKER)\s+[^\s]*(?![^\s])
scope: meta.preprocessor.forth
- match: (?<![^\s])(?i:REVISION)\s+[^\s]*\s*".*"(?![^\s])
scope: meta.preprocessor.forth
- match: (?<![^\s])(?i:INCLUDED|INCLUDE-FILE)(?![^\s])
scope: meta.preprocessor.forth
- match: (?<![^\s])(\[)(?![^\s])
push:
- meta_scope: meta.preprocessor.forth
- match: (?<![^\s])(\])(?![^\s])
pop: true
line-comments:
- match: (?<![^\s])(?i:\\|\\G)(?![^\s])
push:
- meta_scope: comment.line.forth
- match: \n
pop: true
paren-comments:
- match: (?<![^\s])(?i:\(|\(S|\(F)(?![^\s])
push:
- meta_scope: comment.block.forth
- match: \)
pop: true
block-comments:
- match: (?<![^\s])\(\*(?![^\s])
push:
- meta_scope: comment.block.forth
- match: \*\)(?![^\s])
pop: true
doc-comments:
- match: (?<![^\s])(?i:DOC)(?![^\s])
push:
- meta_scope: comment.block.doc.forth
- match: (?<![^\s])(?i:ENDDOC)(?![^\s])
pop: true
debug-comments:
- match: (?<![^\s])(?i:<<DEBUG)(?![^\s])
push:
- meta_scope: comment.block.debug.forth
- match: (?<![^\s])(?i:DEBUG>>)(?![^\s])
pop: true