aboutsummaryrefslogtreecommitdiff
path: root/matlab/+types
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-03-02 13:04:44 -0600
committerJoel Martin <github@martintribe.org>2015-03-02 13:04:44 -0600
commit751ab516f1ecb639543ba99363afb85bf1aa2e62 (patch)
tree1e88d56cff5d36fc6ccaf35904988b25a5d40d5b /matlab/+types
parent334a71b60745998663ebbbeea5b0c66f9aca5e13 (diff)
downloadmal-751ab516f1ecb639543ba99363afb85bf1aa2e62.tar.gz
mal-751ab516f1ecb639543ba99363afb85bf1aa2e62.zip
matlab: move Reader.m to +types/Reader.m
Fixes https://github.com/kanaka/mal/issues/18 for case insensitive file-systems.
Diffstat (limited to 'matlab/+types')
-rw-r--r--matlab/+types/Reader.m27
1 files changed, 27 insertions, 0 deletions
diff --git a/matlab/+types/Reader.m b/matlab/+types/Reader.m
new file mode 100644
index 0000000..c18ea54
--- /dev/null
+++ b/matlab/+types/Reader.m
@@ -0,0 +1,27 @@
+classdef Reader < handle
+ properties
+ tokens
+ position
+ end
+ methods
+ function rdr = Reader(tokens)
+ rdr.tokens = tokens;
+ rdr.position = 1;
+ end
+ function tok = next(rdr)
+ rdr.position = rdr.position + 1;
+ if rdr.position-1 > length(rdr.tokens)
+ tok = false;
+ else
+ tok = rdr.tokens{rdr.position-1};
+ end
+ end
+ function tok = peek(rdr)
+ if rdr.position > length(rdr.tokens)
+ tok = false;
+ else
+ tok = rdr.tokens{rdr.position};
+ end
+ end
+ end
+end