From 0164b842d14675b0a28dd143d36923e690e75d27 Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Tue, 5 Jun 2018 13:50:31 -0300 Subject: Config work More work for getting going on templates, as well as just some refactoring for future changes --- src/main/java/bjc/rgens/parser/RGrammar.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/java/bjc/rgens/parser/RGrammar.java') diff --git a/src/main/java/bjc/rgens/parser/RGrammar.java b/src/main/java/bjc/rgens/parser/RGrammar.java index 1b68c80..381eac1 100755 --- a/src/main/java/bjc/rgens/parser/RGrammar.java +++ b/src/main/java/bjc/rgens/parser/RGrammar.java @@ -31,6 +31,8 @@ import edu.gatech.gtri.bktree.MutableBkTree; * @author EVE */ public class RGrammar { + public String name; + /* The max distance between possible alternate rules. */ private static final int MAX_DISTANCE = 6; @@ -51,9 +53,6 @@ public class RGrammar { } } - /* The pattern for matching the name of a variable. */ - private static Pattern NAMEVAR_PATTERN = Pattern.compile("\\$(\\w+)"); - /* The rules of the grammar. */ private Map rules; /* The rules imported from other grammars. */ @@ -163,7 +162,7 @@ public class RGrammar { if(rl.doRecur()) { RuleCase start = rules.get(fromRule).getCase(state.rnd); - System.err.printf("\tFINE: Generating %s (from %s)\n", start, fromRule); + System.err.printf("\tFINE: Generating %s (from %s in %s)\n", start, fromRule, name); generateCase(start, state); @@ -266,7 +265,7 @@ public class RGrammar { if (initRule.equals("")) { throw new GrammarException("The empty string is not a valid rule name"); } else if (!rules.containsKey(initRule)) { - String msg = String.format("No rule '%s' local to this grammar defined.", initRule); + String msg = String.format("No rule '%s' local to this grammar (%s) defined.", initRule, name); throw new GrammarException(msg); } @@ -286,7 +285,8 @@ public class RGrammar { for (String rname : exportRules) { if (!rules.containsKey(rname)) { - String msg = String.format("No rule '%s' local to this grammar defined", initialRule); + String msg = String.format("No rule '%s' local to this grammar (%s) defined for export", + name, rname); throw new GrammarException(msg); } -- cgit v1.2.3