Simplify lexer/parser structure to use stdio_reader.

This commit is contained in:
Graydon Hoare 2010-08-18 15:41:13 -07:00
parent f0d4e6c511
commit 4727532e95
4 changed files with 35 additions and 32 deletions

View file

@ -1,3 +1,25 @@
import std._io;
state type parser =
state obj {
state fn peek() -> token.token;
state fn bump();
};
fn new_parser(str path) -> parser {
state obj stdio_parser(mutable token.token tok,
_io.stdio_reader rdr)
{
state fn peek() -> token.token {
ret tok;
}
state fn bump() {
tok = lexer.next_token(rdr);
}
}
auto rdr = _io.new_stdio_reader(path);
ret stdio_parser(lexer.next_token(rdr), rdr);
}
//
// Local Variables: