Skip to content

Commit b0e4290

Browse files
committed
Highlight flow control functions.
1 parent a6c272f commit b0e4290

File tree

2 files changed

+202
-115
lines changed

2 files changed

+202
-115
lines changed

AutoLISP.YAML-tmLanguage

Lines changed: 72 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,45 @@ fileTypes: [lsp]
66
uuid: 00D451C9-6B1D-11D9-8DFA-000D93589AF7
77

88
patterns:
9-
- include: '#comment'
10-
- include: '#atom'
11-
- include: '#function'
9+
- include: '#comments'
10+
- include: '#parens'
1211

1312
repository:
1413

15-
comment:
14+
comments:
1615
patterns:
1716
- name: comment.block.autolisp
1817
begin: ;\|
1918
end: \|;
2019
- name: comment.line.semicolon.autolisp
2120
match: ;.*$
2221

23-
atom:
22+
parens:
2423
patterns:
25-
- include: '#string'
26-
- include: '#number'
27-
- include: '#symbol'
24+
- name: meta.group.autolisp
25+
begin: \(
26+
beginCaptures:
27+
'0': {name: punctuation.definition.group.begin.autolisp}
28+
end: \)
29+
endCaptures:
30+
'0': {name: punctuation.definition.group.end.autolisp}
31+
patterns:
32+
- include: '#expressions'
33+
- include: '#parens'
34+
35+
expressions:
36+
patterns:
37+
- include: '#comments'
38+
- include: '#strings'
39+
- include: '#numbers'
40+
- include: '#control'
41+
# - include: '#operator'
42+
- include: '#functions'
43+
- include: '#symbols'
2844

29-
string:
45+
strings:
3046
patterns:
3147
- name: string.quoted.double.autolisp
32-
#match: \".*?[^\\]\"
3348
begin: '"'
3449
beginCaptures:
3550
'0': {name: punctuation.definition.string.begin.autolisp}
@@ -40,12 +55,35 @@ repository:
4055
- match: \\(?:\d{1,3}|.)
4156
name: constant.character.escape.autolisp
4257

