-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtokenExtr.m
49 lines (38 loc) · 1.41 KB
/
tokenExtr.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [tok,newPos] = tokenExtr(inpTok,pos)
switch inpTok(pos:pos)
case {'(','{',')','}','/','\','>','<','!','=','^',',','D',';','|'}
tok = inpTok(pos:pos);
newPos = pos +1;
case {'U','G','E','L','S','C','F','P','B','#'}
if(inpTok(pos+1:pos+1)=='[')
k = strfind(inpTok,']');
i=1;
while (i<=length(k) && (k(i)<(pos+1)) )
i=i+1;
end
tok = inpTok(pos:k(i));
newPos = k(i) +1;
else
tok = inpTok(pos:pos);
newPos = pos +1;
end
case {'0','1','2','3','4','5','6','7','8','9','.','-','+'}
i = pos;
% curChar = inpTok(i:i);
while(inpTok(i:i)~=',' && inpTok(i:i)~=')' && inpTok(i:i)~=';')
i=i+1;
% curChar = inpTok(i:i);
end
tok = inpTok(pos:i-1);
newPos = i;
case {'q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','Q','W','R','T','Y','I','O','A','H','J','K','Z','X','V','N','M'}
i = pos;
% curChar = inpTok(i:i);
while(inpTok(i:i)~='<' && inpTok(i:i)~='>' && inpTok(i:i)~=',')
i=i+1;
end
tok = inpTok(pos:i-1);
newPos = i;
otherwise
end
end