/usr/share/jed/lib/syntax.sl is in jed-common 1:0.99.19-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | % syntax.sl -*- SLang -*-
% The functions here are used to manipulate the syntax keyword tables
%
% Note: Eventually code here will need to be changed to use character semantics.
% The user should not have to worry about multibyte encodings.
%
private define add_hash_to_syntax_table (tbl, hash, len, n)
{
variable i;
hash = assoc_get_keys (hash);
i = array_sort (hash);
hash = strjoin (hash[i], "");
() = define_keywords_n (tbl, hash, len, n);
hash;
}
%!%+
%\function{add_keywords}
%\synopsis{add_keywords}
%\usage{String add_keywords (String tbl, String kws, Int len, Int n);}
%\description
%
% Adds a set of keywords `kws', each of length `len', to the already
% existing syntax table `tbl'. For convenience of the user, the function
% does alphabetical sorting and removes duplicate entries.
%
% The previous list of keywords is returned.
%\seealso{define_keywords_n, create_syntax_table, add_keyword_n}
%!%-
define add_keywords (tbl, kws, len, n)
{
variable okws, a, i, j, num, idx;
variable hash;
% add old keywords
kws += define_keywords_n (tbl, "", len, n);
num = strbytelen (kws) / len;
!if (num) return "";
hash = Assoc_Type[Int_Type];
_for (0, num-1, 1)
{
i = ();
hash [substrbytes (kws, 1 + i * len, len)] = 1;
}
add_hash_to_syntax_table (tbl, hash, len, n);
}
%!%+
%\function{add_keyword_n}
%\synopsis{add_keyword_n}
%\usage{Void add_keyword_n (String tbl, String kw, Int n);}
%\description
%
% Adds a single keyword `kw' to the already existing syntax table `tbl'.
%\seealso{define_keywords_n, create_syntax_table, add_keywords}
%!%-
define add_keyword_n (tbl, kw, n)
{
variable len = strbytelen (kw);
!if (len) return;
() = add_keywords (tbl, kw, len, n);
}
%!%+
%\function{add_keyword}
%\synopsis{add_keyword}
%\usage{Void add_keyword (String_Type tbl, String_Type kw);}
%\description
%
% Adds a single keyword `kw' to the already existing syntax table `tbl'.
%\seealso{define_keywords_n, create_syntax_table, add_keyword_n}
%!%-
define add_keyword ()
{
add_keyword_n (0);
}
%!%+
%\function{remove_keywords}
%\synopsis{remove_keywords}
%\usage{String remove_keywords (String tbl, String kws, Int len, Int n);}
%\description
% Removes a set of keywords `kws', each of length `len', from the already
% existing syntax table `tbl'.
%
% The previous list of keywords is returned.
%\seealso{add_keywords, define_keywords_n, create_syntax_table, add_keyword_n}
%!%-
define remove_keywords (tbl, kws, len, n)
{
variable okws, num, nrem, i, rm;
variable hash;
% the old keywords
okws = define_keywords_n (tbl, "", len, n);
num = strbytelen (okws) / len;
nrem = strbytelen (kws) / len;
!if (nrem)
{
() = define_keywords_n (tbl, okws, len, n);
return okws;
}
hash = Assoc_Type[Int_Type];
_for (0, num-1, 1)
{
i = ();
hash [substrbytes (okws, 1 + i * len, len)] = 1;
}
% remove unwanted entries
_for (0, nrem-1, 1)
{
i = ();
assoc_delete_key (hash, substrbytes (kws, 1 + i * len, len));
}
() = add_hash_to_syntax_table (tbl, hash, len, n);
okws;
}
|