DELETE PARSER CRAP
This commit is contained in:
parent
e1f2c6b88b
commit
bbf161ede9
5 changed files with 0 additions and 149 deletions
|
@ -1,42 +0,0 @@
|
|||
/* mod.rs
|
||||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
|
||||
pub use self::nodes::Program;
|
||||
|
||||
mod nodes;
|
||||
|
||||
use lexer::Lexer;
|
||||
|
||||
pub struct Parser {
|
||||
lexer: Lexer,
|
||||
}
|
||||
|
||||
impl Parser {
|
||||
pub fn new(lexer: Lexer) -> Parser {
|
||||
Parser { lexer: lexer }
|
||||
}
|
||||
|
||||
pub fn parse(&self) -> nodes::Program {
|
||||
self.parse_program()
|
||||
}
|
||||
}
|
||||
|
||||
impl Parser {
|
||||
fn parse_program(&self) -> nodes::Program {
|
||||
let program = Program::new();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use lexer::Lexer;
|
||||
|
||||
#[test]
|
||||
fn parses_empty_input() {
|
||||
let parser = Parser::new(Lexer::new(""));
|
||||
let parsed = parser.parse();
|
||||
assert_eq!(parsed, Program::new());
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/* parser/nodes/constant.rs
|
||||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
|
||||
use std::fmt;
|
||||
use types::{Boolean, Number};
|
||||
use super::TreeDebug;
|
||||
use super::expression::Expression;
|
||||
|
||||
pub trait ConstantValue {}
|
||||
impl ConstantValue for Boolean {}
|
||||
impl ConstantValue for Number {}
|
||||
|
||||
pub struct Constant<'a, V: ConstantValue> {
|
||||
parent: Option<&'a Expression>,
|
||||
value: V
|
||||
}
|
||||
|
||||
impl<'a, V: ConstantValue> Constant<'a, V> {
|
||||
pub fn new(value: V) -> Constant<'a, V> {
|
||||
Constant { parent: None, value: value }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, V: ConstantValue + fmt::Debug> fmt::Debug for Constant<'a, V> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Constant {{ {:?} }}", self.value)
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
/* parser/nodes/expression.rs
|
||||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
|
||||
pub trait Expression {}
|
|
@ -1,33 +0,0 @@
|
|||
/* parser/nodes/mod.rs
|
||||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
|
||||
use std::fmt;
|
||||
|
||||
pub use self::constant::Constant;
|
||||
pub use self::program::Program;
|
||||
|
||||
mod constant;
|
||||
mod expression;
|
||||
mod program;
|
||||
|
||||
use self::expression::Expression;
|
||||
|
||||
/// Conveniently print out a node in the tree
|
||||
trait TreeDebug: fmt::Debug {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.tree_fmt(f, 0)
|
||||
}
|
||||
|
||||
fn tree_indent(&self, indent: u8) -> String {
|
||||
(0..10).fold(String::new(), |mut acc, _| {
|
||||
acc.push(' ');
|
||||
acc
|
||||
})
|
||||
}
|
||||
|
||||
fn tree_fmt(&self, f: &mut fmt::Formatter, indent: u8) -> fmt::Result {
|
||||
let spaces: String = self.tree_indent(indent);
|
||||
write!(f, "{}{:?}", spaces, self)
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/* parser/nodes/program.rs
|
||||
* Eryn Wells <eyrn@erynwells.me>
|
||||
*/
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use super::TreeDebug;
|
||||
use super::expression::Expression;
|
||||
|
||||
pub struct Program {
|
||||
forms: Vec<Box<Expression>>,
|
||||
}
|
||||
|
||||
impl Program {
|
||||
pub fn new() -> Program {
|
||||
Program { forms: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
impl fmt::Debug for Program {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.tree_fmt(f, 0)
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeDebug for Program {
|
||||
fn tree_fmt(&self, f: &mut fmt::Formatter, indent: u8) -> fmt::Result {
|
||||
let spaces = self.tree_indent(indent);
|
||||
let mut result = write!(f, "{}Program", spaces);
|
||||
for form in self.forms.iter() {
|
||||
if result.is_err() {
|
||||
break;
|
||||
}
|
||||
result = form.tree_fmt(f, indent + 2);
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue