rlsm 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.txt → README} +10 -23
- data/Rakefile +79 -7
- data/ext/array/array_c_ext.c +137 -0
- data/ext/array/extconf.rb +2 -0
- data/ext/binop/binop_c_ext.c +57 -0
- data/ext/binop/extconf.rb +2 -0
- data/ext/monoid/extconf.rb +2 -0
- data/ext/monoid/monoid_c_ext.c +330 -0
- data/lib/rlsm.rb +10 -14
- data/lib/rlsm/binary_operation.rb +151 -0
- data/lib/rlsm/dfa.rb +418 -602
- data/lib/rlsm/helper.rb +12 -0
- data/lib/rlsm/monoid.rb +454 -694
- data/lib/rlsm/regexp.rb +125 -0
- data/lib/rlsm/regexp_parser.rb +450 -0
- data/test/helpers.rb +66 -0
- data/test/test_binop.rb +119 -0
- data/test/test_dfa.rb +435 -0
- data/test/test_monoid.rb +552 -0
- data/test/test_regexp.rb +440 -0
- metadata +109 -37
- data/History.txt +0 -6
- data/Manifest.txt +0 -18
- data/bin/smon +0 -39
- data/data/monoids.db +0 -0
- data/lib/database.rb +0 -95
- data/lib/monkey_patching/array_ext.rb +0 -50
- data/lib/rlsm/re.rb +0 -504
- data/lib/smon/base.rb +0 -284
- data/lib/smon/db.rb +0 -98
- data/lib/smon/dot.rb +0 -65
- data/lib/smon/latex.rb +0 -313
- data/lib/smon/smon.rb +0 -183
- data/stdarb.tex +0 -118
data/test/test_regexp.rb
ADDED
@@ -0,0 +1,440 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helpers')
|
2
|
+
|
3
|
+
require "rlsm/regexp"
|
4
|
+
|
5
|
+
context "Parsing of a regexp:" do
|
6
|
+
before :each do
|
7
|
+
@a = RLSM::RE::Prim[ 'a' ]
|
8
|
+
@b = RLSM::RE::Prim[ 'b' ]
|
9
|
+
@c = RLSM::RE::Prim[ 'c' ]
|
10
|
+
@d = RLSM::RE::Prim[ 'd' ]
|
11
|
+
|
12
|
+
@aab = [@a, @a, @b]
|
13
|
+
end
|
14
|
+
|
15
|
+
test "RegExp::new : Should require an argument." do
|
16
|
+
assert_raises ArgumentError do
|
17
|
+
RLSM::RegExp.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
test "RegExp::new : Should check that parentheses are balanced." do
|
22
|
+
assert_raises RegExpError do
|
23
|
+
RLSM::RegExp.new "(ab(cUd)"
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_raises RegExpError do
|
27
|
+
RLSM::RegExp.new "ab)((cUd)"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
test "RegExp::new : Should parse empty string." do
|
32
|
+
re = RLSM::RegExp.new ""
|
33
|
+
|
34
|
+
assert_equal( RLSM::RE::EmptySet[], re.parse_tree )
|
35
|
+
end
|
36
|
+
|
37
|
+
test "RegExp::new : Should parse string with only parenthesis." do
|
38
|
+
re = RLSM::RegExp.new "()(())"
|
39
|
+
|
40
|
+
assert_equal( RLSM::RE::EmptySet[], re.parse_tree )
|
41
|
+
end
|
42
|
+
|
43
|
+
test "RegExp::new : Should parse string with only parenthesis and stars." do
|
44
|
+
re = RLSM::RegExp.new "()*((*))"
|
45
|
+
|
46
|
+
assert_equal( RLSM::RE::EmptySet[], re.parse_tree )
|
47
|
+
end
|
48
|
+
|
49
|
+
test "RegExp::new : Should parse empty word." do
|
50
|
+
re = RLSM::RegExp.new "@"
|
51
|
+
|
52
|
+
assert_equal( RLSM::RE::EmptyWord[], re.parse_tree )
|
53
|
+
end
|
54
|
+
|
55
|
+
test "RegExp::new : Should parse a single character." do
|
56
|
+
re = RLSM::RegExp.new "a"
|
57
|
+
|
58
|
+
assert_equal( RLSM::RE::Prim['a'], re.parse_tree )
|
59
|
+
end
|
60
|
+
|
61
|
+
test "RegExp::new : Should parse multiple characters." do
|
62
|
+
re = RLSM::RegExp.new "aab"
|
63
|
+
|
64
|
+
assert_equal( RLSM::RE::Concat[ @aab ], re.parse_tree )
|
65
|
+
end
|
66
|
+
|
67
|
+
test "RegExp::new : Should ignore surrounding parenthesis." do
|
68
|
+
re = RLSM::RegExp.new "(((aab)))"
|
69
|
+
|
70
|
+
assert_equal( RLSM::RE::Concat[ @aab ],
|
71
|
+
re.parse_tree )
|
72
|
+
end
|
73
|
+
|
74
|
+
test "RegExp::new : Should parse a trivial regexp with a kleene star." do
|
75
|
+
re = RLSM::RegExp.new "a*"
|
76
|
+
expected =
|
77
|
+
|
78
|
+
assert_equal( RLSM::RE::Star[ RLSM::RE::Prim['a'] ], re.parse_tree )
|
79
|
+
end
|
80
|
+
|
81
|
+
test "RegExp::new : Should parse a simple regexp with a kleene star." do
|
82
|
+
re = RLSM::RegExp.new "(aab)*"
|
83
|
+
|
84
|
+
assert_equal( RLSM::RE::Star[ RLSM::RE::Concat[ @aab ] ], re.parse_tree )
|
85
|
+
end
|
86
|
+
|
87
|
+
test "RegExp::new : Should simplify multiple stars." do
|
88
|
+
re = RLSM::RegExp.new "a***"
|
89
|
+
|
90
|
+
assert_equal( RLSM::RE::Star[ RLSM::RE::Prim['a'] ],
|
91
|
+
re.parse_tree )
|
92
|
+
end
|
93
|
+
|
94
|
+
test "RegExp::new : Should simplify multiple empty words." do
|
95
|
+
re = RLSM::RegExp.new "@@@"
|
96
|
+
|
97
|
+
assert_equal( RLSM::RE::EmptyWord[],
|
98
|
+
re.parse_tree )
|
99
|
+
end
|
100
|
+
|
101
|
+
test "RegExp::new : Should simplify stars after empty words." do
|
102
|
+
re = RLSM::RegExp.new "@*"
|
103
|
+
|
104
|
+
assert_equal( RLSM::RE::EmptyWord.new,
|
105
|
+
re.parse_tree )
|
106
|
+
end
|
107
|
+
|
108
|
+
test "RegExp::new : Should simplify empty words in a simple expression." do
|
109
|
+
re = RLSM::RegExp.new "@aa@b@"
|
110
|
+
|
111
|
+
assert_equal( RLSM::RE::Concat[ @aab ],
|
112
|
+
re.parse_tree )
|
113
|
+
end
|
114
|
+
|
115
|
+
test "RegExp::new : Should parse a simple union." do
|
116
|
+
re = RLSM::RegExp.new "aab|b|ac"
|
117
|
+
expected = RLSM::RE::Union[ [RLSM::RE::Concat[ @aab ],
|
118
|
+
RLSM::RE::Concat[ [@a,@c] ],
|
119
|
+
@b] ]
|
120
|
+
|
121
|
+
assert_equal( expected, re.parse_tree )
|
122
|
+
end
|
123
|
+
|
124
|
+
test "RegExp::new : Should ignore obviously unnedded parenthesis." do
|
125
|
+
re = RLSM::RegExp.new "(@)aa(b)"
|
126
|
+
|
127
|
+
assert_equal( RLSM::RE::Concat[ @aab ],
|
128
|
+
re.parse_tree )
|
129
|
+
end
|
130
|
+
|
131
|
+
test "RegExp::new : Should parse a concatenation with a kleene star." do
|
132
|
+
re = RLSM::RegExp.new "aba*"
|
133
|
+
expected = RLSM::RE::Concat[ [@a, @b, RLSM::RE::Star[ @a ]] ]
|
134
|
+
assert_equal( expected, re.parse_tree )
|
135
|
+
end
|
136
|
+
|
137
|
+
test "RegExp::new : Should parse a union in a star expression." do
|
138
|
+
re = RLSM::RegExp.new "(a|b)*"
|
139
|
+
expected = RLSM::RE::Star[ RLSM::RE::Union[ [@a, @b] ] ]
|
140
|
+
assert_equal( expected, re.parse_tree )
|
141
|
+
end
|
142
|
+
|
143
|
+
test "RegExp::new : Should parse a union in a concat expression." do
|
144
|
+
re = RLSM::RegExp.new "ab(a|b)b"
|
145
|
+
expected = RLSM::RE::Concat[ [@a, @b, RLSM::RE::Union[ [@a,@b] ], @b] ]
|
146
|
+
|
147
|
+
assert_equal( expected, re.parse_tree )
|
148
|
+
end
|
149
|
+
|
150
|
+
test "RegExp::new : Should parse a complexer union." do
|
151
|
+
re = RLSM::RegExp.new "a*|aab|ba(aab)*bb"
|
152
|
+
concat = RLSM::RE::Concat[ [@b,@a, RLSM::RE::Star[ RLSM::RE::Concat[@aab] ], @b, @b] ]
|
153
|
+
expected = RLSM::RE::Union[ [RLSM::RE::Star[@a], RLSM::RE::Concat[@aab], concat] ]
|
154
|
+
|
155
|
+
assert_equal expected, re.parse_tree
|
156
|
+
end
|
157
|
+
|
158
|
+
test "RegExp::new : Should parse a nested union." do
|
159
|
+
re = RLSM::RegExp.new "a(a|b)|a*"
|
160
|
+
expected =
|
161
|
+
RLSM::RE::Union[ [RLSM::RE::Concat[[@a, RLSM::RE::Union[[@a,@b]]]], RLSM::RE::Star[@a]] ]
|
162
|
+
|
163
|
+
assert_equal expected, re.parse_tree
|
164
|
+
end
|
165
|
+
|
166
|
+
test "RegExp::new : Should treat empty parenthesis as empty set." do
|
167
|
+
re1 = RLSM::RegExp.new "()*"
|
168
|
+
re2 = RLSM::RegExp.new "ab()"
|
169
|
+
|
170
|
+
assert_equal RLSM::RE::EmptySet[], re1.parse_tree
|
171
|
+
assert_equal RLSM::RE::EmptySet[], re2.parse_tree
|
172
|
+
end
|
173
|
+
|
174
|
+
test "RegExp::new : Should ignore union with an empty set." do
|
175
|
+
re = RLSM::RegExp.new "a||b"
|
176
|
+
|
177
|
+
expected = RLSM::RE::Union[ [ RLSM::RE::Prim[ 'a' ], RLSM::RE::Prim[ 'b' ] ] ]
|
178
|
+
|
179
|
+
assert_equal expected, re.parse_tree
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context "Properties of a SyntaxNode:" do
|
184
|
+
test "SyntaxNode#null? : Should return true for EmptySet." do
|
185
|
+
assert RLSM::RE::EmptySet[].null?
|
186
|
+
end
|
187
|
+
|
188
|
+
test "SyntaxNode#null? : Should return true for EmptyWord." do
|
189
|
+
assert RLSM::RE::EmptyWord[].null?
|
190
|
+
end
|
191
|
+
|
192
|
+
test "SyntaxNode#null? : Should return false for Prim." do
|
193
|
+
refute RLSM::RE::Prim[ 'a' ].null?
|
194
|
+
end
|
195
|
+
|
196
|
+
test "SyntaxNode#null? : Should return true for a Star." do
|
197
|
+
assert RLSM::RE::Star[ RLSM::RE::Prim[ 'a' ] ].null?
|
198
|
+
end
|
199
|
+
|
200
|
+
test "SyntaxNode#null? : Should return true for a union with at least one nullable entry." do
|
201
|
+
parse_tree = RLSM::RE::Union[ [RLSM::RE::Prim[ 'a' ], RLSM::RE::EmptyWord[]] ]
|
202
|
+
assert parse_tree.null?
|
203
|
+
end
|
204
|
+
|
205
|
+
test "SyntaxNode#null? : Should return false for a union with no nullable entries." do
|
206
|
+
parse_tree = RLSM::RE::Union[ [RLSM::RE::Prim[ 'a' ], RLSM::RE::Prim[ 'b' ]] ]
|
207
|
+
refute parse_tree.null?
|
208
|
+
end
|
209
|
+
|
210
|
+
test "SyntaxNode#null? : Should return false for a concat with at least one non null entry." do
|
211
|
+
parse_tree = RLSM::RE::Concat[ [RLSM::RE::Star[ RLSM::RE::Prim[ 'a' ] ], RLSM::RE::Prim[ 'b' ]] ]
|
212
|
+
refute parse_tree.null?
|
213
|
+
end
|
214
|
+
|
215
|
+
test "SyntaxNode#null? : Should return true for a concat with only nullable entries." do
|
216
|
+
parse_tree = RLSM::RE::Concat[ [RLSM::RE::Star[RLSM::RE::Prim[ 'a' ]],RLSM::RE::Star[RLSM::RE::Prim[ 'b' ]]] ]
|
217
|
+
assert parse_tree.null?
|
218
|
+
end
|
219
|
+
|
220
|
+
test "SyntaxNode#first : Should return empty Array for EmptySet." do
|
221
|
+
assert_equal [], RLSM::RE::EmptySet[].first
|
222
|
+
end
|
223
|
+
|
224
|
+
test "SyntaxNode#first : Should return empty Array for EmptyWord." do
|
225
|
+
assert_equal [], RLSM::RE::EmptyWord[].first
|
226
|
+
end
|
227
|
+
|
228
|
+
test "SyntaxNode#first : Should return first character of a Prim in an Array." do
|
229
|
+
assert_equal ['a'], RLSM::RE::Prim[ 'a' ].first
|
230
|
+
assert_equal ['b'], RLSM::RE::Prim[ 'b' ].first
|
231
|
+
end
|
232
|
+
|
233
|
+
test "SyntaxNode#first : Should return first of the content of a star." do
|
234
|
+
assert_equal ['a'], RLSM::RE::Star[ RLSM::RE::Prim[ 'a' ] ].first
|
235
|
+
end
|
236
|
+
|
237
|
+
test "SyntaxNode#first : Should return union of first for all factors of a union." do
|
238
|
+
parse_tree = RLSM::RE::Union[ [RLSM::RE::Prim[ 'c' ], RLSM::RE::Prim[ 'b' ]] ]
|
239
|
+
|
240
|
+
assert_equal ['b','c'], parse_tree.first
|
241
|
+
end
|
242
|
+
|
243
|
+
test "SyntaxNode#first : Should return union of first upto first nonnull entry in concat." do
|
244
|
+
parse_tree1 = RLSM::RE::Concat[[RLSM::RE::Prim[ 'b' ],RLSM::RE::Prim[ 'a' ]] ]
|
245
|
+
parse_tree2 = RLSM::RE::Concat[[RLSM::RE::Star[RLSM::RE::Prim['c']], RLSM::RE::Prim['b']]]
|
246
|
+
|
247
|
+
assert_equal ['b'], parse_tree1.first
|
248
|
+
assert_equal ['b','c'], parse_tree2.first
|
249
|
+
end
|
250
|
+
|
251
|
+
test "SyntaxNode#last : Should return empty Array for EmptySet." do
|
252
|
+
assert_equal [], RLSM::RE::EmptySet[].last
|
253
|
+
end
|
254
|
+
|
255
|
+
test "SyntaxNode#last : Should return empty Array for EmptyWord." do
|
256
|
+
assert_equal [], RLSM::RE::EmptyWord[].last
|
257
|
+
end
|
258
|
+
|
259
|
+
test "SyntaxNode#last : Should return last character of a Prim in an Array." do
|
260
|
+
assert_equal ['f'], RLSM::RE::Prim[ 'f' ].last
|
261
|
+
assert_equal ['b'], RLSM::RE::Prim[ 'b' ].last
|
262
|
+
end
|
263
|
+
|
264
|
+
test "SyntaxNode#last : Should return last of the content of a star." do
|
265
|
+
assert_equal ['f'], RLSM::RE::Star[ RLSM::RE::Prim[ 'f' ] ].last
|
266
|
+
end
|
267
|
+
|
268
|
+
test "SyntaxNode#last : Should return union of last for all factors of a union." do
|
269
|
+
parse_tree = RLSM::RE::Union[ [RLSM::RE::Prim[ 'd' ], RLSM::RE::Prim[ 'b' ]] ]
|
270
|
+
|
271
|
+
assert_equal ['b','d'], parse_tree.last
|
272
|
+
end
|
273
|
+
|
274
|
+
test "SyntaxNode#last : Should return union of last upto first nonnull entry in concat." do
|
275
|
+
parse_tree1 = RLSM::RE::Concat[ [RLSM::RE::Prim[ 'c' ], RLSM::RE::Prim[ 'b' ]] ]
|
276
|
+
parse_tree2 = RLSM::RE::Concat[[RLSM::RE::Prim['c'], RLSM::RE::Star[ RLSM::RE::Prim['d']]]]
|
277
|
+
|
278
|
+
assert_equal ['b'], parse_tree1.last
|
279
|
+
assert_equal ['c','d'], parse_tree2.last
|
280
|
+
end
|
281
|
+
|
282
|
+
test "SyntaxNode#follow : Should return nil for EmptySet." do
|
283
|
+
assert_equal nil, RLSM::RE::EmptySet[].follow
|
284
|
+
end
|
285
|
+
|
286
|
+
test "SyntaxNode#follow : Should return nil for EmptyWord." do
|
287
|
+
assert_equal nil, RLSM::RE::EmptyWord[].follow
|
288
|
+
end
|
289
|
+
|
290
|
+
test "SyntaxNode#follow : Should return empty Array for a single letter expression." do
|
291
|
+
assert_equal [], RLSM::RE::Prim[ 'a' ].follow
|
292
|
+
end
|
293
|
+
|
294
|
+
test "SyntaxNode#follow : Should return every length two substring for a star." do
|
295
|
+
assert_equal [['a','a']], RLSM::RE::Star[ RLSM::RE::Prim[ 'a' ] ].follow
|
296
|
+
end
|
297
|
+
|
298
|
+
test "SyntaxNode#follow : Should return every length two substring for a union." do
|
299
|
+
concat = RLSM::RE::Concat[ %w(c c d).map { |char| RLSM::RE::Prim[char] } ]
|
300
|
+
parse_tree = RLSM::RE::Union[ [RLSM::RE::Star[ RLSM::RE::Prim[ 'a' ] ],
|
301
|
+
RLSM::RE::Prim[ 'b' ],
|
302
|
+
concat ] ]
|
303
|
+
assert_equal [['a','a'], ['c','c'], ['c','d']], parse_tree.follow
|
304
|
+
end
|
305
|
+
|
306
|
+
test "SyntaxNode#follow : Should return every length two substring for a concat." do
|
307
|
+
parse_tree = RLSM::RE::Concat[ [RLSM::RE::Star[ RLSM::RE::Prim[ 'a' ] ],
|
308
|
+
RLSM::RE::Prim[ 'b' ],
|
309
|
+
RLSM::RE::Union[ [RLSM::RE::Prim[ 'c' ], RLSM::RE::Prim[ 'd' ]] ] ] ]
|
310
|
+
assert_equal [['a','a'], ['a','b'], ['b','c'], ['b','d']], parse_tree.follow
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
context "Simplification of regexps:" do
|
315
|
+
before :each do
|
316
|
+
@a = RLSM::RE::Prim[ 'a' ]
|
317
|
+
@b = RLSM::RE::Prim[ 'b' ]
|
318
|
+
@c = RLSM::RE::Prim[ 'c' ]
|
319
|
+
@d = RLSM::RE::Prim[ 'd' ]
|
320
|
+
|
321
|
+
@aab = [@a, @a, @b]
|
322
|
+
end
|
323
|
+
|
324
|
+
test "RegExp::new : Should simplify (@)* to @" do
|
325
|
+
assert_equal RLSM::RE::EmptyWord[], RLSM::RegExp.new("(@)*").parse_tree
|
326
|
+
end
|
327
|
+
|
328
|
+
test "RegExp::new : Should ignore unneeded empty words in a union." do
|
329
|
+
re = RLSM::RegExp.new "@|b|a*"
|
330
|
+
|
331
|
+
expected = RLSM::RE::Union[ [ RLSM::RE::Star[ @a ], @b ] ]
|
332
|
+
|
333
|
+
assert_equal expected, re.parse_tree
|
334
|
+
end
|
335
|
+
|
336
|
+
test "RegExp::new : Should multiple empty words in a union reduce to one." do
|
337
|
+
re = RLSM::RegExp.new "@|b|@"
|
338
|
+
|
339
|
+
expected = RLSM::RE::Union[ [ RLSM::RE::EmptyWord[], @b ] ]
|
340
|
+
|
341
|
+
assert_equal expected, re.parse_tree
|
342
|
+
end
|
343
|
+
|
344
|
+
test "RegExp::new : Should simplify multiple identical entries in a union." do
|
345
|
+
re = RLSM::RegExp.new "@|b|b"
|
346
|
+
|
347
|
+
expected = RLSM::RE::Union[ [ RLSM::RE::EmptyWord[], @b ] ]
|
348
|
+
|
349
|
+
assert_equal expected, re.parse_tree
|
350
|
+
end
|
351
|
+
|
352
|
+
test "RegExp::new : Should simplify a empty word in a stared union." do
|
353
|
+
re = RLSM::RegExp.new "(@|a|b)*"
|
354
|
+
expected = RLSM::RE::Star[RLSM::RE::Union[ [@a, @b ] ]]
|
355
|
+
assert_equal expected, re.parse_tree
|
356
|
+
end
|
357
|
+
|
358
|
+
test "RegExp::new : Should simplify something like (a|a*|b) to (a*|b)" do
|
359
|
+
re = RLSM::RegExp.new "(a|a*|b)"
|
360
|
+
expected = RLSM::RE::Union[ [RLSM::RE::Star[@a], @b ] ]
|
361
|
+
assert_equal expected, re.parse_tree
|
362
|
+
end
|
363
|
+
|
364
|
+
test "RegExp::new : Should simplify something like (a|a*)* to a*" do
|
365
|
+
re = RLSM::RegExp.new "(a|a*)*"
|
366
|
+
expected = RLSM::RE::Star[ @a ]
|
367
|
+
assert_equal expected, re.parse_tree
|
368
|
+
end
|
369
|
+
|
370
|
+
# test "RegExp::new : Should simplify something like (aab|bab) to (a|b)ab." do
|
371
|
+
# re = RLSM::RegExp.new "(aab|bab)"
|
372
|
+
# expected = RLSM::RE::Concat[ [RLSM::RE::Union[ [@a,@b] ], @a, @b] ]
|
373
|
+
# assert_equal expected, re.parse_tree
|
374
|
+
# end
|
375
|
+
|
376
|
+
# test "RegExp::new : Should simplify something like (abb|aba) to ab(a|b)."
|
377
|
+
end
|
378
|
+
|
379
|
+
context "Equality of regular expressions:" do
|
380
|
+
test "RegExp#== : Should return true for identical string representations." do
|
381
|
+
re1 = RLSM::RegExp.new "a(b)(a|b)"
|
382
|
+
re2 = RLSM::RegExp.new "ab(a||b)"
|
383
|
+
|
384
|
+
assert re1 == re2
|
385
|
+
end
|
386
|
+
|
387
|
+
test "RegExp#== : Should return false if first of two regexpes differs." do
|
388
|
+
re1 = RLSM::RegExp.new "(a|b)a"
|
389
|
+
re2 = RLSM::RegExp.new "(b|a)a"
|
390
|
+
|
391
|
+
assert re1 == re2
|
392
|
+
refute re1 == RLSM::RegExp.new("(b|a)b")
|
393
|
+
end
|
394
|
+
|
395
|
+
test "RegExp#== : Should return false if last of two regexpes differs." do
|
396
|
+
re1 = RLSM::RegExp.new "a(a|b)"
|
397
|
+
re2 = RLSM::RegExp.new "a(b|a)"
|
398
|
+
|
399
|
+
assert re1 == re2
|
400
|
+
refute re1 == RLSM::RegExp.new("a(b|c)")
|
401
|
+
end
|
402
|
+
|
403
|
+
test "RegExp#== : Should return true if two regexps only differs in order in a union." do
|
404
|
+
re1 = RLSM::RegExp.new "a(a|b)a"
|
405
|
+
re2 = RLSM::RegExp.new "a(b|a)a"
|
406
|
+
|
407
|
+
assert re1 == re2
|
408
|
+
end
|
409
|
+
|
410
|
+
test "RegExp#== : Should return true if two regexps only differs in factorisation." do
|
411
|
+
re1 = RLSM::RegExp.new "a(a|b)a"
|
412
|
+
re2 = RLSM::RegExp.new "(aba|aaa)"
|
413
|
+
re3 = RLSM::RegExp.new "aba"
|
414
|
+
|
415
|
+
assert re1 == re2, "Oho?"
|
416
|
+
refute re3 == re1, "Huh?"
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
context "Calculation with regular expressions:" do
|
421
|
+
test "RegExp::+ : Should concatenate two regexps." do
|
422
|
+
re1 = RLSM::RegExp.new "ab(a|b)"
|
423
|
+
re2 = RLSM::RegExp.new "ab"
|
424
|
+
|
425
|
+
assert_equal RLSM::RegExp.new("ab(a|b)ab"), re1 + re2
|
426
|
+
end
|
427
|
+
|
428
|
+
test "RegExp::| : Should unite two regexps." do
|
429
|
+
re1 = RLSM::RegExp.new "ab(a|b)"
|
430
|
+
re2 = RLSM::RegExp.new "ab"
|
431
|
+
|
432
|
+
assert_equal RLSM::RegExp.new("ab(a|b)|ab"), re1 | re2
|
433
|
+
end
|
434
|
+
|
435
|
+
test "RegExp::star : Should star a regexp." do
|
436
|
+
re = RLSM::RegExp.new "ab(a|b)"
|
437
|
+
|
438
|
+
assert_equal RLSM::RegExp.new("(ab(a|b))*"), re.star
|
439
|
+
end
|
440
|
+
end
|
metadata
CHANGED
@@ -1,63 +1,132 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rlsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Gunther Diemant
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-09 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: minitest
|
17
17
|
type: :development
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: "0"
|
24
24
|
version:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thoughtbot-shoulda
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: |+
|
36
|
+
= rlsm
|
37
|
+
rlsm stands for *R*egular *L*anguages and *S*yntactic *M*onoids.
|
38
|
+
|
39
|
+
Source is availible from
|
40
|
+
http://github.com/asmodis/rlsm
|
41
|
+
|
42
|
+
RDoc-Documentation is availible from
|
43
|
+
http://rlsm.rubyforge.org
|
44
|
+
|
45
|
+
== DESCRIPTION:
|
46
|
+
|
47
|
+
This is a ruby implementation of three concepts:
|
48
|
+
- Deterministic Finite Automata
|
49
|
+
- Regular Expressions (in the sense of theoretical computer sience)
|
50
|
+
- Monoids
|
51
|
+
|
52
|
+
|
53
|
+
== SYNOPSIS:
|
54
|
+
|
55
|
+
require 'rlsm'
|
56
|
+
|
57
|
+
m = RLSM::Monoid.new '012 112 212'
|
58
|
+
m.syntactic? # => true
|
59
|
+
m.isomorph_to?(m) # => true
|
60
|
+
m.commutative? # => false
|
61
|
+
|
62
|
+
== INSTALL:
|
63
|
+
|
64
|
+
gem install rlsm
|
65
|
+
|
66
|
+
|
67
|
+
== LICENSE:
|
68
|
+
|
69
|
+
(The MIT License)
|
70
|
+
|
71
|
+
Copyright (c) 2009 Gunther Diemant <g.diemant@gmx.net>
|
72
|
+
|
73
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
74
|
+
a copy of this software and associated documentation files (the
|
75
|
+
'Software'), to deal in the Software without restriction, including
|
76
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
77
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
78
|
+
permit persons to whom the Software is furnished to do so, subject to
|
79
|
+
the following conditions:
|
80
|
+
|
81
|
+
The above copyright notice and this permission notice shall be
|
82
|
+
included in all copies or substantial portions of the Software.
|
83
|
+
|
84
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
87
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
88
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
89
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
90
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
91
|
+
|
92
|
+
email: g.diemant@gmx.net
|
93
|
+
executables: []
|
31
94
|
|
95
|
+
extensions:
|
96
|
+
- ext/array/extconf.rb
|
97
|
+
- ext/binop/extconf.rb
|
98
|
+
- ext/monoid/extconf.rb
|
32
99
|
extra_rdoc_files:
|
33
|
-
-
|
34
|
-
- Manifest.txt
|
35
|
-
- README.txt
|
100
|
+
- README
|
36
101
|
files:
|
37
|
-
-
|
38
|
-
- Manifest.txt
|
39
|
-
- README.txt
|
40
|
-
- Rakefile
|
41
|
-
- bin/smon
|
42
|
-
- data/monoids.db
|
43
|
-
- lib/database.rb
|
44
|
-
- lib/monkey_patching/array_ext.rb
|
45
|
-
- lib/rlsm.rb
|
102
|
+
- lib/rlsm/binary_operation.rb
|
46
103
|
- lib/rlsm/dfa.rb
|
104
|
+
- lib/rlsm/helper.rb
|
47
105
|
- lib/rlsm/monoid.rb
|
48
|
-
- lib/rlsm/
|
49
|
-
- lib/
|
50
|
-
- lib/
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
106
|
+
- lib/rlsm/regexp.rb
|
107
|
+
- lib/rlsm/regexp_parser.rb
|
108
|
+
- lib/rlsm.rb
|
109
|
+
- ext/array/array_c_ext.c
|
110
|
+
- ext/binop/binop_c_ext.c
|
111
|
+
- ext/monoid/monoid_c_ext.c
|
112
|
+
- ext/array/extconf.rb
|
113
|
+
- ext/binop/extconf.rb
|
114
|
+
- ext/monoid/extconf.rb
|
115
|
+
- test/helpers.rb
|
116
|
+
- test/test_binop.rb
|
117
|
+
- test/test_dfa.rb
|
118
|
+
- test/test_monoid.rb
|
119
|
+
- test/test_regexp.rb
|
120
|
+
- Rakefile
|
121
|
+
- README
|
55
122
|
has_rdoc: true
|
56
|
-
homepage: http://
|
123
|
+
homepage: http://github.com/asmodis/rlsm
|
124
|
+
licenses: []
|
125
|
+
|
57
126
|
post_install_message:
|
58
127
|
rdoc_options:
|
59
128
|
- --main
|
60
|
-
- README
|
129
|
+
- README
|
61
130
|
require_paths:
|
62
131
|
- lib
|
63
132
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -75,9 +144,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
144
|
requirements: []
|
76
145
|
|
77
146
|
rubyforge_project: rlsm
|
78
|
-
rubygems_version: 1.
|
147
|
+
rubygems_version: 1.3.5
|
79
148
|
signing_key:
|
80
|
-
specification_version:
|
81
|
-
summary:
|
82
|
-
test_files:
|
83
|
-
|
149
|
+
specification_version: 3
|
150
|
+
summary: Library for investigating regular languages and syntactic monoids.
|
151
|
+
test_files:
|
152
|
+
- test/test_binop.rb
|
153
|
+
- test/test_dfa.rb
|
154
|
+
- test/test_monoid.rb
|
155
|
+
- test/test_regexp.rb
|