diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-06-05 13:50:31 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-06-05 13:50:31 -0300 |
| commit | 0164b842d14675b0a28dd143d36923e690e75d27 (patch) | |
| tree | f78674448a6ddf7acabf344d8f558adc2608b578 /src/main/java/bjc/rgens/parser/RGrammar.java | |
| parent | a3da25a2988bab62a565a7cd2422a3150b85cbb5 (diff) | |
Config work
More work for getting going on templates, as well as just some
refactoring for future changes
Diffstat (limited to 'src/main/java/bjc/rgens/parser/RGrammar.java')
| -rwxr-xr-x | src/main/java/bjc/rgens/parser/RGrammar.java | 12 |
1 files changed, 6 insertions, 6 deletions
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<String, Rule> 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); } |
