Dart DocumentationparsersPosition

Position class

class Position {
 final int line;
 final int character;
 final int offset;

 const Position(this.offset, this.line, this.character);

 Position addChar(String c) {
   assert(c.length == 1);
   final isNewLine = c == '\n';
   return new Position(
       offset + 1,
       line + (isNewLine ? 1 : 0),
       isNewLine ? 1 : character + 1);
 }

 bool operator <(Position p) => offset < p.offset;
 bool operator >(Position p) => offset > p.offset;

 String toString() => '(line $line, char $character, offset $offset)';
}

Constructors

const Position(int offset, int line, int character) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
const Position(this.offset, this.line, this.character);

Properties

final int character #

final int character

final int line #

final int line

final int offset #

final int offset

Operators

bool operator <(Position p) #

bool operator <(Position p) => offset < p.offset;

bool operator >(Position p) #

bool operator >(Position p) => offset > p.offset;

Methods

Position addChar(String c) #

Position addChar(String c) {
 assert(c.length == 1);
 final isNewLine = c == '\n';
 return new Position(
     offset + 1,
     line + (isNewLine ? 1 : 0),
     isNewLine ? 1 : character + 1);
}

String toString() #

Returns a string representation of this object.

docs inherited from Object
String toString() => '(line $line, char $character, offset $offset)';