summaryrefslogtreecommitdiff
path: root/RGens/src/main/java/bjc/rgens/newparser/RGrammars.java
diff options
context:
space:
mode:
authorstudent <student@69.161.224.76>2018-03-29 11:38:02 -0400
committerstudent <student@69.161.224.76>2018-03-29 11:38:02 -0400
commit6aa15e30fa75211964428e386b4b6b0f2c66dbc5 (patch)
tree5beeb6016a94b284eeed80daf65b9c2800ec7e63 /RGens/src/main/java/bjc/rgens/newparser/RGrammars.java
parentc921b00c99cf46bc33f724581ab9bde2b0d8bb6a (diff)
Rename package
Diffstat (limited to 'RGens/src/main/java/bjc/rgens/newparser/RGrammars.java')
-rw-r--r--RGens/src/main/java/bjc/rgens/newparser/RGrammars.java55
1 files changed, 0 insertions, 55 deletions
diff --git a/RGens/src/main/java/bjc/rgens/newparser/RGrammars.java b/RGens/src/main/java/bjc/rgens/newparser/RGrammars.java
deleted file mode 100644
index 3704944..0000000
--- a/RGens/src/main/java/bjc/rgens/newparser/RGrammars.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package bjc.rgens.newparser;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URI;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Get access to the included grammars.
- *
- * @author Ben Culkin
- */
-public class RGrammars {
- private static RGrammarSet gramSet;
-
- private static void loadSet() {
- try {
- URI rsc = RGrammarTest.class.getResource("/server-config-sample.cfg").toURI();
-
- Map<String, String> env = new HashMap<>();
- env.put("create", "true");
- FileSystem zipfs = FileSystems.newFileSystem(rsc, env);
-
- Path cfgPath = Paths.get(rsc);
-
- gramSet = RGrammarSet.fromConfigFile(cfgPath);
- } catch (IOException | URISyntaxException ex) {
- RuntimeException rtex = new RuntimeException("Could not load grammars");
-
- rtex.initCause(ex);
-
- throw rtex;
- }
- }
-
- public static String generateExport(String exportName) throws GrammarException {
- if(gramSet == null) loadSet();
-
- if(!gramSet.getExportedRules().contains(exportName)) {
- throw new GrammarException(String.format("No built-in rule named %s", exportName));
- }
-
- RGrammar gram = gramSet.getExportSource(exportName);
-
- String res = gram.generate(exportName);
- if(exportName.contains("+")) res = res.replaceAll("\\s+", "");
-
- return res;
- }
-}