From 93065e7dc910f867c06a09794adfe8d0a7ccd512 Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 6 Jun 2021 23:13:48 +0200 Subject: [PATCH] AST revamp - Unified terminology of span in error.rs --- src/ast.rs | 18 ++++++++++++++++-- src/error.rs | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) 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)]