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
c4befba8
Commit
c4befba8
authored
Feb 18, 2020
by
Alexandru Dura
Browse files
Expose the enumerateParseTrees as a static method
parent
2ed4d4c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/se/lth/sep/Util.java
View file @
c4befba8
...
...
@@ -86,9 +86,9 @@ public class Util {
return
result
;
}
public
List
<
ParseTree
>
enumerateParseTrees
(
SPPFNode
root
,
Grammar
grammar
,
SPPFTrivialProductionRemover
tpr
)
{
static
public
List
<
ParseTree
>
enumerateParseTrees
(
SPPFNode
root
,
Grammar
grammar
,
SPPFTrivialProductionRemover
tpr
)
{
SPPFDebinarizeVisitor
dbv
=
new
SPPFDebinarizeVisitor
();
dbv
.
visit
(
root
);
...
...
src/test/java/EarleyParserTest.java
View file @
c4befba8
...
...
@@ -421,14 +421,6 @@ public class EarleyParserTest {
SPPFNode
root
=
parser
.
parse
(
str
,
Java14Grammar
.
n_class_declaration
);
assertNotNull
(
root
);
Util
.
dumpParseResult
(
"testJava5-bt.dot"
,
root
,
g
);
// debinarize
SPPFDebinarizeVisitor
dbv
=
new
SPPFDebinarizeVisitor
();
dbv
.
visit
(
root
);
Util
.
dumpParseResult
(
"testJava5.dot"
,
root
,
g
);
// decorate nodes with the grammar rules
SPPFNodeDecorator
dec
=
new
SPPFNodeDecorator
(
g
);
dec
.
visit
(
root
);
// remove trivial productions
SPPFTrivialProductionRemover
tpr
=
new
SPPFTrivialProductionRemover
(
g
)
{
@Override
public
boolean
isBubleUpChild
(
Category
c
)
{
...
...
@@ -439,12 +431,7 @@ public class EarleyParserTest {
return
false
;
}
};
tpr
.
visit
(
root
);
Util
.
dumpParseResult
(
"testJava5-notr.dot"
,
root
,
g
);
// dump the parse trees
ParseTreeGenerator
ptg
=
new
ParseTreeGenerator
(
g
,
root
);
List
<
ParseTree
>
pts
=
ptg
.
getParseTrees
();
List
<
ParseTree
>
pts
=
Util
.
enumerateParseTrees
(
root
,
g
,
tpr
);
// the parsing should produce 3^6 parse trees
assertEquals
(
3
*
3
*
3
*
3
*
3
*
3
,
pts
.
size
());
Util
.
dumpParseTrees
(
"testJava5-parse-tree"
,
pts
);
...
...
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