A big refactor, step 3
This commit is contained in:
@@ -20,7 +20,7 @@ impl AstNode for Conditional {
|
||||
mod test {
|
||||
use crate::ast::Statement;
|
||||
use crate::parser::Parseable;
|
||||
use crate::parser::ast_nodes::test_utils::*;
|
||||
use crate::parser::test_utils::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -10,7 +10,6 @@ mod assignment;
|
||||
mod var_decl;
|
||||
mod block;
|
||||
mod conditional;
|
||||
mod test_utils;
|
||||
mod while_loop;
|
||||
mod repeat_loop;
|
||||
mod program;
|
||||
|
||||
@@ -17,7 +17,7 @@ impl AstNode for Program {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::parser::ast_nodes::test_utils::dislocate;
|
||||
use crate::parser::test_utils::dislocate;
|
||||
use crate::parser::Parseable;
|
||||
use super::*;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ impl AstNode for RepeatLoop {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::ast::Statement;
|
||||
use crate::parser::ast_nodes::test_utils::{dislocate, dislocated_block};
|
||||
use crate::parser::test_utils::{dislocate, dislocated_block};
|
||||
use crate::parser::Parseable;
|
||||
use super::*;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ impl AstNode for WhileLoop {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::ast::Statement;
|
||||
use crate::parser::ast_nodes::test_utils::{dislocate, dislocated_block};
|
||||
use crate::parser::test_utils::{dislocate, dislocated_block};
|
||||
use crate::parser::Parseable;
|
||||
use super::*;
|
||||
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
use pest::pratt_parser::PrattParser;
|
||||
use pest::Parser;
|
||||
|
||||
use crate::ast::*;
|
||||
pub use pairs_ext::*;
|
||||
pub use parse_error::ParseError;
|
||||
|
||||
mod parse_error;
|
||||
mod pairs_ext;
|
||||
mod ast_nodes;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_utils;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[grammar = "parser/forge.pest"]
|
||||
struct ForgeParser;
|
||||
@@ -33,13 +44,6 @@ pub type PestRule = Rule;
|
||||
pub(crate) type Pair<'a> = pest::iterators::Pair<'a, Rule>;
|
||||
pub(crate) type Pairs<'i, R = Rule> = pest::iterators::Pairs<'i, R>;
|
||||
|
||||
mod parse_error;
|
||||
mod pairs_ext;
|
||||
|
||||
use crate::ast::*;
|
||||
pub use pairs_ext::*;
|
||||
pub use parse_error::ParseError;
|
||||
|
||||
/// A trait that represents something that can be parsed into an AST node: impl this to turn
|
||||
/// a pair into your node, by from_pair-ing child nodes.
|
||||
trait AstNode: Sized {
|
||||
@@ -77,11 +81,10 @@ pub fn parse(src: &str) -> Result<Program, ParseError> {
|
||||
Program::from_str(src)
|
||||
}
|
||||
|
||||
mod ast_nodes;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// todo: can this die? it's only used in compiler tests but needs to be here for visibility reasons
|
||||
#[cfg(test)]
|
||||
impl Expr {
|
||||
pub(crate) fn parse(src: &str) -> Result<Self, ParseError> {
|
||||
Self::from_str(src)
|
||||
|
||||
Reference in New Issue
Block a user