[parser] Reorganize NodeParsers into parsers/ subdirectory

This commit is contained in:
Eryn Wells 2018-08-26 17:32:09 -07:00
parent 1304e04808
commit fe478fadc7
5 changed files with 19 additions and 14 deletions

View file

@ -5,17 +5,14 @@
extern crate sibillexer;
extern crate sibiltypes;
mod list_parser;
mod node_parser;
mod program_parser;
mod sym_parser;
mod parsers;
use std::iter::Peekable;
use sibillexer::Result as LexerResult;
use sibillexer::Lex;
use sibiltypes::Obj;
use node_parser::{NodeParser, NodeParseResult};
use program_parser::ProgramParser;
use parsers::{NodeParser, NodeParseResult};
use parsers::ProgramParser;
/// The output of calling `parse()` on a Parser is one of these Result objects.
pub type Result = std::result::Result<Obj, ParseError>;

View file

@ -1,11 +1,11 @@
/* parser/src/list_parser.rs
/* parser/src/parsers/list.rs
* Eryn Wells <eryn@erynwells.me>
*/
use sibillexer::{Lex, Token};
use sibiltypes::{Obj, Pair};
use node_parser::{NodeParser, NodeParseResult};
use sym_parser::SymParser;
use parsers::{NodeParser, NodeParseResult};
use parsers::sym::SymParser;
#[derive(Debug)]
pub struct ListParser {

View file

@ -1,7 +1,13 @@
/* node_parser.rs
/* parser/src/parsers/mod.rs
* Eryn Wells <eryn@erynwells.me>
*/
mod list;
mod program;
mod sym;
pub use self::program::ProgramParser;
use std::fmt::Debug;
use sibillexer::Lex;
use sibiltypes::Obj;
@ -31,8 +37,10 @@ impl NodeParseResult {
pub trait NodeParser: Debug {
/// Called on a NodeParser when a Lex is encountered in the input.
fn parse(&mut self, lex: &Lex) -> NodeParseResult;
/// Called on a NodeParser when None is encountered in the input.
fn none(&mut self) -> NodeParseResult;
/// Called on a NodeParser when a NodeParser created by this one returns an object via
/// `NodeParseResult::Complete`.
fn subparser_completed(&mut self, obj: Obj) -> NodeParseResult;

View file

@ -4,9 +4,9 @@
use sibillexer::{Lex, Token};
use sibiltypes::Obj;
use list_parser::ListParser;
use node_parser::{NodeParser, NodeParseResult};
use sym_parser::SymParser;
use parsers::{NodeParser, NodeParseResult};
use parsers::list::ListParser;
use parsers::sym::SymParser;
#[derive(Debug)]
pub struct ProgramParser;

View file

@ -4,7 +4,7 @@
use sibillexer::{Lex, Token};
use sibiltypes::{Obj, Sym};
use node_parser::{NodeParser, NodeParseResult};
use parsers::{NodeParser, NodeParseResult};
#[derive(Debug)]
pub struct SymParser;