seems to be able to parse signal tree

This commit is contained in:
Yehowshua Immanuel 2022-07-14 16:46:11 -04:00
parent 49d103fd56
commit 8bcd2bc8ec
7 changed files with 611 additions and 54 deletions

View file

@ -1,4 +1,5 @@
use super::types::ParseResult;
use super::reader::WordReader;
pub(super) fn digit(chr : u8) -> bool {
let zero = b'0' as u8;
@ -82,3 +83,22 @@ pub(super) fn tag<'a>(word : &'a str, pattern : &'a str) -> ParseResult<'a> {
residual : &word[new_start..]
};
}
pub(super) fn ident(
word_reader : &mut WordReader,
keyword : &str,
) -> Result<(), String> {
// let keyword = "module";
let err : Result<(), String> = Err(format!("reached end of file without parser leaving ident"));
let word = word_reader.next_word();
let (word, cursor) = word.ok_or(err).unwrap();
if word == keyword {
return Ok(())
}
else {
let err = format!("found keyword `{word}` but expected `{keyword}` on {cursor:?}");
return Err(err)
}
}