forked from AbleScript/ablescript
AST revamp
- Unified terminology of span in error.rs
This commit is contained in:
parent
6fd95f3cc2
commit
93065e7dc9
18
src/ast.rs
18
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;
|
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 {
|
||||||
|
|
|
@ -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)]
|
||||||
|
|
Loading…
Reference in a new issue