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 sibiltypes;
 | 
			
		||||
 | 
			
		||||
use sibillexer::Lexer;
 | 
			
		||||
use sibillexer::Token;
 | 
			
		||||
use sibiltypes::Value;
 | 
			
		||||
use super::Parsable;
 | 
			
		||||
use super::ParseError;
 | 
			
		||||
use super::Result;
 | 
			
		||||
use sibillexer::{Lexer, Token};
 | 
			
		||||
use sibiltypes::{Bool, Char, Number, Value};
 | 
			
		||||
use super::{Parsable, ParseError, Result};
 | 
			
		||||
 | 
			
		||||
pub enum SExpression {
 | 
			
		||||
    Value(Box<Value>),
 | 
			
		||||
    Atom(Box<Value>),
 | 
			
		||||
    List(Vec<SExpression>),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Parsable for 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>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
use sibillexer::Lexer;
 | 
			
		||||
use super::Result;
 | 
			
		||||
use super::Parsable;
 | 
			
		||||
use super::ParseError;
 | 
			
		||||
use list::SExpression;
 | 
			
		||||
 | 
			
		||||
struct Program {
 | 
			
		||||
    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