More rough sketching of a parser
This commit is contained in:
parent
ee3368201b
commit
1365ab71db
2 changed files with 17 additions and 8 deletions
|
|
@ -5,20 +5,17 @@
|
||||||
extern crate sibillexer;
|
extern crate sibillexer;
|
||||||
extern crate sibiltypes;
|
extern crate sibiltypes;
|
||||||
|
|
||||||
use sibillexer::Lexer;
|
use sibillexer::{Lexer, Token};
|
||||||
use sibillexer::Token;
|
use sibiltypes::{Bool, Char, Number, Value};
|
||||||
use sibiltypes::Value;
|
use super::{Parsable, ParseError, Result};
|
||||||
use super::Parsable;
|
|
||||||
use super::ParseError;
|
|
||||||
use super::Result;
|
|
||||||
|
|
||||||
pub enum SExpression {
|
pub enum SExpression {
|
||||||
Value(Box<Value>),
|
Atom(Box<Value>),
|
||||||
List(Vec<SExpression>),
|
List(Vec<SExpression>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parsable for SExpression {
|
impl Parsable for SExpression {
|
||||||
fn parse(lexer: &Lexer) -> Result<SExpression> {
|
fn parse(lexer: &Lexer) -> Result<SExpression> {
|
||||||
Err(ParseError{ })
|
Ok(SExpression::Atom(Box::new(Number::from_int(3, true))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,20 @@
|
||||||
* Eryn Wells <eryn@erynwells.me>
|
* Eryn Wells <eryn@erynwells.me>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use sibillexer::Lexer;
|
||||||
|
use super::Result;
|
||||||
|
use super::Parsable;
|
||||||
|
use super::ParseError;
|
||||||
use list::SExpression;
|
use list::SExpression;
|
||||||
|
|
||||||
struct Program {
|
struct Program {
|
||||||
commands: Vec<SExpression>,
|
commands: Vec<SExpression>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Parsable for Program {
|
||||||
|
fn parse(lexer: &Lexer) -> Result<Program> {
|
||||||
|
let mut commands: Vec<SExpression> = Vec::new();
|
||||||
|
// TODO: Actually parse commands.
|
||||||
|
Ok(Program { commands: commands })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue