Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alexandru Dura
SPPF Earley Parser
Commits
f6e215b1
Commit
f6e215b1
authored
Feb 18, 2020
by
Alexandru Dura
Browse files
Add a convenience function to get the parse trees
parent
a2d41e0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
f6e215b1
...
...
@@ -33,6 +33,3 @@ subprojects {
maxParallelForks
=
Runtime
.
runtime
.
availableProcessors
()
}
}
// Define the main class for the application
mainClassName
=
'Schedule'
src/main/java/se/lth/sep/Util.java
View file @
f6e215b1
...
...
@@ -7,6 +7,7 @@ import java.util.Collection;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.apache.commons.lang3.mutable.MutableInt
;
...
...
@@ -84,6 +85,26 @@ public class Util {
return
result
;
}
public
List
<
ParseTree
>
enumerateParseTrees
(
SPPFNode
root
,
Grammar
grammar
,
SPPFTrivialProductionRemover
tpr
)
{
SPPFDebinarizeVisitor
dbv
=
new
SPPFDebinarizeVisitor
();
dbv
.
visit
(
root
);
// decorate nodes with the grammar rules
SPPFNodeDecorator
dec
=
new
SPPFNodeDecorator
(
grammar
);
dec
.
visit
(
root
);
// remove trivial productions
tpr
.
visit
(
root
);
// generate all the possible parse trees
ParseTreeGenerator
ptg
=
new
ParseTreeGenerator
(
grammar
,
root
);
List
<
ParseTree
>
pts
=
ptg
.
getParseTrees
();
return
pts
;
}
}
class
DotVisitor
implements
SPPFNodeVisitor
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment