diff --git a/src/ast.rs b/src/ast.rs index 434a246..a864317 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1,9 +1,22 @@ +//! AbleScript's Abstract Syntax tree +//! +//! Statements are the type which is AST made of, as they +//! express an effect. +//! +//! Expressions are just operations and they cannot be +//! used as statements. Functions in AbleScript are in fact +//! just plain subroutines and they do not return any value, +//! so their calls are statements. + use crate::variables::Value; type Span = std::ops::Range; #[derive(Debug)] -pub struct Iden(String); +pub struct Iden { + pub iden: String, + pub span: Span, +} #[derive(Debug)] pub struct Block { @@ -64,13 +77,14 @@ pub struct Expr { #[derive(Debug)] pub enum ExprKind { - Binary { + BinOp { lhs: Box, rhs: Box, kind: BinOpKind, }, Not(Box), Literal(Value), + Variable(String), } impl Expr { diff --git a/src/error.rs b/src/error.rs index 2d2a354..bd15001 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,7 +5,7 @@ use crate::brian::InterpretError; #[derive(Debug, Clone)] pub struct Error { pub kind: ErrorKind, - pub position: Range, + pub span: Range, } #[derive(Debug, Clone)]