[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 sibillexer;
extern crate sibiltypes; extern crate sibiltypes;
mod list_parser; mod parsers;
mod node_parser;
mod program_parser;
mod sym_parser;
use std::iter::Peekable; use std::iter::Peekable;
use sibillexer::Result as LexerResult; use sibillexer::Result as LexerResult;
use sibillexer::Lex; use sibillexer::Lex;
use sibiltypes::Obj; use sibiltypes::Obj;
use node_parser::{NodeParser, NodeParseResult}; use parsers::{NodeParser, NodeParseResult};
use program_parser::ProgramParser; use parsers::ProgramParser;
/// The output of calling `parse()` on a Parser is one of these Result objects. /// The output of calling `parse()` on a Parser is one of these Result objects.
pub type Result = std::result::Result<Obj, ParseError>; 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> * Eryn Wells <eryn@erynwells.me>
*/ */
use sibillexer::{Lex, Token}; use sibillexer::{Lex, Token};
use sibiltypes::{Obj, Pair}; use sibiltypes::{Obj, Pair};
use node_parser::{NodeParser, NodeParseResult}; use parsers::{NodeParser, NodeParseResult};
use sym_parser::SymParser; use parsers::sym::SymParser;
#[derive(Debug)] #[derive(Debug)]
pub struct ListParser { pub struct ListParser {

View file

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

View file

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

View file

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