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;
}
Constructors
const Position(int offset, int line, int 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);
}