diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-06-03 19:27:43 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-06-03 19:27:43 -0300 |
| commit | a13f1f396d28c0b900a10bede57f30be3a35003a (patch) | |
| tree | 4e358ecff1c794bb8691e985528f5640eefd415e /src/main/java/bjc/rgens/parser/RGrammarSet.java | |
| parent | c524f46dbd6a460b7374690244888a001023d3af (diff) | |
Enable multi-prefixing/suffixing
You can now provide multiple prefix/suffix elements, and all of the
permutations of them will be applied.
For example, providing the elements A & B, will yield the following
permutations
* A
* B
* A B
* B A
Diffstat (limited to 'src/main/java/bjc/rgens/parser/RGrammarSet.java')
| -rwxr-xr-x | src/main/java/bjc/rgens/parser/RGrammarSet.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/bjc/rgens/parser/RGrammarSet.java b/src/main/java/bjc/rgens/parser/RGrammarSet.java index 975510a..c797b8c 100755 --- a/src/main/java/bjc/rgens/parser/RGrammarSet.java +++ b/src/main/java/bjc/rgens/parser/RGrammarSet.java @@ -7,6 +7,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; +import java.util.TreeMap; import java.util.Scanner; import java.util.Set; @@ -34,7 +35,7 @@ public class RGrammarSet { exportedRules = new HashMap<>(); - exportFrom = new HashMap<>(); + exportFrom = new TreeMap<>(); loadedFrom = new HashMap<>(); } @@ -256,14 +257,16 @@ public class RGrammarSet { */ Path convPath = cfgParent.resolve(path.toString()); - //if(Files.isDirectory(convPath)) { - // /* @TODO implement subset grammars */ - // throw new GrammarException("Sub-grammar sets aren't implemented yet"); - //} else if (convPath.getFileName().endsWith(".gram")) { + if(Files.isDirectory(convPath)) { + /* @TODO implement subset grammars */ + throw new GrammarException("Sub-grammar sets aren't implemented yet"); + } else if (convPath.getFileName().toString().endsWith(".gram")) { /* Load grammar file. */ try { + BufferedReader fis = Files.newBufferedReader(convPath); RGrammar gram = RGrammarParser.readGrammar(fis); + fis.close(); /* Add grammar to the set. */ @@ -278,10 +281,10 @@ public class RGrammarSet { String msg = String.format("Error loading file '%s'", path); throw new GrammarException(msg, gex); } - //} else { - // String msg = String.format("Unrecognized file type '%s'", convPath.getFileName()); - // throw new GrammarException(msg); - //} + } else { + String msg = String.format("Unrecognized file type '%s'", convPath.getFileName()); + throw new GrammarException(msg); + } } } |
