diff --git a/runtime/Java/src/org/antlr/v4/runtime/SymbolStream.java b/runtime/Java/src/org/antlr/v4/runtime/SymbolStream.java index 4c801b1dc..fcab38a0f 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/SymbolStream.java +++ b/runtime/Java/src/org/antlr/v4/runtime/SymbolStream.java @@ -31,19 +31,21 @@ package org.antlr.v4.runtime; /** A stream of either tokens or tree nodes */ public interface SymbolStream extends IntStream { - /** Get an object at absolute index i; 0..n-1. + /** Get the symbol at absolute index i; 0..n-1. * This is only valid if the underlying stream implementation buffers * all of the incoming objects. + * + * @throws UnsupportedOperationException if the index {@code i} is outside + * the marked region and the stream does not support accessing symbols by + * index outside of marked regions. */ public T get(int i); - /** Get Object at current input pointer + i ahead where i=1 is next Object. - * i<0 indicates Objects in the past. So -1 is previous Object and -2 is - * two Objects ago. LT(0) is undefined. For i>=n, return an - * object representing EOF. Return null for LT(0) and any index that - * results in an absolute index that is negative. - * - * TODO (Sam): throw exception for invalid k? + /** Get symbol at current input pointer + {@code k} ahead where {@code k=1} + * is next symbol. k<0 indicates objects in the past. So -1 is previous + * Object and -2 is two Objects ago. {@code LT(0)} is undefined. For i>=n, + * return an object representing EOF. Return {@code null} for {@code LT(0)} + * and any index that results in an absolute index that is negative. */ T LT(int k); }