Skip to content

Commit

Permalink
Refactor the parser code into its own crate for future development
Browse files Browse the repository at this point in the history
This will inform #46
  • Loading branch information
rtyler committed Nov 29, 2020
1 parent 9a39ea0 commit 127d3b7
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 12 deletions.
13 changes: 12 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [

"crates/agent",
"crates/models",
"crates/parser",

"services/auctioneer",
"services/eventbus",
Expand Down
13 changes: 13 additions & 0 deletions crates/parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "otto-parser"
version = "0.1.0"
authors = ["R. Tyler Croy <[email protected]>"]
edition = "2018"

[dependencies]
log = "~0.4.11"
otto-models = { path = "../models" }
pest = "~2.1.3"
pest_derive = "~2.1.0"
serde_json = "~1.0.59"
uuid = { version = "~0.8.1", features = ["v4", "serde"]}
6 changes: 6 additions & 0 deletions crates/parser/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
= Otto Parser

The Otto Parser service is basically a parser engine that speaks HTTP. In the
`src/` directory you will find the `.pest` grammar definition which outlines
the Otto Pipeline syntax.

3 changes: 3 additions & 0 deletions services/parser/src/lib.rs → crates/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use pest::iterators::{Pair, Pairs};
use pest::Parser;
use uuid::Uuid;

pub use pest::error::ErrorVariant;
pub use pest::error::LineColLocation;

#[derive(Parser)]
#[grammar = "pipeline.pest"]
struct PipelineParser;
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 2 additions & 7 deletions services/parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
[package]
name = "otto-parser"
name = "otto-parser-service"
version = "0.1.0"
authors = ["R. Tyler Croy <[email protected]>"]
edition = "2018"

[lib]
name = "otto_parser"
path = "src/lib.rs"

[[bin]]
name = "otto-parser"
path = "src/main.rs"
Expand All @@ -16,8 +12,7 @@ path = "src/main.rs"
async-std = { version = "1.6.5", features = ["attributes"]}
log = "~0.4.11"
otto-models = { path = "../../crates/models" }
pest = "~2.1.3"
pest_derive = "~2.1.0"
otto-parser = { path = "../../crates/parser" }
pretty_env_logger = "~0.4.0"
serde_json = "~1.0.59"
tide = "~0.15.0"
Expand Down
4 changes: 1 addition & 3 deletions services/parser/README.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
= Parser service

The Otto Parser service is basically a parser engine that speaks HTTP. In the
`src/` directory you will find the `.pest` grammar definition which outlines
the Otto Pipeline syntax.
The Otto Parser Service presents the parser crate as an HTTP service.

The `apispec.yml` is an link:https://en.wikipedia.org/wiki/Open_API[OpenAPI]
specification that describes the public HTTP endpoints that the parser service
Expand Down
1 change: 0 additions & 1 deletion services/parser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ async fn parse(mut req: Request<()>) -> tide::Result {

match parsed {
Err(e) => {
use pest::error::*;
error!("Failed to parse: {:?}", e);

let variant = match e.variant {
Expand Down

0 comments on commit 127d3b7

Please sign in to comment.