Package: enscript / 1.6.5.90-3

147116-ruby-hilight Patch series | download
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
Description: Ruby highlighting rules for enscript.
Author: Mike Wilson <wmwilson01@hotmail.com>
Bug-Debian: http://bugs.debian.org/147116

--- /dev/null
+++ b/states/hl/ruby.st
@@ -0,0 +1,205 @@
+/**
+ * Name: ruby
+ * Description: Ruby programming language.
+ * Author: Mike Wilson <wmwilson01@hotmail.com>
+ */
+
+state ruby_comment
+{
+  /\*\\\// {
+    language_print ($0);
+    return;
+  }
+  LANGUAGE_SPECIALS {
+   language_print ($0);
+  }
+}
+
+state ruby_dquot_string
+{
+  /\\\\./ {
+    language_print ($0);
+  }
+  /\"/ {
+    language_print ($0);
+    return;
+  }
+  LANGUAGE_SPECIALS {
+    language_print ($0);
+  }
+}
+
+state ruby_quot_string
+{
+  /\\\\./ {
+    language_print ($0);
+  }
+  /[\']/ {
+    language_print ($0);
+    return;
+  }
+  LANGUAGE_SPECIALS {
+    language_print ($0);
+  }
+}
+
+state ruby_bquot_string
+{
+  /\\\\./ {
+    language_print ($0);
+  }
+  /`/ {
+    language_print ($0);
+    return;
+  }
+  LANGUAGE_SPECIALS {
+    language_print ($0);
+  }
+}
+
+state ruby
+{
+  BEGIN {
+    header ();
+  }
+  END {
+    trailer ();
+  }
+
+  /* Comments. */
+  /#[^{].*$/ {
+    comment_face (true);
+    language_print ($0);
+    comment_face (false);
+  }
+
+  /* Ignore escaped quote marks */
+  /\\\"/ {
+    language_print ($0);
+  }
+  /\\\'/ {
+    language_print ($0);
+  }
+  /\\\`/ {
+    language_print ($0);
+  }
+
+  /* In cgi files, JavaScript might be imbedded, so we need to look out
+   * for the JavaScript comments, because they might contain something
+   * we don't like, like a contraction (don't, won't, etc.)
+   * We won't put them in comment face, because they are not ruby
+   * comments.
+   */
+  /\/\// {
+    language_print ($0);
+    call (eat_one_line);
+  }
+
+  /* String constants. */
+  /\"/ {
+    string_face (true);
+    language_print ($0);
+    call (ruby_dquot_string);
+    string_face (false);
+  }
+  /[\']/ {
+    string_face (true);
+    language_print ($0);
+    call (ruby_quot_string);
+    string_face (false);
+  }
+
+  /* Backquoted command string */
+  /`/ {
+    string_face (true);
+    language_print ($0);
+    call (ruby_bquot_string);
+    string_face (false);
+  }
+
+  /* Variables globals and instance */
+  /[$@]\w+/ {
+    variable_name_face (true);
+    language_print ($0);
+    variable_name_face (false);
+  }
+
+  /* Variables class variable */
+  /@@\w+/ {
+    variable_name_face (true);
+    language_print ($0);
+    variable_name_face (false);
+  }
+
+   /([ \t]*)(def)([ \t]+)([^(]*)/ {
+    /* indentation */
+    language_print ($1);
+
+    /* def */
+    keyword_face (true);
+    language_print ($2);
+    keyword_face (false);
+
+    /* middle */
+    language_print ($3);
+
+    /* Function name. */
+    function_name_face (true);
+    language_print ($4);
+    function_name_face (false);
+  }
+
+  /* Highlighting
+	--Type face
+ 	private protected public
+
+	--Builtin face (I consider these to be somewhat special)
+	alias alias_method attr attr_accessor attr_reader attr_writer
+	module_alias module_function self super
+
+	--Reference face
+	require include
+
+	--Keyword face
+	and begin break case class def defined? do else elsif end
+	ensure eval extend false for if in method module next nil not
+	or redo rescue retry return then true undef unless until when
+	while yield
+   */
+/\\b(private|protected|public)\\b/ {
+    type_face (true);
+    language_print ($0);
+    type_face (false);
+  }
+
+/\\b(alias|alias_method|attr|attr_(accessor|reader|writer)\\
+|module_(alias|function)|self|super)\\b/ {
+    builtin_face (true);
+    language_print ($0);
+    builtin_face (false);
+  }
+
+/\\b(include|require)\\b/ {
+    reference_face (true);
+    language_print ($0);
+    reference_face (false);
+  }
+
+/\\b(and|begin|break|case|class|def|defined?|do|else|elsif|end|ensure|eval\\
+|extend|false|for|if|in|method|module|next|nil|not|or|raise|redo|rescue|retry\\
+|return|then|true|undef|unless|until|when|while|yield)\\b/ {
+    keyword_face (true);
+    language_print ($0);
+    keyword_face (false);
+  }
+
+  LANGUAGE_SPECIALS {
+    language_print ($0);
+  }
+
+  /\$[!@&`'+~=\/\\,;.<>_*$?:"]/ {
+    variable_name_face (true);
+    language_print ($0);
+    variable_name_face (false);
+  }
+}
--- a/states/hl/Makefile.am
+++ b/states/hl/Makefile.am
@@ -37,7 +37,7 @@
 postscript.st python.st pyrex.st rfc.st scheme.st sh.st skill.st	\
 sql.st states.st synopsys.st tcl.st tcsh.st tex.st vba.st verilog.st	\
 vhdl.st vrml.st wmlscript.st zsh.st eiffel.st erlang.st dylan.st oz.st	\
-lua.st oberon2.st icon.st smalltalk.st forth.st sml.st
+lua.st oberon2.st icon.st smalltalk.st forth.st sml.st ruby.st
 
 hldir = $(pkgdatadir)/hl
 dist_hl_DATA = $(misc) $(styles) $(languages) $(highlightings)