rlsm 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +12 -1
- data/lib/rlsm.rb +1 -1
- data/lib/rlsm/dfa.rb +13 -4
- data/lib/rlsm/monoid.rb +7 -6
- data/lib/rlsm/monoid_db.rb +1 -1
- data/lib/rlsm/regexp.rb +11 -375
- data/lib/rlsm/regexp_nodes/concat.rb +112 -0
- data/lib/rlsm/regexp_nodes/primexp.rb +49 -0
- data/lib/rlsm/regexp_nodes/renodes.rb +95 -0
- data/lib/rlsm/regexp_nodes/star.rb +50 -0
- data/lib/rlsm/regexp_nodes/union.rb +85 -0
- data/lib/smon/commands/db_find.rb +37 -0
- data/lib/smon/commands/db_stat.rb +20 -0
- data/lib/smon/commands/show.rb +4 -17
- data/lib/smon/presenter.rb +18 -0
- data/lib/smon/presenter/txt_presenter.rb +157 -0
- data/lib/smon/smon.rb +3 -4
- data/test/dfa_spec.rb +99 -0
- data/test/monoid_spec.rb +270 -0
- data/test/regexp_spec.rb +25 -0
- metadata +16 -5
- data/test/test_rlsm.rb +0 -0
data/test/regexp_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'rlsm', 'regexp')
|
2
|
+
|
3
|
+
describe RLSM::RegExp do
|
4
|
+
['(ab', '(|ab)', '(ab|)', 'ab(*)', '(*a|b)', 'ab()cd'].each do |str|
|
5
|
+
it "should raise error for input #{str}" do
|
6
|
+
lambda { RLSM::RegExp.new str }.should raise_error(Exception)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
['', '&', 'a', 'a|b', 'ab', '(a|b)c', '(a*|bc&&&d)|abc|(a|b|c)*'].each do |s|
|
11
|
+
it "should accept the input #{s}" do
|
12
|
+
lambda { RLSM::RegExp.new s }.should_not raise_error(Exception)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should simplify a input" do
|
17
|
+
RLSM::RegExp.new('a&&**&&c***(bbbcccaa)**').to_s.should == 'ac*(bbbcccaa)*'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should convert a regexp to an dfa" do
|
21
|
+
dfa1 = RLSM::RegExp.new('(a|b)aa*(&|b)a*').to_dfa
|
22
|
+
dfa1.states.size.should == 4
|
23
|
+
dfa1.final_states.map {|f| f.label}.sort.should == ['1', '2'].sort
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rlsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- asmodis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-17 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -48,6 +48,13 @@ files:
|
|
48
48
|
- lib/rlsm/monoid.rb
|
49
49
|
- lib/rlsm/monoid_db.rb
|
50
50
|
- lib/rlsm/regexp.rb
|
51
|
+
- lib/rlsm/regexp_nodes/concat.rb
|
52
|
+
- lib/rlsm/regexp_nodes/primexp.rb
|
53
|
+
- lib/rlsm/regexp_nodes/renodes.rb
|
54
|
+
- lib/rlsm/regexp_nodes/star.rb
|
55
|
+
- lib/rlsm/regexp_nodes/union.rb
|
56
|
+
- lib/smon/commands/db_find.rb
|
57
|
+
- lib/smon/commands/db_stat.rb
|
51
58
|
- lib/smon/commands/exit.rb
|
52
59
|
- lib/smon/commands/help.rb
|
53
60
|
- lib/smon/commands/intro.rb
|
@@ -56,8 +63,12 @@ files:
|
|
56
63
|
- lib/smon/commands/regexp.rb
|
57
64
|
- lib/smon/commands/reload.rb
|
58
65
|
- lib/smon/commands/show.rb
|
66
|
+
- lib/smon/presenter.rb
|
67
|
+
- lib/smon/presenter/txt_presenter.rb
|
59
68
|
- lib/smon/smon.rb
|
60
|
-
- test/
|
69
|
+
- test/dfa_spec.rb
|
70
|
+
- test/monoid_spec.rb
|
71
|
+
- test/regexp_spec.rb
|
61
72
|
has_rdoc: true
|
62
73
|
homepage: http://www.github.com/asmodis/rlsm
|
63
74
|
post_install_message:
|
@@ -85,5 +96,5 @@ rubygems_version: 1.2.0
|
|
85
96
|
signing_key:
|
86
97
|
specification_version: 2
|
87
98
|
summary: "This is a ruby implementation of three concepts: - Deterministic Finite Automata (DFA) - Regular Expressions (in the sense of theoretical computer sience) - Monoids (an algebraic construct)"
|
88
|
-
test_files:
|
89
|
-
|
99
|
+
test_files: []
|
100
|
+
|
data/test/test_rlsm.rb
DELETED
File without changes
|