Skip to content

Commit

Permalink
booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmindlin committed Jun 16, 2024
1 parent 5decb00 commit 75e73eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scout-interpreter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn eval_expression<'a>(
let res = eval_op(l_obj.clone(), op, r_obj.clone())?;
Ok(res)
}
_ => Err(EvalError::InvalidExpr),
ExprKind::Boolean(val) => Ok(Arc::new(Object::Boolean(*val))),
}
}
.boxed()
Expand Down
4 changes: 4 additions & 0 deletions scout-lexer/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pub enum TokenKind {
Goto,
Scrape,
Screenshot,
True,
False,
}

impl TokenKind {
Expand All @@ -43,6 +45,8 @@ impl TokenKind {
"goto" => Some(Goto),
"scrape" => Some(Scrape),
"screenshot" => Some(Screenshot),
"true" => Some(True),
"false" => Some(False),
_ => None,
}
}
Expand Down
2 changes: 2 additions & 0 deletions scout-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ impl Parser {

fn parse_single_expr(&mut self) -> ParseResult<ExprKind> {
let lhs = match self.curr.kind {
TokenKind::False => Ok(ExprKind::Boolean(false)),
TokenKind::True => Ok(ExprKind::Boolean(true)),
TokenKind::Ident => {
// Parse multiple types of ident expressions
match self.peek.kind {
Expand Down

0 comments on commit 75e73eb

Please sign in to comment.