Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmindlin committed Jun 11, 2024
1 parent 4a52098 commit 56d730a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
6 changes: 6 additions & 0 deletions scout-interpreter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::thread::sleep;
use std::time::Duration;
use std::{collections::HashMap, sync::Arc};

use env::EnvPointer;
Expand Down Expand Up @@ -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) => {
Expand Down
8 changes: 7 additions & 1 deletion scout-lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions scout-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ pub mod ast;

type ParseResult<T> = Result<T, ParseError>;

#[derive(Debug, PartialOrd, Ord, PartialEq, Eq)]
pub enum Precedence {
Lowest,
Equals,
LessGreater,
Sum,
Product,
Prefix,
Call,
Index,
}

impl From<TokenKind> 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),
Expand Down

0 comments on commit 56d730a

Please sign in to comment.