blob: eac0a54277abd350dcc5270b79e1a793b5900f09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// A hypothetical scanner class
struct _Scan {
int !x;
u8[~] buf;
new _Scan={ u8[~] b -> buf=b; };
// Skip whitespace
val skip = { ->
while( buf[x] <= ' ' )
x++;
};
// Peek a character; if matched consume it, else false.
val peek = { u8 c ->
skip();
if( buf[x] != c ) return false;
x++;
return true;
};
};
!_Scan !s = new _Scan(" q");
return s.peek('q');
|