Initial library commit.

This commit is contained in:
2016-07-15 15:40:16 -04:00
commit 14bd90d88e
9 changed files with 153 additions and 0 deletions

3
src/compiler.rs Normal file
View File

@ -0,0 +1,3 @@
pub enum Compiler
{
}

3
src/lexer.rs Normal file
View File

@ -0,0 +1,3 @@
pub enum Lexer
{
}

9
src/lib.rs Normal file
View File

@ -0,0 +1,9 @@
mod compiler;
mod lexer;
mod parser;
pub use self::compiler::Compiler;
pub use self::lexer::Lexer;
pub use self::parser::Parser;

65
src/parser.rs Normal file
View File

@ -0,0 +1,65 @@
///
pub struct Parser
{
///
position: usize,
///
input: String
}
impl Parser
{
///
pub fn parse(&mut self)
{
}
/// Get, but don't consume, the current character.
pub fn get_char(&self) -> char
{
'a'
}
/// Returns true if the next set of characters starts with
/// the given pattern; Otherwise, false.
pub fn starts_with<P>(&self, pattern: P) -> bool
where P: AsRef<str>
{
self.position >= self.input.len()
}
/// Returns true if all the input has been consumed;
/// Otherwise, false.
pub fn end_of_file(&self) -> bool
{
self.position >= self.input.len()
}
/// Return the current character and advance to the next one.
pub fn consume_char(&mut self) -> char
{
'a'
}
/// Consume and discard zero or more whitespace characters.
pub fn consume_whitespace(&mut self)
{
self.consume_while(Parser::is_whitespace);
}
/// Consume characters until the test returns false.
pub fn consume_while<F>(&mut self, test: F) -> String
where F: Fn(char) -> bool
{
String::new()
}
/// Determines if a character is whitespace.
fn is_whitespace(c: char) -> bool
{
c.is_whitespace()
}
}