implement String.nth and OS.time in stdlib

This commit is contained in:
2025-06-29 16:10:39 +02:00
parent 21cac533f2
commit 62dd8b0d52
6 changed files with 37 additions and 90 deletions

View File

@@ -37,10 +37,6 @@ pub enum Stmt {
body: Box<Stmt>,
},
Return(Expr),
Assert {
keyword: Token,
value: Expr,
},
}
#[derive(Debug, Clone)]
@@ -197,11 +193,6 @@ impl Parser {
self.for_statement()
} else if self.match_token(&[TokenType::KeywordReturn]) {
Ok(Stmt::Return(self.expression()?))
} else if self.match_token(&[TokenType::KeywordAssert]) {
Ok(Stmt::Assert {
keyword: self.previous().clone(),
value: self.expression()?,
})
} else {
Ok(Stmt::Expression(self.expression()?))
}
@@ -490,7 +481,8 @@ impl Parser {
fn consume(&mut self, token_type: TokenType, message: &str) -> Result<Token, ZernError> {
if self.check(&token_type) {
Ok(self.advance().clone())
self.current += 1;
Ok(self.previous().clone())
} else {
error!(self.previous().loc, format!("{}", message))
}
@@ -499,7 +491,7 @@ impl Parser {
fn match_token(&mut self, token_types: &[TokenType]) -> bool {
for x in token_types {
if self.check(x) {
self.advance();
self.current += 1;
return true;
}
}
@@ -514,13 +506,6 @@ impl Parser {
}
}
fn advance(&mut self) -> &Token {
if !self.eof() {
self.current += 1;
}
self.previous()
}
fn peek(&self) -> &Token {
&self.tokens[self.current]
}