File: pscript.sl

package info (click to toggle)
jed 0.98.7-14
  • links: PTS
  • area: main
  • in suites: slink
  • size: 3,088 kB
  • ctags: 3,851
  • sloc: ansic: 29,315; makefile: 257; sh: 248
file content (90 lines) | stat: -rw-r--r-- 3,939 bytes parent folder | download | duplicates (6)
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
% This is a simple PostScript mode. It just implements a highlighting
% scheme.

% Note that PostScript considers any set of matched parentheses to be a
% valid string. This cannot easily be matched by DFA-based methods, so
% the highlighting scheme here simply deals with *one* set of inner
% parentheses. Hence (asd(df)df) is a valid string under these rules,
% but (sdf(df(sdf)sdf)sdf) contains more nested parentheses than we can
% cope with here.

$1 = "PostScript";

create_syntax_table ($1);

#ifdef HAS_DFA_SYNTAX
enable_highlight_cache ("pscript.dfa", $1);
define_highlight_rule("%.*$", "comment", $1);
define_highlight_rule("[\\-\\+]?[0-9]*\\.?[0-9]+([Ee][\\-\\+]?[0-9]*)?",
		      "number", $1);
define_highlight_rule("[0-9]+#[0-9A-Za-z]*", "number", $1);
define_highlight_rule(strcat("\\((\\\\.|[^\\(\\)\\\\]|",
			     "\\(([^\\\\\\(\\)]|\\\\.)*\\))*\\)"),
		      "string", $1);
define_highlight_rule(strcat("\\((\\\\.|[^\\(\\)\\\\]|\\(([^\\\\\\(\\)]|\\\\",
			     ".)*\\))*(\\(([^\\\\\\(\\)]|\\\\.)*)?\\\\?$"),
		      "string", $1);
define_highlight_rule(strcat("^(([^\\\\\\(\\)]|\\\\.)*\\))?(\\\\.|[^\\(\\)",
			     "\\\\]|\\(([^\\\\\\(\\)]|\\\\.)*\\))*\\)"),
		      "string", $1);
define_highlight_rule("<[ \t0-9a-fA-F]*>", "string", $1);
define_highlight_rule("<[ \t0-9a-fA-F]*$", "string", $1);
define_highlight_rule("^[ \t0-9a-fA-F]*>", "Qstring", $1);
define_highlight_rule("<~[ \t!-u]*~>", "string", $1);
define_highlight_rule("<~[ \t!-u]*~?$", "string", $1);
define_highlight_rule("^[ \t!-u]*~>", "Qstring", $1);
define_highlight_rule("[!-\\$&'\\*-\\.0-;=\\?-Z\\\\\\^-z\\|~]+",
		      "Knormal", $1);
define_highlight_rule("//?[!-\\$&'\\*-\\.0-;=\\?-Z\\\\\\^-z\\|~]+",
		      "normal", $1);
define_highlight_rule("<<|>>|\\[|\\]|{|}", "Qdelimiter", $1);
define_highlight_rule(".", "normal", $1);
build_highlight_table ($1);
#endif

% All words in PostScript are of course redefinable. So we will simply
% define as keywords the *really* basic ones. These are basic language
% operators.
define_keywords ($1, "=", 1);
define_keywords ($1, "==eqgegtiflelnltneor", 2);
define_keywords ($1, strcat("absaddandcoscvicvncvrcvscvxdefdivdupendexpfor",
			    "getlogmodmulnegnotpopputrunsinsrtsubxor"), 3);
define_keywords ($1, strcat("atancopycopycvrsdictexchexecexitfileidivload",
			    "loopmarkquitrandreadrollsavestoptruetype"), 4);
define_keywords ($1, strcat("aloadarraybeginclearcountcvlitfalsefloorindex",
			    "knownroundrrandsrandstackstoreundefwherewrite"),
		 5);
define_keywords ($1, "astoreforallgstateifelselengthpstackrepeatstring", 6);
define_keywords ($1, "ceilingrestore", 7);
define_keywords ($1, "truncate", 8);
define_keywords ($1, strcat("counttomarkcurrentfilegetintervalpackedarray",
			    "putinterval"), 11);

% And these are basic graphical operators.
define_keywords_n ($1, "arc", 3, 1);
define_keywords_n ($1, "arcnarctclipfillshow", 4, 1);
define_keywords_n ($1, "arctogsaveimagescale", 5, 1);
define_keywords_n ($1, "concateoclipeofilllinetomatrixmovetorotatestroke",
		   6, 1);
define_keywords_n ($1, "curvetonewpathrlinetormovetosetdashsetfontsetgray",
		   7, 1);
define_keywords_n ($1, "findfontgrestoremakefontrcurvetosetcolorshowpage",
		   8, 1);
define_keywords_n ($1, "closepathscalefontsetmatrixtransformtranslate", 9, 1);
define_keywords_n ($1, "definefontsetlinecapsetpattern", 10, 1);
define_keywords_n ($1, strcat("currentdashcurrentfontcurrentgraysethsbcolor",
			    "setlinejoinsetrgbcolor"), 11, 1);
define_keywords_n ($1, "currentcolorsetcmykcolorsetlinewidth", 12, 1);
define_keywords_n ($1, "currentmatrix", 13, 1);
define_keywords_n ($1, "currentlinecapcurrentpattern", 14, 1);
define_keywords_n ($1, "currenthsbcolorcurrentlinejoincurrentrgbcolor",
		   15, 1);
define_keywords_n ($1, "currentcmykcolorcurrentlinewidth", 16, 1);

define ps_mode ()
{
   variable ps = "PostScript";
   set_mode(ps, 0);
   use_syntax_table (ps);
   runhooks("ps_mode_hook");
}