[parser, types] Clean up obj parsers
- Define ListParser, SymParser in their own separate modules - Add some stuff to types to make working with them more ergonomic
This commit is contained in:
parent
b6a9b8a855
commit
929846152e
8 changed files with 129 additions and 56 deletions
|
@ -2,18 +2,28 @@
|
|||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
|
||||
use object::Object;
|
||||
use predicates::IsBool;
|
||||
use std::fmt;
|
||||
use object::Obj;
|
||||
use preds;
|
||||
|
||||
impl IsBool for Object {
|
||||
fn is_bool(&self) -> bool {
|
||||
match *self {
|
||||
Object::Bool(_) => true,
|
||||
_ => false,
|
||||
/// The Scheme boolean type. It can be `True` or `False`.
|
||||
pub enum Bool { True, False }
|
||||
|
||||
impl Obj for Bool { }
|
||||
|
||||
impl fmt::Display for Bool {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Bool::True => write!(f, "#t"),
|
||||
Bool::False => write!(f, "#f")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl preds::IsBool for Bool {
|
||||
fn is_bool(&self) -> bool { true }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use object::Object;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue