@Override public Sequence flatten(Map<Sequence, Sequence> map, Map<Sequence, List<Fixup>> map2) { Sequence result = map.get(this); if (result == null) { result = new Sequence(new Symbol[flattenedSize()]); map.put(this, result); List<Fixup> l = new ArrayList<Fixup>(); map2.put(result, l); flatten(production, 0, result.production, 0, map, map2); for (Fixup f : l) { System.arraycopy(result.production, 0, f.symbols, f.pos, result.production.length); } map2.remove(result); } return result; }
/** * Returns the amount of space required to flatten the given * sub-array of symbols. * @param symbols The array of input symbols. * @param start The index where the subarray starts. * @return The number of symbols that will be produced if one expands * the given input. */ protected static int flattenedSize(Symbol[] symbols, int start) { int result = 0; for (int i = start; i < symbols.length; i++) { if (symbols[i] instanceof Sequence) { Sequence s = (Sequence) symbols[i]; result += s.flattenedSize(); } else { result += 1; } } return result; }
/** * Returns the amount of space required to flatten the given * sub-array of symbols. * @param symbols The array of input symbols. * @param start The index where the subarray starts. * @return The number of symbols that will be produced if one expands * the given input. */ protected static int flattenedSize(Symbol[] symbols, int start) { int result = 0; for (int i = start; i < symbols.length; i++) { if (symbols[i] instanceof Sequence) { Sequence s = (Sequence) symbols[i]; result += s.flattenedSize(); } else { result += 1; } } return result; }
/** * Returns the amount of space required to flatten the given * sub-array of symbols. * @param symbols The array of input symbols. * @param start The index where the subarray starts. * @return The number of symbols that will be produced if one expands * the given input. */ protected static int flattenedSize(Symbol[] symbols, int start) { int result = 0; for (int i = start; i < symbols.length; i++) { if (symbols[i] instanceof Sequence) { Sequence s = (Sequence) symbols[i]; result += s.flattenedSize(); } else { result += 1; } } return result; }
/** * Returns the amount of space required to flatten the given * sub-array of symbols. * @param symbols The array of input symbols. * @param start The index where the subarray starts. * @return The number of symbols that will be produced if one expands * the given input. */ protected static int flattenedSize(Symbol[] symbols, int start) { int result = 0; for (int i = start; i < symbols.length; i++) { if (symbols[i] instanceof Sequence) { Sequence s = (Sequence) symbols[i]; result += s.flattenedSize(); } else { result += 1; } } return result; }
@Override public Sequence flatten(Map<Sequence, Sequence> map, Map<Sequence, List<Fixup>> map2) { Sequence result = map.get(this); if (result == null) { result = new Sequence(new Symbol[flattenedSize()]); map.put(this, result); List<Fixup> l = new ArrayList<Fixup>(); map2.put(result, l); flatten(production, 0, result.production, 0, map, map2); for (Fixup f : l) { System.arraycopy(result.production, 0, f.symbols, f.pos, result.production.length); } map2.remove(result); } return result; }
@Override public Sequence flatten(Map<Sequence, Sequence> map, Map<Sequence, List<Fixup>> map2) { Sequence result = map.get(this); if (result == null) { result = new Sequence(new Symbol[flattenedSize()]); map.put(this, result); List<Fixup> l = new ArrayList<Fixup>(); map2.put(result, l); flatten(production, 0, result.production, 0, map, map2); for (Fixup f : l) { System.arraycopy(result.production, 0, f.symbols, f.pos, result.production.length); } map2.remove(result); } return result; }
@Override public Sequence flatten(Map<Sequence, Sequence> map, Map<Sequence, List<Fixup>> map2) { Sequence result = map.get(this); if (result == null) { result = new Sequence(new Symbol[flattenedSize()]); map.put(this, result); List<Fixup> l = new ArrayList<Fixup>(); map2.put(result, l); flatten(production, 0, result.production, 0, map, map2); for (Fixup f : l) { System.arraycopy(result.production, 0, f.symbols, f.pos, result.production.length); } map2.remove(result); } return result; }
@Override public Sequence flatten(Map<Sequence, Sequence> map, Map<Sequence, List<Fixup>> map2) { Sequence result = map.get(this); if (result == null) { result = new Sequence(new Symbol[flattenedSize()]); map.put(this, result); List<Fixup> l = new ArrayList<Fixup>(); map2.put(result, l); flatten(production, 0, result.production, 0, map, map2); for (Fixup f : l) { System.arraycopy(result.production, 0, f.symbols, f.pos, result.production.length); } map2.remove(result); } return result; }
@Override public final int flattenedSize() { return flattenedSize(production, 0); } }
/** * A convenience method to construct a sequence. * @param production The constituent symbols of the sequence. */ static Symbol seq(Symbol... production) { return new Sequence(production); }
/** * A convenience method to construct a sequence. * @param production The constituent symbols of the sequence. */ static Symbol seq(Symbol... production) { return new Sequence(production); }
@Override public final int flattenedSize() { return flattenedSize(production, 0); } }
@Override public final int flattenedSize() { return flattenedSize(production, 0); } }
@Override public final int flattenedSize() { return flattenedSize(production, 0); } }
/** * A convenience method to construct a sequence. * @param production The constituent symbols of the sequence. */ static Symbol seq(Symbol... production) { return new Sequence(production); }
/** * A convenience method to construct a sequence. * @param production The constituent symbols of the sequence. */ static Symbol seq(Symbol... production) { return new Sequence(production); }
/** * Returns the amount of space required to flatten the given * sub-array of symbols. * @param symbols The array of input symbols. * @param start The index where the subarray starts. * @return The number of symbols that will be produced if one expands * the given input. */ protected static int flattenedSize(Symbol[] symbols, int start) { int result = 0; for (int i = start; i < symbols.length; i++) { if (symbols[i] instanceof Sequence) { Sequence s = (Sequence) symbols[i]; result += s.flattenedSize(); } else { result += 1; } } return result; }
/** * Returns the amount of space required to flatten the given * sub-array of symbols. * @param symbols The array of input symbols. * @param start The index where the subarray starts. * @return The number of symbols that will be produced if one expands * the given input. */ protected static int flattenedSize(Symbol[] symbols, int start) { int result = 0; for (int i = start; i < symbols.length; i++) { if (symbols[i] instanceof Sequence) { Sequence s = (Sequence) symbols[i]; result += s.flattenedSize(); } else { result += 1; } } return result; }
@Override public Sequence flatten(Map<Sequence, Sequence> map, Map<Sequence, List<Fixup>> map2) { Sequence result = map.get(this); if (result == null) { result = new Sequence(new Symbol[flattenedSize()]); map.put(this, result); List<Fixup> l = new ArrayList<>(); map2.put(result, l); flatten(production, 0, result.production, 0, map, map2); for (Fixup f : l) { System.arraycopy(result.production, 0, f.symbols, f.pos, result.production.length); } map2.remove(result); } return result; }