43-
number:
58+
numbers:
4459
patterns:
4560
- name: constant.numeric.autolisp
46-
match: (?i)(?<=^|['\s()])[+-]?\d+\.?\d*(?=$|[\s()])
61+
match: (?<=^|['\s()])[+-]?\d+\.?\d*((e|E)(\+|-)?\d+)?(?=$|[\s()])
62+
63+
control:
64+
patterns:
65+
- name: keyword.control.autolisp
66+
match: (?<=^|['\s()])(?i:cond|if|and|or|not|progn|exit|quit|repeat|while|foreach|setq)(?=$|[\s()])
67+
68+
# operator:
69+
# patterns:
70+
# - name: keyword.operator.comparsion.autolisp
71+
# match: (?<=^|['\s()])(?i:=|/=|<|>|<=|>=)(?=$|[\s()])
72+
# - name: keyword.operator.arithmetic.autolisp
73+
# match: (?<=^|['\s()])(?i:\+|-|\*|/|1\+|1-)(?=$|[\s()])
74+
75+
functions:
76+
patterns:
77+
- name: meta.function.autolisp
78+
match: (?i)(defun[q]?)\s+([^'\s()]+)\s*(\()([^'()]*)(\))
79+
captures:
80+
'1': {name: storage.type.function.autolisp}
81+
'2': {name: entity.name.function.autolisp}
82+
'3': {name: punctuation.definition.parameters.begin.autolisp}
83+
'4': {name: variable.parameter.autolisp}
84+
'5': {name: punctuation.definition.parameters.end.autolisp}
4785

48-
symbol:
86+
symbols:
4987
patterns:
5088
- include: '#vanilla'
5189
- include: '#vl'
@@ -55,43 +93,30 @@ repository:
5593
- include: '#vla'
5694
- include: '#call'
5795

58-
function:
59-
patterns:
60-
- name: meta.function.autolisp
61-
#match: (?i)(?<=defun|defun-q)\s+([^'\s()]+)\s*(\()\s*([^'\s()]+)\s*(\))
62-
match: (?i)(?<=defun|defun-q)\s+([^'\s()]+)\s*(\()([^'()]*)(\))
63-
captures:
64-
'1': {name: entity.name.function.autolisp}
65-
'2': {name: punctuation.defenition.parameters.begin.autolisp}
66-
'3': {name: variable.parameter.autolisp}
67-
'4': {name: punctuation.defenition.parameters.end.autolisp}
68-
6996
vanilla:
7097
patterns:
7198
- name: variable.language.vanilla.autolisp
7299
match: (?i)(?<=^|['\s()])\*(?:last-value|error|push-error-using-(?:command|stack)|pop-error-mode)\*(?=$|[\s()])
73100
- name: constant.language.vanilla.autolisp
74101
match: (?i)(?<=^|['\s()])(?:nil|t)(?=$|[\s()])
75-
- name: support.constant.vanilla.autolisp
76-
match: (?i)(?<=^|['\s()])(?:pi)(?=$|[\s()])
77-
- name: support.function.control.vanilla.autolisp
78-
match: (?i)(?<=^|['\s()])(?:while|cond|if|progn|repeat)(?=$|[\s()])
79102
- name: support.function.base.vanilla.autolisp
80-
match: (?i)(?<=^|['\s()])(?:load|defun(?:-q(?:-list-(?:ref|set)?)?)?|set[q]?|function|lambda|read|eval|trace|untrace)(?=$|[\s()])
81-
- name: support.function.type.vanilla.autolisp
82-
match: (?i)(?<=^|['\s()])(?:type)(?=$|[\s()])
83-
- name: support.function.comparsion.vanilla.autolisp
84-
match: (?i)(?<=^|['\s()])(?:eq|equal|=|/=|<|<=|>|>=|or|and|not)(?=$|[\s()])
103+
match: (?<=^|['\s()])(?i:eval|quote|setq|lambda|function|apply|defun|defun-q|cond|if|and|or|not|progn|exit|quit|repeat|while|foreach|equal|eq|=|/=|<|>|<=|>=|type|trace|untrace)(?=$|[\s()])
85104
- name: support.function.symbol.vanilla.autolisp
86-
match: (?i)(?<=^|['\s()])(?:boundp|atoms-family|type|quote)(?=$|[\s()])
105+
match: (?i)(?<=^|['\s()])(?:set|boundp|atoms-family)(?=$|[\s()])
87106
- name: support.function.string.vanilla.autolisp
88107
match: (?i)(?<=^|['\s()])(?:strlen|substr|strcat|ascii|chr|strcase|wcmatch|acad_strlsort)(?=$|[\s()])
108+
- name: support.function.number.vanilla.autolisp
109+
match: (?<=^|['\s()])(?i:numberp|zerop|minusp|\+|-|\*|/|1\+|1-|rem|float|fix)(?=$|[\s()])
110+
- name: support.constant.math.vanilla.autolisp
111+
match: (?i)(?<=^|['\s()])(?:pi)(?=$|[\s()])
89112
- name: support.function.math.vanilla.autolisp
90-
match: (?i)(?<=^|['\s()])(?:numberp|zerop|minusp|float|fix|\+|-|\*|/|1\+|1-|min|max|abs|rem|gcd|sqrt|expt|exp|log|sin|cos|atan|~|lsh|logand|logior|boole)(?=$|[\s()])
113+
match: (?<=^|['\s()])(?i:min|max|abs|gcd|sqrt|expt|exp|log|sin|cos|atan)(?=$|[\s()])
114+
- name: support.function.bitwise.vanilla.autolisp
115+
match: (?<=^|['\s()])(?i:~|lsh|logand|logior|boole)(?=$|[\s()])
91116
- name: support.function.list.vanilla.autolisp
92-
match: (?i)(?<=^|['\s()])(?:atom|null|listp|cons|list|c[ad]{1,4}r|last|nth|length|reverse|append|mapcar|foreach|apply|member|subst|assoc)(?=$|[\s()])
117+
match: (?i)(?<=^|['\s()])(?:atom|null|listp|cons|list|c[ad]{1,4}r|last|nth|length|reverse|append|mapcar|member|subst|assoc)(?=$|[\s()])
93118
- name: support.function.io.vanilla.autolisp
94-
match: (?i)(?<=^|['\s()])(?:open|close|(?:read|write)-(?:char|line)|findfile|findtrustedfile|fnsplitl|prin[tc1])(?=$|[\s()])
119+
match: (?i)(?<=^|['\s()])(?:open|close|(?:read|write)-(?:char|line)|findfile|findtrustedfile|fnsplitl|prin[tc1]|read|load)(?=$|[\s()])
95120
- name: support.function.display.vanilla.autolisp
96121
match: (?i)(?<=^|['\s()])(?:prompt|terpri|textpage|textscr|graphscr|redraw|grtext|grdraw|grvecs|vports|menucmd|menugroup)(?=$|[\s()])
97122
- name: support.function.acad.vanilla.autolisp
@@ -116,7 +141,7 @@ repository:
116141
- name: support.function.string.vl.autolisp
117142
match: (?i)(?<=^|['\s()])vl-(?:string-(?:elt|(?:left-|right-)?trim|position|search|translate|mismatch|>list)|list->string)(?=$|[\s()])
118143
- name: support.function.list.vl.autolisp
119-
match: (?i)(?<=^|['\s()])vl-(?:consp|list\*|list-length|every|some|position|remove(?:-if(?:-not)?)?|member-if(?:-not)?|sort(?:-i)?)(?=$|[\s()])
144+
match: (?i)(?<=^|['\s()])vl-(?:consp|list\*|list-length|some|every|member-if(?:-not)?|position|remove(?:-if(?:-not)?)?|sort(?:-i)?)(?=$|[\s()])
120145
- name: support.function.io.vl.autolisp
121146
match: (?i)(?<=^|['\s()])vl-(?:prin[c1]-to-string|file-(?:directory-p|size|systime|rename|copy|delete)|filename-(?:directory|base|extension|mktemp)|directory-files|mkdir)(?=$|[\s()])
122147
- name: support.function.error.vl.autolisp
@@ -128,7 +153,7 @@ repository:
128153
patterns:
129154
- name: support.constant.vle.autolisp
130155
match: (?i)(?<=^|['\s()])vle-extensions-active(?=$|[\s()])
131-
- name: support.function.control.vle.autolisp
156+
- name: keyword.control.vle.autolisp
132157
match: (?i)(?<=^|['\s()])until(?=$|[\s()])
133158
- name: support.function.symbol.vle.autolisp
134159
match: (?i)(?<=^|['\s()])vle-symbolp(?=$|[\s()])
@@ -264,8 +289,10 @@ repository:
264289
match: (?i)(?<=^|['\s()])ll-(?:features)(?=$|[\s()])
265290
- name: support.function.require.call.autolisp
266291
match: (?i)(?<=^|['\s()])ll-(?:featurep|provide|require)(?=$|[\s()])
292+
- name: support.function.logic.call.autolisp
293+
match: (?i)(?<=^|['\s()])ll-(?:nand|nor|xor)(?=$|[\s()])
267294
- name: support.function.type.call.autolisp
268-
match: (?i)(?<=^|['\s()])ll-(?:anyp|typep)(?=$|[\s()])
295+
match: (?i)(?<=^|['\s()])ll-(?:typep|anyp|functionp)(?=$|[\s()])
269296
- name: support.constant.boolean.call.autolisp
270297
match: (?i)(?<=^|['\s()])ll-(?:true|false)(?=$|[\s()])
271298
- name: support.function.boolean.call.autolisp
@@ -276,12 +303,10 @@ repository:
276303
match: (?i)(?<=^|['\s()])ll-(?:voidp)(?=$|[\s()])
277304
- name: support.function.symbol.call.autolisp
278305
match: (?i)(?<=^|['\s()])ll-(?:symbolp|symbol-value|symbol-name)(?=$|[\s()])
279-
- name: support.function.def.call.autolisp
280-
match: (?i)(?<=^|['\s()])ll-(?:functionp)(?=$|[\s()])
281306
- name: support.function.string.call.autolisp
282307
match: (?i)(?<=^|['\s()])ll-(?:substring|list->string|string-(?:>list|elt|position)|string-(?:left-|right-)?trim)(?=$|[\s()])
283-
- name: support.function.stringx.call.autolisp
284-
match: (?i)(?<=^|['\s()])ll-(?:string(?:=|/=|<|<=|>|>=)|string-(?:not-)?(?:equal|lessp|greaterp))(?=$|[\s()])
308+
# - name: support.function.stringx.call.autolisp
309+
# match: (?i)(?<=^|['\s()])ll-(?:string(?:=|/=|<|>|<=|>=)|string-(?:not-)?(?:equal|lessp|greaterp))(?=$|[\s()])
285310
- name: support.function.random.call.autolisp
286311
match: (?i)(?<=^|['\s()])ll-(?:rand|srand|random|random-seed)(?=$|[\s()])
287312
- name: support.function.number.call.autolisp
@@ -294,8 +319,10 @@ repository:
294319
match: (?i)(?<=^|['\s()])ll-(?:signum|round|floor|ceiling|truncate|fract|lcm|tan|asin|acos|radians->degrees|degrees->radians)(?=$|[\s()])
295320
- name: support.function.mathx.call.autolisp
296321
match: (?i)(?<=^|['\s()])ll-(?:1/|sqr|exp10|exp2|log10|log2|cot|sec|csc|acot|asec|acsc|versin|vercos|coversin|covercos|haversin|havercos|hacoversin|hacovercos|exsec|excsc|sinh|cosh|tanh|coth|sech|csch|asinh|acosh|atanh|acoth|asech|acsch|gons->radians|radians->gons|gons->degrees|degrees->gons|dms->degrees|degrees->dms)(?=$|[\s()])
322+
- name: support.constant.bitwise.call.autolisp
323+
match: (?i)(?<=^|['\s()])ll-(?:boole-(?:1|2|and|andc1|andc2|c1|c2|clr|eqv|ior|nand|nor|orc1|orc2|set|xor))(?=$|[\s()])
297324
- name: support.function.list.call.autolisp
298-
match: (?i)(?<=^|['\s()])ll-(?:consp|endp|make-list|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|rest|nthcdr|firstn|butlast|butlastn|lst-cons|lastn|sublist|subseq|split(?:-if(?:-not)?|-at(?:-first|-last)?|-all)?|partition(?:-all)?|separate|list-length|revappend|copy-(?:list|tree)|count(?:-if(?:-not)?)?|maplist|maptree|some|every|foldr|foldl|reduce(?:-from-end|-with-init)?|member-if(?:-not)?|position(?:-if(?:-not)?)?|inlistp|mismatch|subst(?:-if(?:-not)?|-nth|-first|-last)|substree|sublis|flatten|insert|remove(?:-if(?:-not)?|-nth|-first|-last)?|remove(?:-adjacent)?-duplicates|tailp|ldiff)(?=$|[\s()])
325+
match: (?i)(?<=^|['\s()])ll-(?:consp|endp|make-list|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|rest|nthcdr|firstn|butlast|butlastn|last-cons|lastn|sublist|subseq|split(?:-if(?:-not)?|-at(?:-first|-last)?|-all)?|partition(?:-all)?|separate|list-length|revappend|copy-(?:list|tree)|count(?:-if(?:-not)?)?|maplist|maptree|some|every|foldr|foldl|reduce(?:-from-end|-with-init)?|member-if(?:-not)?|position(?:-if(?:-not)?)?|inlistp|mismatch|subst(?:-if(?:-not)?|-nth|-first|-last)|substree|sublis|flatten|insert|remove(?:-if(?:-not)?|-nth|-first|-last)?|remove(?:-adjacent)?-duplicates|tailp|ldiff)(?=$|[\s()])
299326
- name: support.function.listset.call.autolisp
300327
match: (?i)(?<=^|['\s()])ll-(?:subsetp|adjoin|union|intersection|set-difference|set-exclusive-or)(?=$|[\s()])
301328
- name: support.function.activex.call.autolisp

0 commit comments

Comments
 (0)