AST revamp

- Unified terminology of span in error.rs
This commit is contained in:
Erin 2021-06-06 23:13:48 +02:00 committed by ondra05
parent 6fd95f3cc2
commit 93065e7dc9
2 changed files with 17 additions and 3 deletions

View file

@ -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; use crate::variables::Value;
type Span = std::ops::Range<usize>; type Span = std::ops::Range<usize>;
#[derive(Debug)] #[derive(Debug)]
pub struct Iden(String); pub struct Iden {
pub iden: String,
pub span: Span,
}
#[derive(Debug)] #[derive(Debug)]
pub struct Block { pub struct Block {
@ -64,13 +77,14 @@ pub struct Expr {
#[derive(Debug)] #[derive(Debug)]
pub enum ExprKind { pub enum ExprKind {
Binary { BinOp {
lhs: Box<Expr>, lhs: Box<Expr>,
rhs: Box<Expr>, rhs: Box<Expr>,
kind: BinOpKind, kind: BinOpKind,
}, },
Not(Box<Expr>), Not(Box<Expr>),
Literal(Value), Literal(Value),
Variable(String),
} }
impl Expr { impl Expr {

View file

@ -5,7 +5,7 @@ use crate::brian::InterpretError;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Error { pub struct Error {
pub kind: ErrorKind, pub kind: ErrorKind,
pub position: Range<usize>, pub span: Range<usize>,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]