|
| 1 | +%YAML 1.2 |
| 2 | +--- |
| 3 | +name: PostScript |
| 4 | +file_extensions: |
| 5 | + - ps |
| 6 | +scope: source.ps |
| 7 | +contexts: |
| 8 | + main: |
| 9 | + - include: expressions |
| 10 | + |
| 11 | + expressions: |
| 12 | + - include: comments |
| 13 | + - include: numbers |
| 14 | + - include: operators |
| 15 | + - include: dictionaries # include `dictionaries` before `strings` |
| 16 | + - include: strings |
| 17 | + - include: brackets |
| 18 | + - include: constants |
| 19 | + - include: variables # include `variables` last |
| 20 | + |
| 21 | + comments: |
| 22 | + - match: '%' |
| 23 | + scope: punctuation.definition.comment.ps |
| 24 | + push: |
| 25 | + - meta_scope: comment.line.ps |
| 26 | + - match: \n |
| 27 | + pop: true |
| 28 | + |
| 29 | + numbers: |
| 30 | + - match: |- |
| 31 | + (?x) |
| 32 | + (((3[0-6]|[1-2][0-9]|[2-9])\#[[:alnum:]]+)| # radix numbers |
| 33 | + ((((\+|-)?\d+\.?\d*)|((\+|-)?\.\d+))((e|E)(\+|-)?\d+)?))(?=[()<>\[\]{}/%\s]+) # signed integers & real numbers |
| 34 | + scope: constant.numeric.ps |
| 35 | +
|
| 36 | + string_escaped_char: |
| 37 | + - match: '\\([0-7]{1,3}|[nrtbf(\\)])' |
| 38 | + scope: constant.character.escape.c |
| 39 | + |
| 40 | + inside_string_literal: |
| 41 | + - match: \( |
| 42 | + push: |
| 43 | + - include: inside_string_literal |
| 44 | + - include: string_escaped_char |
| 45 | + - match: \) |
| 46 | + pop: true |
| 47 | + |
| 48 | + strings: |
| 49 | + - match: \( |
| 50 | + scope: punctuation.definition.string.begin.ps |
| 51 | + push: |
| 52 | + - meta_scope: string.literal.ps |
| 53 | + - match: \) |
| 54 | + scope: punctuation.definition.string.end.ps |
| 55 | + pop: true |
| 56 | + - include: inside_string_literal |
| 57 | + - include: string_escaped_char |
| 58 | + - match: '<~' |
| 59 | + scope: punctuation.definition.string.begin.ps |
| 60 | + push: |
| 61 | + - meta_scope: string.ascii.ps |
| 62 | + - match: '~>' |
| 63 | + scope: punctuation.definition.string.end.ps |
| 64 | + pop: true |
| 65 | + - match: '[^[:ascii:]]' |
| 66 | + scope: invalid.illegal.unexpected-character.ps |
| 67 | + - match: '<' |
| 68 | + scope: punctuation.definition.string.begin.ps |
| 69 | + push: |
| 70 | + - meta_scope: string.hexadecimal.ps |
| 71 | + - match: '>' |
| 72 | + scope: punctuation.definition.string.end.ps |
| 73 | + pop: true |
| 74 | + - match: '[^\h ]' |
| 75 | + scope: invalid.illegal.unexpected-character.ps |
| 76 | + |
| 77 | + variables: |
| 78 | + - match: //? |
| 79 | + scope: punctuation.definition.variable.ps |
| 80 | + push: |
| 81 | + - meta_scope: variable.other.readwrite.ps |
| 82 | + - match: '(?=\s)' |
| 83 | + pop: true |
| 84 | + - match: '[^()<>\[\]{}/%\s]+' |
| 85 | + scope: variable.other.readwrite.ps |
| 86 | + |
| 87 | + brackets: |
| 88 | + - match: \[ |
| 89 | + scope: punctuation.definition.brackets.begin.ps |
| 90 | + push: |
| 91 | + - meta_scope: meta.brackets.ps |
| 92 | + - match: \] |
| 93 | + scope: punctuation.definition.brackets.end.ps |
| 94 | + pop: true |
| 95 | + - include: expressions |
| 96 | + - match: \{ |
| 97 | + scope: punctuation.definition.brackets.begin.ps |
| 98 | + push: |
| 99 | + - meta_scope: meta.brackets.ps |
| 100 | + - match: \} |
| 101 | + scope: punctuation.definition.brackets.end.ps |
| 102 | + pop: true |
| 103 | + - include: expressions |
| 104 | + |
| 105 | + dictionaries: |
| 106 | + - match: '<<' |
| 107 | + scope: punctuation.definition.dictionary.begin.ps |
| 108 | + push: |
| 109 | + - meta_scope: meta.dictionary.ps |
| 110 | + - match: '>>' |
| 111 | + scope: punctuation.definition.dictionary.end.ps |
| 112 | + pop: true |
| 113 | + - include: expressions |
| 114 | + |
| 115 | + operators: |
| 116 | + - 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' |
| 117 | + scope: keyword.operator.arithmetic.ps |
| 118 | + - match: '\b(pop|exch|dup|index|roll|clear|count|mark|cleartomark|counttomark)\b' |
| 119 | + scope: keyword.operator.stack.ps |
| 120 | + - match: '\b(array|astore|aload|packedarray|setpacking|currentpacking)\b' |
| 121 | + scope: keyword.operator.array.ps |
| 122 | + - match: '\b(dict|maxlength|begin|end|def|load|store|undef|known|where|currentdict|countdictstack|dictstack|cleardictstack)\b' |
| 123 | + scope: keyword.operator.dictionary.ps |
| 124 | + - match: '\b(string|anchorsearch|search)\b' |
| 125 | + scope: keyword.operator.string.ps |
| 126 | + - match: '\b(eq|ne|ge|gt|le|lt)\b' |
| 127 | + scope: keyword.operator.comparison.ps |
| 128 | + - match: '\b(exec|if|ifelse|forall|for|repeat|loop|exit|stop|stopped|countexecstack|execstack|quit|start)\b' |
| 129 | + scope: keyword.operator.control.ps |
| 130 | + - match: '\b(type|cvlit|cvx|xcheck|executeonly|noaccess|readonly|rcheck|wcheck|cvi|cvn|cvr|cvrs|cvs)\b' |
| 131 | + scope: keyword.operator.type.ps |
| 132 | + - 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|\=\=|\=)' |
| 133 | + scope: keyword.operator.file.ps |
| 134 | + - match: '\b(defineresource|undefineresource|findresource|findcolorrendering|resourcestatus|resourceforall)\b' |
| 135 | + scope: keyword.operator.resource.ps |
| 136 | + - match: '\b(save|restore|setglobal|currentglobal|gcheck|startjob|defineuserobject|execuserobject|undefineuserobject|UserObjects)\b' |
| 137 | + scope: keyword.operator.virtual-memory.ps |
| 138 | + - 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' |
| 139 | + scope: keyword.operator.graphic-state.ps |
| 140 | + - match: '\b(concat|concatmatrix|currentmatrix|defaultmatrix|dtransform|identmatrix|idtransform|initmatrix|invertmatrix|itransform|matrix|rotate|scale|setmatrix|transform|translate)\b' |
| 141 | + scope: keyword.operator.matrix.ps |
| 142 | + - 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' |
| 143 | + scope: keyword.operator.path.ps |
| 144 | + - match: '\b(colorimage|eofill|erasepage|fill|image|imagemask|rectfill|rectstroke|shfill|stroke|ueofill|ufill|ustroke)\b' |
| 145 | + scope: keyword.operator.paint.ps |
| 146 | + - match: '\b(infill|ineofill|inufill|inueofill|instroke|inustroke)\b' |
| 147 | + scope: keyword.operator.insideness.ps |
| 148 | + - match: '\b(makepattern|setpattern|execform)\b' |
| 149 | + scope: keyword.operator.pattern.ps |
| 150 | + - match: '\b(showpage|copypage|setpagedevice|currentpagedevice|nulldevice)\b' |
| 151 | + scope: keyword.operator.device.ps |
| 152 | + - 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' |
| 153 | + scope: keyword.operator.font.ps |
| 154 | + - match: '\b(cachestatus|currentcacheparams|currentdevparams|currentsystemparams|currentuserparams|setcachelimit|setcacheparams|setdevparams|setsystemparams|setucacheparams|setuserparams|setvmthreshold|ucachestatus|vmreclaim|vmstatus|)\b' |
| 155 | + scope: keyword.operator.interpreter.ps |
| 156 | + - match: '\b(getinterval|putinterval|length|get|put|copy|bind|echo|version|realtime|usertime|languagelevel|product|revision|serialnumber|executive|prompt|token)\b' |
| 157 | + scope: keyword.operator.ps |
| 158 | + |
| 159 | + constants: |
| 160 | + - match: '\b(true|false|null)\b' |
| 161 | + scope: constant.language.ps |
| 162 | + - match: '\b(\$error|errordict|FontDirectory|globaldict|GlobalFontDirectory|statusdict|systemdict|userdict)\b' |
| 163 | + scope: constant.other.dictionary.ps |
0 commit comments