implement Yak;
include "yak.m";
Lexeme.to_string(lex : self ref Lexeme) : string
{
pick x := lex {
Function =>
return sys->sprint("Function %s", x.name);
Expr =>
return sys->sprint("Expr = %s", x.value);
}
}
parse(b : ref Iobuf)
{
sys = load Sys Sys->PATH;
bufio = load Bufio Bufio->PATH;
c := chan of ref Lexeme;
spawn lex(b, c);
}
lex(b : ref Iobuf, c : chan of ref Lexeme)
{
r : int;
while(r = b.getc() > 0) {
case r {
' ' or '\t' or '\n' or '\r' =>
;
* => sys->print("%c", r);
}
}
}
|