Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: petitparser/lib/src/core/context.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « petitparser/lib/src/core/composite.dart ('k') | petitparser/lib/src/core/definition.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: petitparser/lib/src/core/context.dart
diff --git a/petitparser/lib/src/core/context.dart b/petitparser/lib/src/core/context.dart
deleted file mode 100644
index f9cac843322ec866363b1f036ef2c211e5c76fb1..0000000000000000000000000000000000000000
--- a/petitparser/lib/src/core/context.dart
+++ /dev/null
@@ -1,119 +0,0 @@
-part of petitparser;
-
-/**
- * An immutable parse context.
- */
-class Context {
- const Context(this.buffer, this.position);
-
- /**
- * The buffer we are working on.
- */
- final buffer;
-
- /**
- * The current position in the buffer.
- */
- final int position;
-
- /**
- * Returns a result indicating a parse success.
- */
- Result success(result, [int position]) {
- return new Success(buffer, position == null ? this.position : position, result);
- }
-
- /**
- * Returns a result indicating a parse failure.
- */
- Result failure(String message, [int position]) {
- return new Failure(buffer, position == null ? this.position : position, message);
- }
-
- /**
- * Returns a human readable string of the current context.
- */
- String toString() => 'Context[${toPositionString()}]';
-
- /**
- * Returns the line:column if the input is a string, otherwise the position.
- */
- String toPositionString() => Token.positionString(buffer, position);
-}
-
-/**
- * An immutable parse result.
- */
-abstract class Result extends Context {
- const Result(buffer, position) : super(buffer, position);
-
- /**
- * Returns [true] if this result indicates a parse success.
- */
- bool get isSuccess => false;
-
- /**
- * Returns [true] if this result indicates a parse failure.
- */
- bool get isFailure => false;
-
- /**
- * Returns the parse result of the current context.
- */
- get value;
-
- /**
- * Returns the parse message of the current context.
- */
- String get message;
-}
-
-/**
- * An immutable parse result in case of a successful parse.
- */
-class Success extends Result {
- const Success(buffer, position, this.value) : super(buffer, position);
-
- @override
- bool get isSuccess => true;
-
- @override
- final value;
-
- @override
- String get message => null;
-
- @override
- String toString() => 'Success[${toPositionString()}]: $value';
-}
-
-/**
- * An immutable parse result in case of a failed parse.
- */
-class Failure extends Result {
- const Failure(buffer, position, this.message) : super(buffer, position);
-
- @override
- bool get isFailure => true;
-
- @override
- get value => throw new ParserError(this);
-
- @override
- final String message;
-
- @override
- String toString() => 'Failure[${toPositionString()}]: $message';
-}
-
-/**
- * An exception raised in case of a parse error.
- */
-class ParserError extends Error {
- final Failure failure;
-
- ParserError(this.failure);
-
- @override
- String toString() => '${failure.message} at ${failure.toPositionString()}';
-}
« no previous file with comments | « petitparser/lib/src/core/composite.dart ('k') | petitparser/lib/src/core/definition.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698