whiley_file 0.1.0

An API for manipulating files written in the Whiley Programming Language.
Documentation
use crate::ast::{Expr,Name,Parameter,Stmt,Type};

// =============================================================================
// Declarations
// =============================================================================

#[derive(Clone,Debug,PartialEq)]
pub struct TypeDecl {
    name: Name,
    pattern: Type
}
impl TypeDecl {
    pub fn new(name: Name, pattern: Type) -> Self {
        TypeDecl{name,pattern}
    }
}

#[derive(Clone,Debug,PartialEq)]
pub struct FunctionDecl {
    name: Name,
    parameters: Vec<Parameter>,
    returns: Vec<Parameter>,
    body:Stmt
}
impl FunctionDecl {
    pub fn new(name: Name, parameters: Vec<Parameter>,
               returns: Vec<Parameter>, body: Stmt) -> Self {
        FunctionDecl{name,parameters,returns,body}
    }
}

#[derive(Clone,Debug,PartialEq)]
pub struct MethodDecl {
    name: Name,
    parameters: Vec<Parameter>,
    returns: Vec<Parameter>,
    body:Stmt
}
impl MethodDecl {
    pub fn new(name: Name, parameters: Vec<Parameter>,
               returns: Vec<Parameter>, body: Stmt) -> Self {
        MethodDecl{name,parameters,returns,body}
    }
}

// =============================================================================
// Statements
// =============================================================================

#[derive(Clone,Debug,PartialEq)]
pub struct AssertStmt(pub Expr);

#[derive(Clone,Debug,PartialEq)]
pub struct BlockStmt(pub Vec<Stmt>);

#[derive(Clone,Debug,PartialEq)]
pub struct SkipStmt();

// =============================================================================
// Expressions
// =============================================================================

#[derive(Clone,Debug,PartialEq)]
pub struct BoolExpr(pub bool);

#[derive(Clone,Debug,PartialEq)]
pub struct EqualsExpr(pub Expr, pub Expr);

#[derive(Clone,Debug,PartialEq)]
pub struct NotEqualsExpr(pub Expr, pub Expr);

#[derive(Clone,Debug,PartialEq)]
pub struct LessThanExpr(pub Expr, pub Expr);

#[derive(Clone,Debug,PartialEq)]
pub struct IntExpr(pub i32);

#[derive(Clone,Debug,PartialEq)]
pub struct VarExpr(pub Name);

// =============================================================================
// Expressions
// =============================================================================

#[derive(Clone,Debug,PartialEq)]
pub struct ArrayType(pub Type);

#[derive(Clone,Debug,PartialEq)]
pub struct BoolType();

#[derive(Clone,Debug,PartialEq)]
pub struct IntType(pub bool, pub u8);

#[derive(Clone,Debug,PartialEq)]
pub struct NullType();

#[derive(Clone,Debug,PartialEq)]
pub struct RecordType(pub Vec<(Type,Name)>);

#[derive(Clone,Debug,PartialEq)]
pub struct ReferenceType(pub Type);

#[derive(Clone,Debug,PartialEq)]
pub struct VoidType();