Class Pos

java.lang.Object
net.hydromatic.morel.ast.Pos

public class Pos extends Object
Position of a parse-tree node.
  • Field Details

    • ZERO

      public static final Pos ZERO
    • file

      public final String file
    • startLine

      public final int startLine
    • startColumn

      public final int startColumn
    • endLine

      public final int endLine
    • endColumn

      public final int endColumn
  • Constructor Details

    • Pos

      public Pos(String file, int startLine, int startColumn, int endLine, int endColumn)
      Creates a Pos.
  • Method Details

    • of

      public static Pos of(String ml, String file, int startOffset, int endOffset)
      Creates a Pos from two offsets.
    • split

      public static 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.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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

      public static <E> Pos sum(Iterable<E> elements, Function<E,Pos> fn)
    • sum

      public static Pos sum(List<? extends AstNode> nodes)
    • 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 positions
      line - Start line
      column - Start column
      endLine - End line
      endColumn - End column
      Returns:
      Sum of parser positions
    • plus

      public Pos plus(Pos pos)
    • plusAll

      public Pos plusAll(Iterable<Pos> poses)
    • plusAll

      public Pos plusAll(@Nonnull List<? extends AstNode> nodes)
    • lineCol

      private static org.apache.calcite.util.mapping.IntPair lineCol(String s, int offset)
      Returns the 1-based line.