diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-06-05 22:09:23 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-06-05 22:09:23 -0300 |
| commit | 05c9922b30cd0dcd2a452673c2e155215d074b19 (patch) | |
| tree | 80f2cc1cfd239761f3d74d20159f780c1673781b /src/main/java/bjc/rgens/parser/ConfigLoader.java | |
| parent | f25d1062a56a81b17348b799e6d4d7e1dc12a1cc (diff) | |
Templates pt. 3
Templates should now work, though there is no syntax to reference them
from rules yet
In addition, several internal things have been changed so as to improve
code quality
Diffstat (limited to 'src/main/java/bjc/rgens/parser/ConfigLoader.java')
| -rw-r--r-- | src/main/java/bjc/rgens/parser/ConfigLoader.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/bjc/rgens/parser/ConfigLoader.java b/src/main/java/bjc/rgens/parser/ConfigLoader.java index f3028fe..4cad368 100644 --- a/src/main/java/bjc/rgens/parser/ConfigLoader.java +++ b/src/main/java/bjc/rgens/parser/ConfigLoader.java @@ -7,6 +7,8 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Scanner; +import bjc.rgens.parser.templates.GrammarTemplate; + public class ConfigLoader { /** * Load a grammar set from a configuration file. @@ -62,7 +64,7 @@ public class ConfigLoader { switch(type) { case "load": - loadConfigLine(ln, set, cfgParent); + loadConfigLine(ln, cfgSet, set, cfgParent); break; default: throw new GrammarException("Unknown config line type " + type); @@ -91,8 +93,7 @@ public class ConfigLoader { return cfgSet; } - private static void loadConfigLine(String ln, RGrammarSet set, Path cfgParent) throws IOException { - + private static void loadConfigLine(String ln, ConfigSet cfgSet, RGrammarSet set, Path cfgParent) throws IOException { /* * Get the place where the tag ID ends */ @@ -134,6 +135,8 @@ public class ConfigLoader { BufferedReader fis = Files.newBufferedReader(convPath); GrammarTemplate template = GrammarTemplate.readTemplate(fis); + template.belongsTo = cfgSet; + if(template.name == null) { System.err.printf("\tINFO: Naming unnamed template loaded from %s off config name '%s'\n", convPath, name); @@ -148,10 +151,10 @@ public class ConfigLoader { long fileTime = endFileTime - startFileTime; System.err.printf("\tPERF: Read template %s (from %s) in %d ns (%f s)\n", - gram.name, convPath, fileTime, fileTime / 1000000000.0); + template.name, convPath, fileTime, fileTime / 1000000000.0); /* Add grammar to the set. */ - cfgSet.templates.put(name, gram); + cfgSet.templates.put(name, template); /* * @NOTE |
