yay 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/data/yay/log4x.yay +2 -2
- data/data/yay/syslog.yay +9 -11
- data/lib/yay/parser.rb +5 -4
- data/lib/yay/parser_gen.rb +213 -187
- data/lib/yay/version.rb +1 -1
- metadata +14 -14
data/data/yay/log4x.yay
CHANGED
data/data/yay/syslog.yay
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
#!/usr/bin/yay
|
2
2
|
# Highlights syslog messages
|
3
3
|
|
4
|
-
debug
|
5
|
-
|
6
|
-
notice
|
7
|
-
|
8
|
-
|
4
|
+
debug, dbg are @boring
|
5
|
+
/info(rmational)?/i are @normal
|
6
|
+
notice, /warn(ing)?/i are @interesting
|
7
|
+
/err(or)?/i and alert are @serious
|
8
|
+
/crit(ical)?/i, /emerg(ency)?/i are @serious
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
err and alert
|
15
|
-
crit and emerg are red lines
|
10
|
+
@boring is dim
|
11
|
+
@normal is normal
|
12
|
+
@interesting is inverted yellow
|
13
|
+
@serious is inverted red
|
16
14
|
|
data/lib/yay/parser.rb
CHANGED
@@ -64,7 +64,7 @@ class Yay
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def handle_regex string
|
67
|
-
return string_to_regex string
|
67
|
+
return string_to_regex string, false
|
68
68
|
end
|
69
69
|
|
70
70
|
# for lack of a better function, this will take the ending sequence from
|
@@ -86,10 +86,11 @@ class Yay
|
|
86
86
|
|
87
87
|
# for lack of a better function, this will take a string like "/abc/" and
|
88
88
|
# transform it in to a regex object
|
89
|
-
def string_to_regex string
|
89
|
+
def string_to_regex string, escape=true
|
90
90
|
matches = /\/([^\/\\\r\n]*(?:\\.[^\/\\\r\n]*)*)\/([a-z]\b)*/.match string
|
91
91
|
return nil if matches[1].nil?
|
92
|
-
content =
|
92
|
+
content = matches[1]
|
93
|
+
content = Regexp::escape(content) if escape
|
93
94
|
options = extract_regexp_options matches[2]
|
94
95
|
return Regexp.new(content, options)
|
95
96
|
end
|
@@ -151,4 +152,4 @@ class Yay
|
|
151
152
|
raise Yay::UnexpectedTokenError.new type, error_value, current_position
|
152
153
|
end
|
153
154
|
end
|
154
|
-
end
|
155
|
+
end
|
data/lib/yay/parser_gen.rb
CHANGED
@@ -1,53 +1,18 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by
|
4
|
-
# from
|
3
|
+
# This file is automatically generated by Racc 1.4.7
|
4
|
+
# from Racc grammer file "".
|
5
5
|
#
|
6
6
|
|
7
|
-
require 'racc/parser'
|
8
|
-
|
7
|
+
require 'racc/parser.rb'
|
9
8
|
|
10
9
|
class Yay
|
11
|
-
|
12
10
|
class ParserGen < Racc::Parser
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
racc_reduce_table = [
|
17
|
-
0, 0, :racc_error,
|
18
|
-
1, 13, :_reduce_none,
|
19
|
-
1, 13, :_reduce_2,
|
20
|
-
2, 13, :_reduce_3,
|
21
|
-
1, 13, :_reduce_4,
|
22
|
-
0, 13, :_reduce_5,
|
23
|
-
3, 14, :_reduce_none,
|
24
|
-
1, 14, :_reduce_none,
|
25
|
-
1, 15, :_reduce_none,
|
26
|
-
1, 15, :_reduce_none,
|
27
|
-
1, 15, :_reduce_none,
|
28
|
-
1, 15, :_reduce_none,
|
29
|
-
1, 15, :_reduce_none,
|
30
|
-
4, 17, :_reduce_13,
|
31
|
-
3, 18, :_reduce_14,
|
32
|
-
4, 19, :_reduce_15,
|
33
|
-
3, 20, :_reduce_16,
|
34
|
-
2, 21, :_reduce_17,
|
35
|
-
3, 22, :_reduce_18,
|
36
|
-
1, 22, :_reduce_19,
|
37
|
-
1, 26, :_reduce_20,
|
38
|
-
1, 26, :_reduce_21,
|
39
|
-
2, 24, :_reduce_22,
|
40
|
-
1, 24, :_reduce_23,
|
41
|
-
1, 16, :_reduce_24,
|
42
|
-
0, 16, :_reduce_none,
|
43
|
-
1, 25, :_reduce_26,
|
44
|
-
0, 25, :_reduce_27,
|
45
|
-
2, 23, :_reduce_28,
|
46
|
-
0, 23, :_reduce_none ]
|
12
|
+
module_eval(<<'...end grammar.y/module_eval...', 'grammar.y', 54)
|
47
13
|
|
48
|
-
|
49
|
-
|
50
|
-
racc_shift_n = 40
|
14
|
+
...end grammar.y/module_eval...
|
15
|
+
##### State transition tables begin ###
|
51
16
|
|
52
17
|
racc_action_table = [
|
53
18
|
-7, -25, 32, 17, 25, 17, -25, 12, 22, 22,
|
@@ -91,231 +56,292 @@ racc_goto_default = [
|
|
91
56
|
nil, nil, nil, 7, nil, 11, 13, 14, 15, 16,
|
92
57
|
1, nil, nil, nil, 6 ]
|
93
58
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
:
|
98
|
-
:
|
99
|
-
:
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:
|
103
|
-
:
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
59
|
+
racc_reduce_table = [
|
60
|
+
0, 0, :racc_error,
|
61
|
+
1, 13, :_reduce_1,
|
62
|
+
1, 13, :_reduce_2,
|
63
|
+
2, 13, :_reduce_3,
|
64
|
+
1, 13, :_reduce_4,
|
65
|
+
0, 13, :_reduce_5,
|
66
|
+
3, 14, :_reduce_6,
|
67
|
+
1, 14, :_reduce_7,
|
68
|
+
1, 15, :_reduce_none,
|
69
|
+
1, 15, :_reduce_none,
|
70
|
+
1, 15, :_reduce_none,
|
71
|
+
1, 15, :_reduce_none,
|
72
|
+
1, 15, :_reduce_none,
|
73
|
+
4, 17, :_reduce_13,
|
74
|
+
3, 18, :_reduce_14,
|
75
|
+
4, 19, :_reduce_15,
|
76
|
+
3, 20, :_reduce_16,
|
77
|
+
2, 21, :_reduce_17,
|
78
|
+
3, 22, :_reduce_18,
|
79
|
+
1, 22, :_reduce_19,
|
80
|
+
1, 26, :_reduce_20,
|
81
|
+
1, 26, :_reduce_21,
|
82
|
+
2, 24, :_reduce_22,
|
83
|
+
1, 24, :_reduce_23,
|
84
|
+
1, 16, :_reduce_24,
|
85
|
+
0, 16, :_reduce_25,
|
86
|
+
1, 25, :_reduce_26,
|
87
|
+
0, 25, :_reduce_27,
|
88
|
+
2, 23, :_reduce_28,
|
89
|
+
0, 23, :_reduce_29 ]
|
107
90
|
|
108
|
-
|
91
|
+
racc_reduce_n = 30
|
92
|
+
|
93
|
+
racc_shift_n = 40
|
94
|
+
|
95
|
+
racc_token_table = {
|
96
|
+
false => 0,
|
97
|
+
:error => 1,
|
98
|
+
:literal => 2,
|
99
|
+
:install => 3,
|
100
|
+
:list_installed => 4,
|
101
|
+
:variable => 5,
|
102
|
+
:include => 6,
|
103
|
+
:regex => 7,
|
104
|
+
:colour => 8,
|
105
|
+
:and => 9,
|
106
|
+
:line => 10,
|
107
|
+
:verb => 11 }
|
109
108
|
|
110
109
|
racc_nt_base = 12
|
111
110
|
|
111
|
+
racc_use_result_var = true
|
112
|
+
|
112
113
|
Racc_arg = [
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
114
|
+
racc_action_table,
|
115
|
+
racc_action_check,
|
116
|
+
racc_action_default,
|
117
|
+
racc_action_pointer,
|
118
|
+
racc_goto_table,
|
119
|
+
racc_goto_check,
|
120
|
+
racc_goto_default,
|
121
|
+
racc_goto_pointer,
|
122
|
+
racc_nt_base,
|
123
|
+
racc_reduce_table,
|
124
|
+
racc_token_table,
|
125
|
+
racc_shift_n,
|
126
|
+
racc_reduce_n,
|
127
|
+
racc_use_result_var ]
|
127
128
|
|
128
129
|
Racc_token_to_s_table = [
|
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
|
-
|
130
|
+
"$end",
|
131
|
+
"error",
|
132
|
+
"literal",
|
133
|
+
"install",
|
134
|
+
"list_installed",
|
135
|
+
"variable",
|
136
|
+
"include",
|
137
|
+
"regex",
|
138
|
+
"colour",
|
139
|
+
"and",
|
140
|
+
"line",
|
141
|
+
"verb",
|
142
|
+
"$start",
|
143
|
+
"body",
|
144
|
+
"command_list",
|
145
|
+
"command",
|
146
|
+
"and_opt",
|
147
|
+
"match",
|
148
|
+
"assignment",
|
149
|
+
"substitution",
|
150
|
+
"equivalence",
|
151
|
+
"include_file",
|
152
|
+
"string_list",
|
153
|
+
"verbs_opt",
|
154
|
+
"colour_list",
|
155
|
+
"line_opt",
|
156
|
+
"string" ]
|
156
157
|
|
157
158
|
Racc_debug_parser = false
|
158
159
|
|
159
|
-
#####
|
160
|
+
##### State transition tables end #####
|
160
161
|
|
161
|
-
|
162
|
+
# reduce 0 omitted
|
162
163
|
|
163
|
-
|
164
|
+
module_eval(<<'.,.,', 'grammar.y', 5)
|
165
|
+
def _reduce_1(val, _values, result)
|
166
|
+
|
167
|
+
result
|
168
|
+
end
|
169
|
+
.,.,
|
164
170
|
|
165
|
-
module_eval
|
166
|
-
def _reduce_2(
|
167
|
-
|
168
|
-
|
171
|
+
module_eval(<<'.,.,', 'grammar.y', 6)
|
172
|
+
def _reduce_2(val, _values, result)
|
173
|
+
include_file val[0]
|
174
|
+
result
|
169
175
|
end
|
170
176
|
.,.,
|
171
177
|
|
172
|
-
module_eval
|
173
|
-
def _reduce_3(
|
174
|
-
|
175
|
-
|
178
|
+
module_eval(<<'.,.,', 'grammar.y', 7)
|
179
|
+
def _reduce_3(val, _values, result)
|
180
|
+
install_file val[1]
|
181
|
+
result
|
176
182
|
end
|
177
183
|
.,.,
|
178
184
|
|
179
|
-
module_eval
|
180
|
-
def _reduce_4(
|
181
|
-
|
182
|
-
|
185
|
+
module_eval(<<'.,.,', 'grammar.y', 8)
|
186
|
+
def _reduce_4(val, _values, result)
|
187
|
+
list_installed
|
188
|
+
result
|
183
189
|
end
|
184
190
|
.,.,
|
185
191
|
|
186
|
-
module_eval
|
187
|
-
def _reduce_5(
|
188
|
-
|
189
|
-
|
192
|
+
module_eval(<<'.,.,', 'grammar.y', 9)
|
193
|
+
def _reduce_5(val, _values, result)
|
194
|
+
use_default_file
|
195
|
+
result
|
190
196
|
end
|
191
197
|
.,.,
|
192
198
|
|
193
|
-
|
199
|
+
module_eval(<<'.,.,', 'grammar.y', 11)
|
200
|
+
def _reduce_6(val, _values, result)
|
201
|
+
|
202
|
+
result
|
203
|
+
end
|
204
|
+
.,.,
|
194
205
|
|
195
|
-
|
206
|
+
module_eval(<<'.,.,', 'grammar.y', 12)
|
207
|
+
def _reduce_7(val, _values, result)
|
208
|
+
|
209
|
+
result
|
210
|
+
end
|
211
|
+
.,.,
|
196
212
|
|
197
|
-
|
213
|
+
# reduce 8 omitted
|
198
214
|
|
199
|
-
|
215
|
+
# reduce 9 omitted
|
200
216
|
|
201
|
-
|
217
|
+
# reduce 10 omitted
|
202
218
|
|
203
|
-
|
219
|
+
# reduce 11 omitted
|
204
220
|
|
205
|
-
|
221
|
+
# reduce 12 omitted
|
206
222
|
|
207
|
-
module_eval
|
208
|
-
def _reduce_13(
|
209
|
-
|
210
|
-
|
223
|
+
module_eval(<<'.,.,', 'grammar.y', 20)
|
224
|
+
def _reduce_13(val, _values, result)
|
225
|
+
@ruleset.add_match val[0], handle_colours(val[2]), val[3]
|
226
|
+
result
|
211
227
|
end
|
212
228
|
.,.,
|
213
229
|
|
214
|
-
module_eval
|
215
|
-
def _reduce_14(
|
216
|
-
|
217
|
-
|
230
|
+
module_eval(<<'.,.,', 'grammar.y', 22)
|
231
|
+
def _reduce_14(val, _values, result)
|
232
|
+
@ruleset.add_assignment val[0], val[2]
|
233
|
+
result
|
218
234
|
end
|
219
235
|
.,.,
|
220
236
|
|
221
|
-
module_eval
|
222
|
-
def _reduce_15(
|
223
|
-
|
224
|
-
|
237
|
+
module_eval(<<'.,.,', 'grammar.y', 24)
|
238
|
+
def _reduce_15(val, _values, result)
|
239
|
+
@ruleset.add_substitution val[0], handle_colours(val[2]), val[3]
|
240
|
+
result
|
225
241
|
end
|
226
242
|
.,.,
|
227
243
|
|
228
|
-
module_eval
|
229
|
-
def _reduce_16(
|
230
|
-
|
231
|
-
|
244
|
+
module_eval(<<'.,.,', 'grammar.y', 26)
|
245
|
+
def _reduce_16(val, _values, result)
|
246
|
+
@ruleset.add_equivalence val[0], val[2]
|
247
|
+
result
|
232
248
|
end
|
233
249
|
.,.,
|
234
250
|
|
235
|
-
module_eval
|
236
|
-
def _reduce_17(
|
237
|
-
|
238
|
-
|
251
|
+
module_eval(<<'.,.,', 'grammar.y', 28)
|
252
|
+
def _reduce_17(val, _values, result)
|
253
|
+
include_file val[1]
|
254
|
+
result
|
239
255
|
end
|
240
256
|
.,.,
|
241
257
|
|
242
|
-
module_eval
|
243
|
-
def _reduce_18(
|
244
|
-
|
245
|
-
|
258
|
+
module_eval(<<'.,.,', 'grammar.y', 30)
|
259
|
+
def _reduce_18(val, _values, result)
|
260
|
+
val[2].unshift(val[0]); result = val[2]
|
261
|
+
result
|
246
262
|
end
|
247
263
|
.,.,
|
248
264
|
|
249
|
-
module_eval
|
250
|
-
def _reduce_19(
|
251
|
-
|
252
|
-
|
265
|
+
module_eval(<<'.,.,', 'grammar.y', 31)
|
266
|
+
def _reduce_19(val, _values, result)
|
267
|
+
result = [val[0]]
|
268
|
+
result
|
253
269
|
end
|
254
270
|
.,.,
|
255
271
|
|
256
|
-
module_eval
|
257
|
-
def _reduce_20(
|
258
|
-
|
259
|
-
|
272
|
+
module_eval(<<'.,.,', 'grammar.y', 33)
|
273
|
+
def _reduce_20(val, _values, result)
|
274
|
+
result = handle_string(val[0])
|
275
|
+
result
|
260
276
|
end
|
261
277
|
.,.,
|
262
278
|
|
263
|
-
module_eval
|
264
|
-
def _reduce_21(
|
265
|
-
|
266
|
-
|
279
|
+
module_eval(<<'.,.,', 'grammar.y', 34)
|
280
|
+
def _reduce_21(val, _values, result)
|
281
|
+
result = handle_regex(val[0])
|
282
|
+
result
|
267
283
|
end
|
268
284
|
.,.,
|
269
285
|
|
270
|
-
module_eval
|
271
|
-
def _reduce_22(
|
272
|
-
|
273
|
-
|
286
|
+
module_eval(<<'.,.,', 'grammar.y', 36)
|
287
|
+
def _reduce_22(val, _values, result)
|
288
|
+
val[1].unshift(val[0].to_sym); result = val[1]
|
289
|
+
result
|
274
290
|
end
|
275
291
|
.,.,
|
276
292
|
|
277
|
-
module_eval
|
278
|
-
def _reduce_23(
|
279
|
-
|
280
|
-
|
293
|
+
module_eval(<<'.,.,', 'grammar.y', 37)
|
294
|
+
def _reduce_23(val, _values, result)
|
295
|
+
result = [val[0].to_sym]
|
296
|
+
result
|
281
297
|
end
|
282
298
|
.,.,
|
283
299
|
|
284
|
-
module_eval
|
285
|
-
def _reduce_24(
|
286
|
-
|
287
|
-
|
300
|
+
module_eval(<<'.,.,', 'grammar.y', 39)
|
301
|
+
def _reduce_24(val, _values, result)
|
302
|
+
result = nil
|
303
|
+
result
|
288
304
|
end
|
289
305
|
.,.,
|
290
306
|
|
291
|
-
|
307
|
+
module_eval(<<'.,.,', 'grammar.y', 40)
|
308
|
+
def _reduce_25(val, _values, result)
|
309
|
+
|
310
|
+
result
|
311
|
+
end
|
312
|
+
.,.,
|
292
313
|
|
293
|
-
module_eval
|
294
|
-
def _reduce_26(
|
295
|
-
|
296
|
-
|
314
|
+
module_eval(<<'.,.,', 'grammar.y', 42)
|
315
|
+
def _reduce_26(val, _values, result)
|
316
|
+
result = true
|
317
|
+
result
|
297
318
|
end
|
298
319
|
.,.,
|
299
320
|
|
300
|
-
module_eval
|
301
|
-
def _reduce_27(
|
302
|
-
|
303
|
-
|
321
|
+
module_eval(<<'.,.,', 'grammar.y', 43)
|
322
|
+
def _reduce_27(val, _values, result)
|
323
|
+
result = false
|
324
|
+
result
|
304
325
|
end
|
305
326
|
.,.,
|
306
327
|
|
307
|
-
module_eval
|
308
|
-
def _reduce_28(
|
309
|
-
|
310
|
-
|
328
|
+
module_eval(<<'.,.,', 'grammar.y', 45)
|
329
|
+
def _reduce_28(val, _values, result)
|
330
|
+
result = nil
|
331
|
+
result
|
311
332
|
end
|
312
333
|
.,.,
|
313
334
|
|
314
|
-
|
335
|
+
module_eval(<<'.,.,', 'grammar.y', 46)
|
336
|
+
def _reduce_29(val, _values, result)
|
337
|
+
|
338
|
+
result
|
339
|
+
end
|
340
|
+
.,.,
|
315
341
|
|
316
|
-
|
317
|
-
|
318
|
-
|
342
|
+
def _reduce_none(val, _values, result)
|
343
|
+
val[0]
|
344
|
+
end
|
319
345
|
|
320
346
|
end # class ParserGen
|
321
347
|
|
data/lib/yay/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- jon davey
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-18 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -30,21 +30,21 @@ extra_rdoc_files: []
|
|
30
30
|
files:
|
31
31
|
- LICENSE
|
32
32
|
- data/yay/default.yay
|
33
|
-
- data/yay/log4x.yay
|
34
33
|
- data/yay/syslog.yay
|
35
|
-
-
|
36
|
-
- lib/yay/
|
37
|
-
- lib/yay/
|
34
|
+
- data/yay/log4x.yay
|
35
|
+
- lib/yay/lexer.rb
|
36
|
+
- lib/yay/parser.rb
|
38
37
|
- lib/yay/parser_gen.rb
|
39
|
-
- lib/yay/lexer_regex.rb
|
40
38
|
- lib/yay/errors.rb
|
41
|
-
- lib/yay/parser.rb
|
42
|
-
- lib/yay/loader.rb
|
43
|
-
- lib/yay/paths.rb
|
44
39
|
- lib/yay/colour_wheel.rb
|
45
|
-
- lib/yay/
|
40
|
+
- lib/yay/lexer_regex.rb
|
41
|
+
- lib/yay/paths.rb
|
42
|
+
- lib/yay/version.rb
|
43
|
+
- lib/yay/application.rb
|
44
|
+
- lib/yay/loader.rb
|
46
45
|
- lib/yay/rule_set.rb
|
47
|
-
- lib/yay/
|
46
|
+
- lib/yay/colourizer.rb
|
47
|
+
- lib/yay/installer.rb
|
48
48
|
- bin/yay
|
49
49
|
has_rdoc: true
|
50
50
|
homepage: http://github.com/jond3k/yay
|