From 56d730a826de336360f50d9d3eef61a71b526326 Mon Sep 17 00:00:00 2001 From: Max Mindlin Date: Tue, 11 Jun 2024 09:52:35 -0400 Subject: [PATCH] progress --- scout-interpreter/src/lib.rs | 6 ++++++ scout-lexer/src/lib.rs | 8 +++++++- scout-parser/src/lib.rs | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/scout-interpreter/src/lib.rs b/scout-interpreter/src/lib.rs index a19245e..08f697e 100644 --- a/scout-interpreter/src/lib.rs +++ b/scout-interpreter/src/lib.rs @@ -1,3 +1,5 @@ +use std::thread::sleep; +use std::time::Duration; use std::{collections::HashMap, sync::Arc}; use env::EnvPointer; @@ -104,6 +106,10 @@ fn eval_statement<'a>( if crawler.goto(url.as_str()).await.is_err() { return Err(EvalError::InvalidUrl); }; + + // @TODO: Need a better way to determine that a page is "done" + sleep(Duration::from_secs(1)); + Ok(Arc::new(Object::Null)) } StmtKind::Scrape(defs) => { diff --git a/scout-lexer/src/lib.rs b/scout-lexer/src/lib.rs index c60da89..e054e52 100644 --- a/scout-lexer/src/lib.rs +++ b/scout-lexer/src/lib.rs @@ -27,7 +27,13 @@ impl Lexer { '}' => Token::new(RBrace, c.to_string()), ':' => Token::new(Colon, c.to_string()), ',' => Token::new(Comma, c.to_string()), - '=' => Token::new(Equal, c.to_string()), + '=' => match self.peek() { + Some('=') => { + self.next(); + Token::new(DbEqual, "==".to_string()) + } + _ => Token::new(Equal, '='.to_string()), + }, '"' => { let literal = self.read_string(); Token::new(Str, literal) diff --git a/scout-parser/src/lib.rs b/scout-parser/src/lib.rs index 370cfed..0b3c6e1 100644 --- a/scout-parser/src/lib.rs +++ b/scout-parser/src/lib.rs @@ -9,6 +9,31 @@ pub mod ast; type ParseResult = Result; +#[derive(Debug, PartialOrd, Ord, PartialEq, Eq)] +pub enum Precedence { + Lowest, + Equals, + LessGreater, + Sum, + Product, + Prefix, + Call, + Index, +} + +impl From for Precedence { + fn from(value: TokenKind) -> Self { + use TokenKind::*; + match value { + Equal => Self::Equals, + DbEqual => Self::Equals, + LParen => Self::Call, + Pipe => Self::Index, + _ => Self::Lowest, + } + } +} + #[derive(Debug)] pub enum ParseError { UnexpectedToken(TokenKind, TokenKind),