Skip to content

Commit c6e5211

Browse files
authored
Merge pull request #7 from Keats/reorg
Move query parser in its own mod
2 parents ab8d7e6 + dea653b commit c6e5211

File tree

8 files changed

+22
-17
lines changed

8 files changed

+22
-17
lines changed

src/format.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Formatting graphql
22
use std::default::Default;
33

4+
45
#[derive(Debug, PartialEq)]
56
pub(crate) struct Formatter<'a> {
67
buf: String,

src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,11 @@ extern crate combine;
4646
#[cfg(test)] #[macro_use] extern crate pretty_assertions;
4747

4848

49+
mod format;
4950
mod position;
5051
mod tokenizer;
5152
mod helpers;
52-
mod query_grammar;
53-
mod query_error;
54-
mod query_format;
53+
mod query;
5554

56-
pub mod format;
57-
pub mod query;
58-
59-
pub use query_grammar::parse_query;
55+
pub use query::{parse_query, QueryParseError};
6056
pub use position::Pos;

src/query.rs renamed to src/query/ast.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//!
88
use std::collections::BTreeMap;
99

10-
pub use query_error::QueryParseError as ParseError;
11-
1210
use position::Pos;
1311

1412
/// An alias for string, used where graphql expects a name
File renamed without changes.

src/query_format.rs renamed to src/query/format.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::fmt;
2-
use format::{Displayable, Formatter, Style};
3-
use query::*;
2+
3+
use ::format::{Displayable, Formatter, Style};
4+
5+
use query::ast::*;
6+
47

58
impl Document {
69
/// Format a document according to style

src/query_grammar.rs renamed to src/query/grammar.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
use tokenizer::TokenStream;
2-
31
use combine::{parser, ParseResult, Parser};
42
use combine::easy::Error;
53
use combine::error::StreamError;
64
use combine::combinator::{many, many1, eof, optional, position};
75

8-
use query_error::{QueryParseError};
9-
use tokenizer::{Kind as T, Token};
6+
use tokenizer::{Kind as T, Token, TokenStream};
107
use helpers::{punct, ident, kind, name};
11-
use query::*;
8+
use query::error::{QueryParseError};
9+
use query::ast::*;
1210

1311
pub fn directives<'a>(input: &mut TokenStream<'a>)
1412
-> ParseResult<Vec<Directive>, TokenStream<'a>>
@@ -385,7 +383,7 @@ pub fn parse_query(s: &str) -> Result<Document, QueryParseError> {
385383
#[cfg(test)]
386384
mod test {
387385
use position::Pos;
388-
use query::*;
386+
use query::grammar::*;
389387
use super::parse_query;
390388

391389
fn ast(s: &str) -> Document {

src/query/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
mod ast;
2+
mod error;
3+
mod format;
4+
mod grammar;
5+
6+
7+
pub use self::grammar::parse_query;
8+
pub use self::error::QueryParseError;

src/tokenizer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use combine::{StreamOnce, Positioned};
44
use combine::error::{StreamError};
55
use combine::stream::{Resetable};
66
use combine::easy::{Error, Errors};
7+
78
use position::Pos;
89

910

0 commit comments

Comments
 (0)