MCPcopy Create free account
hub / github.com/cschanck/single-file-java / ParentRule

Class ParentRule

src/main/java/org/sfj/PegLegParser.java:109–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107 }
108
109 public class ParentRule implements PegLegRule<V> {
110 private final PegLegRule<V> rule;
111 private Ref<?>[] refs = null;
112
113 public ParentRule(PegLegRule<V> rule) {
114 this.rule = rule;
115 }
116
117 public PegLegRule<V> refs(Ref<?>... refs) {
118 this.refs = refs;
119 return this;
120 }
121
122 @Override
123 public RuleReturn<V> rule() {
124 if (refs == null) { return rule.rule(); }
125 for (Ref<?> r : refs) { r.enterRef(); }
126 try {
127 return rule.rule();
128 } finally {
129 for (Ref<?> r : refs) { r.exitRef(); }
130 }
131 }
132 }
133
134 public static class SourcePosition {
135 int line = 1;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected