Dart DocumentationpetitparserSuccess

Success class

An immutable parse result in case of a successful parse.

class Success extends Result {

 final dynamic _value;

 const Success(buffer, position, this._value) : super(buffer, position);

 bool get isSuccess => true;

 dynamic get value => _value;

 String get message => null;

 String toString() => 'Success[${toPositionString()}]: $_value';

}

Extends

Context > Result > Success

Constructors

const Success(buffer, position, _value) #

const Success(buffer, position, this._value) : super(buffer, position);

Properties

final buffer #

inherited from Context

The buffer we are working on.

dynamic get buffer => _buffer;

final bool isFailure #

inherited from Context

Returns true if this result indicates a parse failure.

bool get isFailure => false;

final bool isSuccess #

Returns true if this result indicates a parse success.

docs inherited from Context
bool get isSuccess => true;

final String message #

Returns the parse message of the current context.

docs inherited from Result
String get message => null;

final int position #

inherited from Context

The current position in the buffer.

int get position => _position;

final result #

inherited from Result
dynamic get result => value;

final value #

Returns the parse result of the current context.

docs inherited from Result
dynamic get value => _value;

Methods

Result failure(String message, [int position]) #

inherited from Context

Returns a result indicating a parse failure.

Result failure(String message, [int position]) {
 return new Failure(_buffer, position == null ? _position : position, message);
}

Result success(result, [int position]) #

inherited from Context

Returns a result indicating a parse success.

Result success(dynamic result, [int position]) {
 return new Success(_buffer, position == null ? _position : position, result);
}

String toPositionString() #

inherited from Context
String toPositionString() {
 if (_buffer is String) {
   var lineAndColumn = Token.lineAndColumnOf(buffer, position);
   return '${lineAndColumn[0]}:${lineAndColumn[1]}';
 } else {
   return '${position}';
 }
}

String toString() #

Returns a human readable string of the current context

docs inherited from Context
String toString() => 'Success[${toPositionString()}]: $_value';