Dart DocumentationpetitparserResult

Result abstract class

An immutable parse result.

abstract class Result extends Context {

 const Result(buffer, position) : super(buffer, position);

 dynamic get result => value;

 /** Returns the parse result of the current context. */
 dynamic get value;

 /** Returns the parse message of the current context. */
 String get message;


}

Extends

Context > Result

Subclasses

Failure, Success

Constructors

const Result(buffer, position) #

const Result(buffer, position) : 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 #

inherited from Context

Returns true if this result indicates a parse success.

bool get isSuccess => false;

final String message #

Returns the parse message of the current context.

String get message;

final int position #

inherited from Context

The current position in the buffer.

int get position => _position;

final result #

dynamic get result => value;

final value #

Returns the parse result of the current context.

dynamic get 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() #

inherited from Context

Returns a human readable string of the current context

String toString() => 'Context[${toPositionString()}]';