From 8c289f05ca36c3def6a4e4ab2414b7469c03339e Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Sun, 21 Jul 2019 16:24:47 -0300 Subject: Refactor front-end error-handling This refactors the front-end to use a tree for capturing errors, instead of throwing exceptions. This has the benefit that you will receive notifications about all of the error messages you have, instead of only the first. I'm a bit fuzzy on the details, since it's been a while since I wrote these changes. --- src/main/java/bjc/rgens/parser/RGrammarTest.java | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/main/java/bjc/rgens/parser/RGrammarTest.java') diff --git a/src/main/java/bjc/rgens/parser/RGrammarTest.java b/src/main/java/bjc/rgens/parser/RGrammarTest.java index 788823a..36c87de 100755 --- a/src/main/java/bjc/rgens/parser/RGrammarTest.java +++ b/src/main/java/bjc/rgens/parser/RGrammarTest.java @@ -2,11 +2,17 @@ package bjc.rgens.parser; import bjc.rgens.parser.templates.GrammarTemplate; +import bjc.utils.data.ITree; +import bjc.utils.data.Tree; + import java.io.IOException; + import java.net.URISyntaxException; import java.net.URL; + import java.nio.file.Path; import java.nio.file.Paths; + import java.util.Random; import static bjc.rgens.parser.RGrammarLogging.*; @@ -27,9 +33,24 @@ public class RGrammarTest { URL rsc = RGrammarTest.class.getResource("/server-config-sample.gcfg"); try { + LoadOptions lopts = new LoadOptions(); + + // Set up load options + lopts.doPerf = true; + lopts.doDebug = false; + lopts.doTrace = false; + + lopts.defName = "default"; + /* Load a grammar set. */ - Path cfgPath = Paths.get(rsc.toURI()); - ConfigSet cfgSet = ConfigLoader.fromConfigFile(cfgPath); + Path cfgPath = Paths.get(rsc.toURI()); + + String msg = String.format("INFO: Loading config file %s", cfgPath); + ITree errTree = new Tree<>(msg); + + ConfigSet cfgSet = ConfigLoader.fromConfigFile(cfgPath, lopts, errTree); + + System.err.print(errTree); for(RGrammarSet gramSet : cfgSet.grammars.values()) { testGrammarSet(gramSet); -- cgit v1.2.3