SEATC 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/Automaton Analyzer.rb +5 -2
- data/lib/Grammar Analyzer.rb +3 -1
- data/lib/Grammar Reader.rb +2 -2
- data/lib/PDA.rb +9 -1
- data/lib/Regular Expression.rb +9 -0
- data/lib/Regular Grammar Analyzer.rb +4 -4
- data/lib/Turing Analyzer.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9781112acb83ae13c83dbb2b4a6ba1227060fbee
|
4
|
+
data.tar.gz: 8320db674be470e14bf40547bdfd53584ce39330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aef04c1b6c066db058690dfc7f06bf98c20358779dd47363efce25a08520bd800d8d3a078819f201b3eb4c0299bd2f56c14e67411d554458157625834f43c4c2
|
7
|
+
data.tar.gz: 85d3c1bd038309ca590bc2c5dbb4e7d955c84c3929601417527b59531b5c5ef93c858c070645330384c2ea26614c49fab2df23b884061009e944e39bc40a8dee
|
data/lib/Automaton Analyzer.rb
CHANGED
@@ -30,9 +30,10 @@ class AutomatonState
|
|
30
30
|
end
|
31
31
|
|
32
32
|
class AutomatonAnalyzer
|
33
|
-
|
33
|
+
attr_accessor :valid, :deterministic, :errno
|
34
34
|
def initialize(deterministic)
|
35
|
-
|
35
|
+
@deterministic = deterministic
|
36
|
+
@errno = 0
|
36
37
|
end
|
37
38
|
def isDeterministic(states)
|
38
39
|
return false if !@deterministic
|
@@ -113,10 +114,12 @@ class AutomatonAnalyzer
|
|
113
114
|
counter = counter + 1
|
114
115
|
end
|
115
116
|
if !lines[0].include? "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!--Created with JFLAP 6.4.--><structure>"
|
117
|
+
@errno = 1
|
116
118
|
return false
|
117
119
|
end
|
118
120
|
# Check if finite automaton
|
119
121
|
if !lines[1].match "<type>fa</type>"
|
122
|
+
@errno = 2
|
120
123
|
return false
|
121
124
|
end
|
122
125
|
states = []
|
data/lib/Grammar Analyzer.rb
CHANGED
@@ -2,7 +2,7 @@ require 'thread'
|
|
2
2
|
load 'Grammar Reader.rb'
|
3
3
|
|
4
4
|
class GrammarAnalyzer
|
5
|
-
attr_accessor :mutex, :valid
|
5
|
+
attr_accessor :mutex, :valid, :errno
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@mutex = Mutex.new
|
@@ -61,6 +61,8 @@ class GrammarAnalyzer
|
|
61
61
|
def analyze(file, line)
|
62
62
|
reader = GrammarReader.new
|
63
63
|
prods = reader.createProductions(reader.readFile(file))
|
64
|
+
@errno = reader.error
|
65
|
+
return false if @errno != 0
|
64
66
|
prods['S'].each do |p|
|
65
67
|
t = Thread.new { analyzer(String.new(p), String.new(line), prods)}
|
66
68
|
t.join
|
data/lib/Grammar Reader.rb
CHANGED
@@ -34,11 +34,11 @@ class GrammarReader
|
|
34
34
|
def createProductions(lines)
|
35
35
|
productions = Hash.new
|
36
36
|
if !lines[0].include? "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!--Created with JFLAP"
|
37
|
-
@error =
|
37
|
+
@error = 1
|
38
38
|
return productions
|
39
39
|
end
|
40
40
|
if !lines[1].include? "\t<type>grammar</type> "
|
41
|
-
@error =
|
41
|
+
@error = 2
|
42
42
|
return productions
|
43
43
|
end
|
44
44
|
counter = 3
|
data/lib/PDA.rb
CHANGED
@@ -37,7 +37,13 @@ end
|
|
37
37
|
|
38
38
|
class PDAAnalyzer
|
39
39
|
@valid = false
|
40
|
-
|
40
|
+
attr_accessor :errno
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
@errno = 0
|
44
|
+
end
|
45
|
+
|
46
|
+
def getStateID(modified)
|
41
47
|
modified.slice! "\t\t<state id=\""
|
42
48
|
lastQuota = true
|
43
49
|
id = 0
|
@@ -144,10 +150,12 @@ class PDAAnalyzer
|
|
144
150
|
counter = counter + 1
|
145
151
|
end
|
146
152
|
if !lines[0].include? "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!--Created with JFLAP 6.4.--><structure>"
|
153
|
+
@errno = 1
|
147
154
|
return false
|
148
155
|
end
|
149
156
|
# Check if pushdown automaton
|
150
157
|
if !lines[1].match "<type>pda</type>"
|
158
|
+
@errno = 2
|
151
159
|
return false
|
152
160
|
end
|
153
161
|
states = []
|
data/lib/Regular Expression.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
class RegularExpression
|
2
2
|
@regex
|
3
|
+
attr_accessor :errno
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@errno = 0
|
7
|
+
end
|
3
8
|
|
4
9
|
def readFile(file)
|
5
10
|
file = File.new(file, "r")
|
@@ -11,8 +16,12 @@ class RegularExpression
|
|
11
16
|
def createRegex(lines)
|
12
17
|
regex = ""
|
13
18
|
if !lines[0].match "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"
|
19
|
+
@errno = 1
|
20
|
+
return false
|
14
21
|
end
|
15
22
|
if !lines[1].include? "\t<type>re</type>"
|
23
|
+
@errno = 2
|
24
|
+
return false
|
16
25
|
end
|
17
26
|
regex = lines[3]
|
18
27
|
regex.slice! "\t<expression>"
|
@@ -18,11 +18,11 @@ PRODUCTION_ERROR = 2
|
|
18
18
|
|
19
19
|
class RegularGrammar
|
20
20
|
@valid
|
21
|
-
|
21
|
+
attr_accessor :errno
|
22
22
|
|
23
23
|
def initialize()
|
24
24
|
@valid = false
|
25
|
-
@
|
25
|
+
@errno = 0
|
26
26
|
end
|
27
27
|
def getLeft(modified)
|
28
28
|
modified.slice! "\t\t<left>"
|
@@ -52,11 +52,11 @@ class RegularGrammar
|
|
52
52
|
def createProductions(lines)
|
53
53
|
productions = Hash.new
|
54
54
|
if !lines[0].include? "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!--Created with JFLAP 6.4.--><structure> "
|
55
|
-
@
|
55
|
+
@errno = 1
|
56
56
|
return productions
|
57
57
|
end
|
58
58
|
if !lines[1].include? "\t<type>grammar</type> "
|
59
|
-
@
|
59
|
+
@errno = 2
|
60
60
|
return productions
|
61
61
|
end
|
62
62
|
counter = 3
|
data/lib/Turing Analyzer.rb
CHANGED
@@ -12,13 +12,14 @@ class TuringTransition
|
|
12
12
|
end
|
13
13
|
|
14
14
|
class TuringAnalyzer
|
15
|
-
attr_accessor :reader, :lines, :states, :valid
|
15
|
+
attr_accessor :reader, :lines, :states, :valid, :errno
|
16
16
|
@initial
|
17
17
|
def initialize
|
18
18
|
@reader = TuringReader.new
|
19
19
|
@states = Array.new
|
20
20
|
@initial = nil
|
21
21
|
@valid = false
|
22
|
+
@errno = 0
|
22
23
|
end
|
23
24
|
|
24
25
|
def analyze file, line
|
@@ -38,11 +39,13 @@ class TuringAnalyzer
|
|
38
39
|
|
39
40
|
def validateJFlap
|
40
41
|
return true if @lines[0].match "JFLAP"
|
42
|
+
@errno = 1
|
41
43
|
return false
|
42
44
|
end
|
43
45
|
|
44
46
|
def validateTuringMachine
|
45
47
|
return true if @lines[0].match "turing"
|
48
|
+
@errno = 2
|
46
49
|
return false
|
47
50
|
end
|
48
51
|
|