MCPcopy Create free account
hub / github.com/antlr/antlr4 / removeOne

Method removeOne

runtime/JavaScript/src/antlr4/misc/IntervalSet.js:141–173  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

139 }
140
141 removeOne(value) {
142 if (this.intervals !== null) {
143 for (let i = 0; i < this.intervals.length; i++) {
144 const existing = this.intervals[i];
145 // intervals are ordered
146 if (value < existing.start) {
147 return;
148 }
149 // check for single value range
150 else if (value === existing.start && value === existing.stop - 1) {
151 this.intervals.splice(i, 1);
152 return;
153 }
154 // check for lower boundary
155 else if (value === existing.start) {
156 this.intervals[i] = new Interval(existing.start + 1, existing.stop);
157 return;
158 }
159 // check for upper boundary
160 else if (value === existing.stop - 1) {
161 this.intervals[i] = new Interval(existing.start, existing.stop - 1);
162 return;
163 }
164 // split existing range
165 else if (value < existing.stop - 1) {
166 const replace = new Interval(existing.start, value);
167 existing.start = value + 1;
168 this.intervals.splice(i, 0, replace);
169 return;
170 }
171 }
172 }
173 }
174
175 toString(literalNames, symbolicNames, elemsAreChar) {
176 literalNames = literalNames || null;

Callers 3

getExpectedTokensMethod · 0.95
removeRangeMethod · 0.95
getErrorRecoverySetMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected