Put parsing details into one module
This commit is contained in:
parent
61c0a34253
commit
6000b1f242
10 changed files with 30 additions and 29 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use minisql::{operation::Operation, schema::TableSchema};
|
||||
use nom::{branch::alt, multi::many0, IResult};
|
||||
|
||||
use crate::{create::parse_create, delete::parse_delete, index::parse_create_index, insert::parse_insert, select::parse_select, validation::{validate_operation, ValidationError}};
|
||||
use crate::{parsing::{create::parse_create, delete::parse_delete, index::parse_create_index, insert::parse_insert, select::parse_select}, validation::{validate_operation, ValidationError}};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
|
||||
mod literal;
|
||||
mod select;
|
||||
mod common;
|
||||
mod create;
|
||||
mod insert;
|
||||
mod delete;
|
||||
mod index;
|
||||
mod parsing;
|
||||
mod validation;
|
||||
mod core;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use nom::{
|
|||
};
|
||||
use minisql::{operation::Condition, type_system::DbType};
|
||||
|
||||
use crate::literal::parse_db_value;
|
||||
use super::literal::parse_db_value;
|
||||
|
||||
pub fn parse_table_name(input: &str) -> IResult<&str, &str> {
|
||||
alt((
|
||||
|
|
@ -68,7 +68,7 @@ fn parse_equality(input: &str) -> IResult<&str, Condition> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use minisql::{operation::Condition, type_system::DbType};
|
||||
use crate::common::{parse_db_type, parse_equality};
|
||||
use crate::parsing::common::{parse_db_type, parse_equality};
|
||||
|
||||
#[test]
|
||||
fn test_parse_equality() {
|
||||
|
|
@ -7,7 +7,7 @@ use nom::{
|
|||
IResult, combinator::opt,
|
||||
};
|
||||
|
||||
use crate::common::{parse_table_name, parse_identifier, parse_db_type};
|
||||
use super::common::{parse_table_name, parse_identifier, parse_db_type};
|
||||
|
||||
pub fn parse_create(input: &str) -> IResult<&str, Operation> {
|
||||
let (input, _) = tag("CREATE")(input)?;
|
||||
|
|
@ -69,7 +69,7 @@ pub fn parse_column_definition(input: &str) -> IResult<&str, (ColumnName, DbType
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use minisql::operation::Operation;
|
||||
use crate::create::parse_create;
|
||||
use crate::parsing::create::parse_create;
|
||||
|
||||
#[test]
|
||||
fn test_parse_create_no_spaces() {
|
||||
|
|
@ -5,7 +5,7 @@ use nom::{
|
|||
IResult,
|
||||
};
|
||||
|
||||
use crate::common::{parse_table_name, parse_condition};
|
||||
use super::common::{parse_table_name, parse_condition};
|
||||
|
||||
pub fn parse_delete(input: &str) -> IResult<&str, Operation> {
|
||||
let (input, _) = tag("DELETE")(input)?;
|
||||
|
|
@ -26,7 +26,7 @@ pub fn parse_delete(input: &str) -> IResult<&str, Operation> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use minisql::operation::Operation;
|
||||
use crate::delete::parse_delete;
|
||||
use crate::parsing::delete::parse_delete;
|
||||
|
||||
#[test]
|
||||
fn test_parse_delete() {
|
||||
|
|
@ -5,7 +5,7 @@ use nom::{
|
|||
IResult, combinator::opt,
|
||||
};
|
||||
|
||||
use crate::common::{parse_identifier, parse_table_name};
|
||||
use super::common::{parse_identifier, parse_table_name};
|
||||
|
||||
pub fn parse_create_index(input: &str) -> IResult<&str, Operation> {
|
||||
let (input, _) = tag("CREATE")(input)?;
|
||||
|
|
@ -39,7 +39,7 @@ pub fn parse_create_index(input: &str) -> IResult<&str, Operation> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use minisql::operation::Operation;
|
||||
use crate::index::parse_create_index;
|
||||
use crate::parsing::index::parse_create_index;
|
||||
|
||||
|
||||
#[test]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{literal::parse_db_value, common::{parse_table_name, parse_identifier}};
|
||||
use super::{literal::parse_db_value, common::{parse_table_name, parse_identifier}};
|
||||
use minisql::{operation::Operation, type_system::Value};
|
||||
use nom::{
|
||||
bytes::complete::tag,
|
||||
|
|
@ -110,7 +110,7 @@ fn parse_uuid(input: &str) -> IResult<&str, Value> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use minisql::type_system::{IndexableValue, Value};
|
||||
use crate::literal::{parse_db_value, parse_string};
|
||||
use crate::parsing::literal::{parse_db_value, parse_string};
|
||||
|
||||
|
||||
#[test]
|
||||
7
parser/src/parsing/mod.rs
Normal file
7
parser/src/parsing/mod.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
pub(crate) mod literal;
|
||||
pub(crate) mod select;
|
||||
pub(crate) mod common;
|
||||
pub(crate) mod create;
|
||||
pub(crate) mod insert;
|
||||
pub(crate) mod delete;
|
||||
pub(crate) mod index;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::common::{parse_table_name, parse_column_name, parse_condition};
|
||||
use super::common::{parse_table_name, parse_column_name, parse_condition};
|
||||
use minisql::operation::{ColumnSelection, Operation};
|
||||
use nom::{
|
||||
branch::alt,
|
||||
|
|
@ -45,7 +45,7 @@ pub fn try_parse_column_selection(input: &str) -> IResult<&str, ColumnSelection>
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use minisql::operation::{ColumnSelection, Operation};
|
||||
use crate::{common::{parse_column_name, parse_table_name}, select::parse_select};
|
||||
use crate::parsing::{common::{parse_column_name, parse_table_name}, select::parse_select};
|
||||
|
||||
|
||||
#[test]
|
||||
Loading…
Add table
Add a link
Reference in a new issue