Simplify lexer/parser structure to use stdio_reader.
This commit is contained in:
parent
f0d4e6c511
commit
4727532e95
4 changed files with 35 additions and 32 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue