Package net.hydromatic.morel.ast
Class Pos
- java.lang.Object
-
- net.hydromatic.morel.ast.Pos
-
public class Pos extends Object
Position of a parse-tree node.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringBuilderdescribeTo(StringBuilder buf)booleanequals(Object o)inthashCode()private static org.apache.calcite.util.mapping.IntPairlineCol(String s, int offset)Returns the 1-based line.static Posof(String ml, String file, int startOffset, int endOffset)Creates a Pos from two offsets.Posplus(Pos pos)PosplusAll(Iterable<Pos> poses)PosplusAll(List<? extends AstNode> nodes)static org.apache.calcite.util.Pair<@NonNull String,@NonNull Pos>split(String s, char delimiter, String file)Creates a Pos from a filename and a string with a delimiter character.static <E> Possum(Iterable<E> elements, Function<E,Pos> fn)static Possum(Iterable<Pos> poses)Combines an iterable of parser positions to create a position which spans from the beginning of the first to the end of the last.private static Possum(Iterable<Pos> poses, int line, int column, int endLine, int endColumn)Computes the parser position which is the sum of an array of parser positions and of a parser position represented by (line, column, endLine, endColumn).static Possum(List<? extends AstNode> nodes)private static Possum_(List<Pos> positions)Combines a list of parser positions to create a position which spans from the beginning of the first to the end of the last.StringtoString()
-
-
-
Constructor Detail
-
Pos
public Pos(String file, int startLine, int startColumn, int endLine, int endColumn)
Creates a Pos.
-
-
Method Detail
-
of
public static Pos of(String ml, String file, int startOffset, int endOffset)
Creates a Pos from two offsets.
-
split
public static org.apache.calcite.util.Pair<@NonNull String,@NonNull Pos> split(String s, char delimiter, String file)
Creates a Pos from a filename and a string with a delimiter character. The delimiter must occur exactly twice in the string.
-
describeTo
public StringBuilder describeTo(StringBuilder buf)
-
sum
public static Pos sum(Iterable<Pos> poses)
Combines an iterable of parser positions to create a position which spans from the beginning of the first to the end of the last.
-
sum_
private static Pos sum_(List<Pos> positions)
Combines a list of parser positions to create a position which spans from the beginning of the first to the end of the last.
-
sum
private static Pos sum(Iterable<Pos> poses, int line, int column, int endLine, int endColumn)
Computes the parser position which is the sum of an array of parser positions and of a parser position represented by (line, column, endLine, endColumn).- Parameters:
poses- Array of parser positionsline- Start linecolumn- Start columnendLine- End lineendColumn- End column- Returns:
- Sum of parser positions
-
lineCol
private static org.apache.calcite.util.mapping.IntPair lineCol(String s, int offset)
Returns the 1-based line.
-
-