Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Learning RFSA in reverse
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Thomas
Learning RFSA in reverse
Commits
fbd6483a
Commit
fbd6483a
authored
5 years ago
by
Thomas
Browse files
Options
Downloads
Patches
Plain Diff
timbuk parser
parent
61a0e9c0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
learnlib/TimbukParser.java
+27
-4
27 additions, 4 deletions
learnlib/TimbukParser.java
with
27 additions
and
4 deletions
learnlib/TimbukParser.java
+
27
−
4
View file @
fbd6483a
import
com.google.common.collect.Lists
;
import
net.automatalib.automata.fsa.impl.compact.CompactNFA
;
import
net.automatalib.util.automata.builders.FSABuilder
;
import
net.automatalib.visualization.Visualization
;
import
net.automatalib.words.Alphabet
;
import
net.automatalib.words.impl.Alphabets
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Scanner
;
import
java.util.Set
;
import
java.util.*
;
// Sorry, not a general parser, just for these files
...
...
@@ -12,11 +16,13 @@ public class TimbukParser {
public
Set
<
GraphvizParser
.
Edge
>
edges
;
public
Set
<
String
>
initial
;
public
Set
<
String
>
accepting
;
public
Set
<
String
>
inputs
;
public
TimbukParser
(
Path
filename
)
throws
IOException
{
edges
=
new
HashSet
<>();
initial
=
new
HashSet
<>();
accepting
=
new
HashSet
<>();
inputs
=
new
HashSet
<>();
Scanner
s
=
new
Scanner
(
filename
);
while
(
s
.
hasNextLine
())
{
...
...
@@ -36,6 +42,7 @@ public class TimbukParser {
int
sep
=
parts
[
0
].
indexOf
(
"("
);
String
label
=
parts
[
0
].
substring
(
0
,
sep
).
trim
();
inputs
.
add
(
label
);
String
from
=
parts
[
0
].
substring
(
sep
+
1
,
parts
[
0
].
length
()-
1
);
edges
.
add
(
new
GraphvizParser
.
Edge
(
from
,
parts
[
1
].
trim
(),
label
));
...
...
@@ -43,4 +50,20 @@ public class TimbukParser {
}
}
}
CompactNFA
<
String
>
createNFA
()
{
List
<
String
>
inputList
=
Lists
.
newArrayList
(
inputs
.
iterator
());
Alphabet
<
String
>
alphabet
=
Alphabets
.
fromList
(
inputList
);
FSABuilder
<?,
String
,
CompactNFA
<
String
>>
builder
=
new
FSABuilder
<>(
new
CompactNFA
<>(
alphabet
));
initial
.
forEach
(
builder:
:
withInitial
);
accepting
.
forEach
(
builder:
:
withAccepting
);
for
(
GraphvizParser
.
Edge
e
:
edges
)
{
builder
.
from
(
e
.
from
).
on
(
e
.
label
).
to
(
e
.
to
);
}
return
builder
.
create
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment