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

Unified Diff: pkg/mustache/lib/char_reader.dart

Issue 804973002: Add appengine/gcloud/mustache dependencies. (Closed) Base URL: git@github.com:dart-lang/pub-dartlang-dart.git@master
Patch Set: Added AUTHORS/LICENSE/PATENTS files Created 6 years 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 | « pkg/mustache/check.sh ('k') | pkg/mustache/lib/mustache.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mustache/lib/char_reader.dart
diff --git a/pkg/mustache/lib/char_reader.dart b/pkg/mustache/lib/char_reader.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ff3a3f1bea67899e2a5f99babdb2c6b76404a53c
--- /dev/null
+++ b/pkg/mustache/lib/char_reader.dart
@@ -0,0 +1,65 @@
+part of mustache;
+
+class _CharReader {
+
+ String _source;
+ Iterator<int> _itr;
+ int _i, _c;
+ int _line = 1, _column = 1;
+
+ _CharReader(String source)
+ : _source = source,
+ _itr = source.runes.iterator { //FIXME runes etc. Not sure if this is the right count.
+
+ if (source == null)
+ throw new ArgumentError('Source is null.');
+
+ _i = 0;
+
+ if (source == '') {
+ _c = _EOF;
+ } else {
+ _itr.moveNext();
+ _c = _itr.current;
+ }
+ }
+
+ int get line => _line;
+ int get column => _column;
+
+ int read() {
+ var c = _c;
+ if (_itr.moveNext()) {
+ _i++;
+ _c = _itr.current;
+ } else {
+ _c = _EOF;
+ }
+
+ if (c == _NEWLINE) {
+ _line++;
+ _column = 1;
+ } else {
+ _column++;
+ }
+
+ return c;
+ }
+
+ int peek() => _c;
+
+ String readWhile(bool test(int charCode)) {
+
+ if (peek() == _EOF)
+ throw new MustacheFormatException('Unexpected end of input.', line, column);
+
+ int start = _i;
+
+ while (peek() != _EOF && test(peek())) {
+ read();
+ }
+
+ int end = peek() == _EOF ? _source.length : _i;
+ return _source.substring(start, end);
+ }
+}
« no previous file with comments | « pkg/mustache/check.sh ('k') | pkg/mustache/lib/mustache.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698