summaryrefslogtreecommitdiff
path: root/src/cli/runtime/LineNumberingTextReader.cs
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2006-06-02 02:21:52 +0000
committerRich Hickey <richhickey@gmail.com>2006-06-02 02:21:52 +0000
commit11461aa4fd81e05305ec84ed8747666e3d165fb9 (patch)
treec1f94a277d7f9f5a6f76f80d0aaa1924de0ec113 /src/cli/runtime/LineNumberingTextReader.cs
parent08e27be5bba0400b651ed7877e72ff48bbdd6ccc (diff)
added support for reader
Diffstat (limited to 'src/cli/runtime/LineNumberingTextReader.cs')
-rw-r--r--src/cli/runtime/LineNumberingTextReader.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/cli/runtime/LineNumberingTextReader.cs b/src/cli/runtime/LineNumberingTextReader.cs
new file mode 100644
index 00000000..5238c6e8
--- /dev/null
+++ b/src/cli/runtime/LineNumberingTextReader.cs
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) Rich Hickey. All rights reserved.
+ * The use and distribution terms for this software are covered by the
+ * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+ * which can be found in the file CPL.TXT at the root of this distribution.
+ * By using this software in any fashion, you are agreeing to be bound by
+ * the terms of this license.
+ * You must not remove this notice, or any other, from this software.
+ **/
+
+using System;
+using System.IO;
+
+namespace org.clojure.runtime
+ {
+
+
+public class LineNumberingTextReader : TextReader, IDisposable
+ {
+ TextReader impl;
+ int line = 0;
+
+ public LineNumberingTextReader(TextReader r){
+ this.impl = r;
+ }
+
+ public int getLineNumber(){
+ return line;
+ }
+
+ override public int Read(){
+ int ret = impl.Read();
+ if(ret == '\n')
+ ++line;
+ return ret;
+ }
+
+ override public int Peek(){
+ return impl.Peek();
+ }
+
+ public override void Close()
+ {
+ base.Close();
+ impl.Close();
+ }
+
+ void IDisposable.Dispose()
+ {
+ base.Dispose();
+ impl.Dispose();
+ }
+
+ }
+
+
+ }