Start adding doc comments
This commit is contained in:
parent
0adc761e72
commit
7c46a29141
@ -2,6 +2,11 @@
|
|||||||
#![feature(custom_attribute)]
|
#![feature(custom_attribute)]
|
||||||
#![feature(unrestricted_attribute_tokens)]
|
#![feature(unrestricted_attribute_tokens)]
|
||||||
#![feature(slice_patterns, box_patterns, box_syntax)]
|
#![feature(slice_patterns, box_patterns, box_syntax)]
|
||||||
|
|
||||||
|
//! `schala-lang` is where the Schala programming language is actually implemented.
|
||||||
|
//! It defines the `Schala` type, which contains the state for a Schala REPL, and implements
|
||||||
|
//! `ProgrammingLanguageInterface` and the chain of compiler passes for it.
|
||||||
|
|
||||||
extern crate itertools;
|
extern crate itertools;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
@ -40,6 +45,9 @@ mod eval;
|
|||||||
#[PipelineSteps(tokenizing, parsing(compact,expanded,trace), symbol_table, typechecking, ast_reducing, eval)]
|
#[PipelineSteps(tokenizing, parsing(compact,expanded,trace), symbol_table, typechecking, ast_reducing, eval)]
|
||||||
#[DocMethod = get_doc]
|
#[DocMethod = get_doc]
|
||||||
#[HandleCustomInterpreterDirectives = handle_custom_interpreter_directives]
|
#[HandleCustomInterpreterDirectives = handle_custom_interpreter_directives]
|
||||||
|
/// All bits of state necessary to parse and execute a Schala program are stored in this struct
|
||||||
|
/// `state` represents the execution state for the AST-walking interpreter, the other fields
|
||||||
|
/// should be self-explanatory.
|
||||||
pub struct Schala {
|
pub struct Schala {
|
||||||
state: eval::State<'static>,
|
state: eval::State<'static>,
|
||||||
symbol_table: Rc<RefCell<symbol_table::SymbolTable>>,
|
symbol_table: Rc<RefCell<symbol_table::SymbolTable>>,
|
||||||
@ -58,6 +66,7 @@ impl Schala {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Schala {
|
impl Schala {
|
||||||
|
/// Creates a new Schala environment *without* any prelude.
|
||||||
fn new_blank_env() -> Schala {
|
fn new_blank_env() -> Schala {
|
||||||
let symbols = Rc::new(RefCell::new(symbol_table::SymbolTable::new()));
|
let symbols = Rc::new(RefCell::new(symbol_table::SymbolTable::new()));
|
||||||
Schala {
|
Schala {
|
||||||
@ -68,6 +77,8 @@ impl Schala {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new Schala environment with the standard prelude, which is defined as ordinary
|
||||||
|
/// Schala code in the file `prelude.schala`
|
||||||
pub fn new() -> Schala {
|
pub fn new() -> Schala {
|
||||||
let prelude = include_str!("prelude.schala");
|
let prelude = include_str!("prelude.schala");
|
||||||
let mut s = Schala::new_blank_env();
|
let mut s = Schala::new_blank_env();
|
||||||
|
@ -10,6 +10,7 @@ pub struct TypeContext<'a> {
|
|||||||
evar_count: u32
|
evar_count: u32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `InferResult` is the monad in which type inference takes place.
|
||||||
type InferResult<T> = Result<T, TypeError>;
|
type InferResult<T> = Result<T, TypeError>;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -21,6 +22,8 @@ impl TypeError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Type` is parameterized by whether the type variables can be just universal, or universal or
|
||||||
|
/// existential.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
enum Type<A> {
|
enum Type<A> {
|
||||||
Var(A),
|
Var(A),
|
||||||
|
Loading…
Reference in New Issue
Block a user