Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-math committed Nov 25, 2023
1 parent ff37ae0 commit 51c7c59
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 192 deletions.
21 changes: 12 additions & 9 deletions TokenList.m
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
classdef TokenList
classdef TokenList < handle
properties
tokens
i = 1;
end

methods
function self = TokenList(tokens)
self.tokens = tokens;
end
function subs = subsref(self, subs, varargin)
if strcmp(subs(1).type, '()')
assert(numel(subs(1).subs) == 1 && numel(subs(1).subs{1}) == 1);
subs = builtin('subsref', self.tokens, subs);
else
subs = builtin('subsref', self, subs);
end
end
function n = numel(self, varargin)
if ~isempty(varargin)
n = 1;
else
n = numel(self.tokens);
end
end
function next(self)
self.i = self.i + 1;
end
function v = get(self)
if self.i > numel(self.tokens)
v = [];
else
v = self.tokens(self.i);
end
end
end
end

Loading

0 comments on commit 51c7c59

Please sign in to comment.