-
Notifications
You must be signed in to change notification settings - Fork 2
/
PostScript.sublime-syntax
163 lines (152 loc) · 7.66 KB
/
PostScript.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
%YAML 1.2
---
name: PostScript
file_extensions:
- ps
scope: source.ps
contexts:
main:
- include: expressions
expressions:
- include: comments
- include: numbers
- include: operators
- include: dictionaries # include `dictionaries` before `strings`
- include: strings
- include: brackets
- include: constants
- include: variables # include `variables` last
comments:
- match: '%'
scope: punctuation.definition.comment.ps
push:
- meta_scope: comment.line.ps
- match: \n
pop: true
numbers:
- match: |-
(?x)
(((3[0-6]|[1-2][0-9]|[2-9])\#[[:alnum:]]+)| # radix numbers
((((\+|-)?\d+\.?\d*)|((\+|-)?\.\d+))((e|E)(\+|-)?\d+)?))(?=[()<>\[\]{}/%\s]+) # signed integers & real numbers
scope: constant.numeric.ps
string_escaped_char:
- match: '\\([0-7]{1,3}|[nrtbf(\\)])'
scope: constant.character.escape.c
inside_string_literal:
- match: \(
push:
- include: inside_string_literal
- include: string_escaped_char
- match: \)
pop: true
strings:
- match: \(
scope: punctuation.definition.string.begin.ps
push:
- meta_scope: string.literal.ps
- match: \)
scope: punctuation.definition.string.end.ps
pop: true
- include: inside_string_literal
- include: string_escaped_char
- match: '<~'
scope: punctuation.definition.string.begin.ps
push:
- meta_scope: string.ascii.ps
- match: '~>'
scope: punctuation.definition.string.end.ps
pop: true
- match: '[^[:ascii:]]'
scope: invalid.illegal.unexpected-character.ps
- match: '<'
scope: punctuation.definition.string.begin.ps
push:
- meta_scope: string.hexadecimal.ps
- match: '>'
scope: punctuation.definition.string.end.ps
pop: true
- match: '[^\h ]'
scope: invalid.illegal.unexpected-character.ps
variables:
- match: //?
scope: punctuation.definition.variable.ps
push:
- meta_scope: variable.other.readwrite.ps
- match: '(?=\s)'
pop: true
- match: '[^()<>\[\]{}/%\s]+'
scope: variable.other.readwrite.ps
brackets:
- match: \[
scope: punctuation.definition.brackets.begin.ps
push:
- meta_scope: meta.brackets.ps
- match: \]
scope: punctuation.definition.brackets.end.ps
pop: true
- include: expressions
- match: \{
scope: punctuation.definition.brackets.begin.ps
push:
- meta_scope: meta.brackets.ps
- match: \}
scope: punctuation.definition.brackets.end.ps
pop: true
- include: expressions
dictionaries:
- match: '<<'
scope: punctuation.definition.dictionary.begin.ps
push:
- meta_scope: meta.dictionary.ps
- match: '>>'
scope: punctuation.definition.dictionary.end.ps
pop: true
- include: expressions
operators:
- match: '\b(add|div|idiv|mod|mul|sub|abs|neg|ceiling|floor|round|truncate|sqrt|atan|cos|sin|exp|ln|log|rand|srand|rrand|and|not|or|xor|bitshift)\b'
scope: keyword.operator.arithmetic.ps
- match: '\b(pop|exch|dup|index|roll|clear|count|mark|cleartomark|counttomark)\b'
scope: keyword.operator.stack.ps
- match: '\b(array|astore|aload|packedarray|setpacking|currentpacking)\b'
scope: keyword.operator.array.ps
- match: '\b(dict|maxlength|begin|end|def|load|store|undef|known|where|currentdict|countdictstack|dictstack|cleardictstack)\b'
scope: keyword.operator.dictionary.ps
- match: '\b(string|anchorsearch|search)\b'
scope: keyword.operator.string.ps
- match: '\b(eq|ne|ge|gt|le|lt)\b'
scope: keyword.operator.comparison.ps
- match: '\b(exec|if|ifelse|forall|for|repeat|loop|exit|stop|stopped|countexecstack|execstack|quit|start)\b'
scope: keyword.operator.control.ps
- match: '\b(type|cvlit|cvx|xcheck|executeonly|noaccess|readonly|rcheck|wcheck|cvi|cvn|cvr|cvrs|cvs)\b'
scope: keyword.operator.type.ps
- match: '(\b(file|filter|closefile|read|write|readhexstring|writehexstring|readstring|writestring|readline|bytesavailable|flush|flushfile|resetfile|status|run|currentfile|deletefile|renamefile|filenameforall|setfileposition|fileposition|print|stack|pstack|printobject|writeobject|setobjectformat|currentobjectformat)\b|\=\=|\=)'
scope: keyword.operator.file.ps
- match: '\b(defineresource|undefineresource|findresource|findcolorrendering|resourcestatus|resourceforall)\b'
scope: keyword.operator.resource.ps
- match: '\b(save|restore|setglobal|currentglobal|gcheck|startjob|defineuserobject|execuserobject|undefineuserobject|UserObjects)\b'
scope: keyword.operator.virtual-memory.ps
- match: '\b(gsave|grestore|clipsave|cliprestore|grestoreall|initgraphics|gstate|setgstate|currentgstate|setlinewidth|currentlinewidth|setlinecap|currentlinecap|setlinejoin|currentlinejoin|setmiterlimit|currentmiterlimit|setstrokeadjust|currentstrokeadjust|setdash|currentdash|setcolorspace|currentcolorspace|setcolor|currentcolor|setgray|currentgray|sethsbcolor|currenthsbcolor|setrgbcolor|currentrgbcolor|setcmykcolor|currentcmykcolor|sethalftone|currenthalftone|setscreen|currentscreen|setcolorscreen|currentcolorscreen|settransfer|setcolortransfer|currentcolortransfer|currenttransfer|setblackgeneration|currentblackgeneration|setundercolorremoval|currentundercolorremoval|setcolorrendering|setflat|currentcolorrendering|setoverprint|currentflat|currentoverprint|setsmoothness|currentsmoothness)\b'
scope: keyword.operator.graphic-state.ps
- match: '\b(concat|concatmatrix|currentmatrix|defaultmatrix|dtransform|identmatrix|idtransform|initmatrix|invertmatrix|itransform|matrix|rotate|scale|setmatrix|transform|translate)\b'
scope: keyword.operator.matrix.ps
- match: '\b(arc|arcn|arct|arcto|charpath|clip|clippath|closepath|currentpoint|curveto|eoclip|flattenpath|initclip|lineto|moveto|newpath|pathbbox|pathforall|rcurveto|rectclip|reversepath|rlineto|rmoveto|setbbox|strokepath|uappend|ucache|upath|ustrokepath)\b'
scope: keyword.operator.path.ps
- match: '\b(colorimage|eofill|erasepage|fill|image|imagemask|rectfill|rectstroke|shfill|stroke|ueofill|ufill|ustroke)\b'
scope: keyword.operator.paint.ps
- match: '\b(infill|ineofill|inufill|inueofill|instroke|inustroke)\b'
scope: keyword.operator.insideness.ps
- match: '\b(makepattern|setpattern|execform)\b'
scope: keyword.operator.pattern.ps
- match: '\b(showpage|copypage|setpagedevice|currentpagedevice|nulldevice)\b'
scope: keyword.operator.device.ps
- match: '\b(ashow|awidthshow|composefont|cshow|currentfont|definefont|findencoding|findfont|glyphshow|ISOLatin1Encoding|kshow|makefont|rootfont|scalefont|selectfont|setcachedevice|setcachedevice2|setcharwidth|setfont|show|StandardEncoding|stringwidth|undefinefont|widthshow|xshow|xyshow|yshow)\b'
scope: keyword.operator.font.ps
- match: '\b(cachestatus|currentcacheparams|currentdevparams|currentsystemparams|currentuserparams|setcachelimit|setcacheparams|setdevparams|setsystemparams|setucacheparams|setuserparams|setvmthreshold|ucachestatus|vmreclaim|vmstatus|)\b'
scope: keyword.operator.interpreter.ps
- match: '\b(getinterval|putinterval|length|get|put|copy|bind|echo|version|realtime|usertime|languagelevel|product|revision|serialnumber|executive|prompt|token)\b'
scope: keyword.operator.ps
constants:
- match: '\b(true|false|null)\b'
scope: constant.language.ps
- match: '\b(\$error|errordict|FontDirectory|globaldict|GlobalFontDirectory|statusdict|systemdict|userdict)\b'
scope: constant.other.dictionary.ps