diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-06-04 16:47:54 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-06-04 16:47:54 -0300 |
| commit | 3b760ca916c6a88265e348d77ee1f6497dace0a4 (patch) | |
| tree | 5d05409b79a9b585276722a54e7a70b7468374f5 /src/main/java/bjc/rgens/parser/RGrammarBuilder.java | |
| parent | 2ca83db4239ea46572910baf0358e3f8608a3610 (diff) | |
Add line offset
Blocks should now properly give absolute numbers as to where they are
from
Diffstat (limited to 'src/main/java/bjc/rgens/parser/RGrammarBuilder.java')
| -rwxr-xr-x | src/main/java/bjc/rgens/parser/RGrammarBuilder.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main/java/bjc/rgens/parser/RGrammarBuilder.java b/src/main/java/bjc/rgens/parser/RGrammarBuilder.java index 20cba93..59f3a4c 100755 --- a/src/main/java/bjc/rgens/parser/RGrammarBuilder.java +++ b/src/main/java/bjc/rgens/parser/RGrammarBuilder.java @@ -272,9 +272,23 @@ public class RGrammarBuilder { newCaseList.add(new Pair<>(cse.getLeft(), new FlatRuleCase(cse.getRight().getElements()))); } + System.err.printf("\tTRACE: Despacing %d cases of rule %s\n", caseList.getSize(), ruleName); + rules.get(ruleName).replaceCases(newCaseList); } + public void setWeight(String ruleName) { + if (ruleName == null) { + throw new NullPointerException("ruleName must not be null"); + } else if (ruleName.equals("")) { + throw new IllegalArgumentException("The empty string is not a valid rule name"); + } else if (!rules.containsKey(ruleName)) { + throw new IllegalArgumentException(String.format("The rule '%s' doesn't exist", ruleName)); + } + + rules.get(ruleName).prob = Rule.ProbType.NORMAL; + } + public void setRuleRecur(String ruleName, int recurLimit) { if (ruleName == null) { throw new NullPointerException("ruleName must not be null"); @@ -286,6 +300,39 @@ public class RGrammarBuilder { rules.get(ruleName).recurLimit = recurLimit; } + + public void setDescent(String ruleName, int descentFactor) { + if (ruleName == null) { + throw new NullPointerException("ruleName must not be null"); + } else if (ruleName.equals("")) { + throw new IllegalArgumentException("The empty string is not a valid rule name"); + } else if (!rules.containsKey(ruleName)) { + throw new IllegalArgumentException(String.format("The rule '%s' doesn't exist", ruleName)); + } + + Rule rl = rules.get(ruleName); + + rl.prob = Rule.ProbType.DESCENDING; + rl.descentFactor = descentFactor; + } + + public void setBinomial(String ruleName, int target, int bound, int trials) { + if (ruleName == null) { + throw new NullPointerException("ruleName must not be null"); + } else if (ruleName.equals("")) { + throw new IllegalArgumentException("The empty string is not a valid rule name"); + } else if (!rules.containsKey(ruleName)) { + throw new IllegalArgumentException(String.format("The rule '%s' doesn't exist", ruleName)); + } + + Rule rl = rules.get(ruleName); + + rl.prob = Rule.ProbType.BINOMIAL; + + rl.target = target; + rl.bound = bound; + rl.trials = trials; + } /* * @TODO * |
