summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-10-22 12:45:50 +0200
committerMatthias Beyer <mail@beyermatthias.de>2017-10-22 12:45:50 +0200
commit4e2dc0a0728b280d2ff01da452eea319b660187c (patch)
tree30abce078e8e6992350d196998512a5f07501289
parent84c575097f3e57198fe4f20d5e31d605109c2a35 (diff)
Initial import for parser
-rw-r--r--Cargo.toml5
-rw-r--r--build.rs6
-rw-r--r--src/grammar.rustpeg2
-rw-r--r--src/lib.rs4
-rw-r--r--src/parser.rs20
5 files changed, 37 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 5752988..bc8f016 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,12 +12,17 @@ license = "MPL-2.0"
repository = "https://github.com/matthiasbeyer/kairos"
+build = "build.rs"
+
[dependencies]
chrono = "0.4"
error-chain = "0.10"
filters = { version = "0.1.1", optional = true }
+[build-dependencies]
+peg = { version = "0.5" }
+
[dev-dependencies]
env_logger = "0.4"
log = "0.3"
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..af09e85
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,6 @@
+extern crate peg;
+
+fn main() {
+ peg::cargo_build("src/grammar.rustpeg");
+}
+
diff --git a/src/grammar.rustpeg b/src/grammar.rustpeg
new file mode 100644
index 0000000..36a3fa0
--- /dev/null
+++ b/src/grammar.rustpeg
@@ -0,0 +1,2 @@
+use timetype::TimeType;
+
diff --git a/src/lib.rs b/src/lib.rs
index 7aeab51..8f7fed9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,6 +2,9 @@
extern crate error_chain;
extern crate chrono;
+#[macro_use]
+extern crate peg;
+
#[cfg(feature = "with-filters")]
extern crate filters;
@@ -17,5 +20,6 @@ pub mod iter;
pub mod timetype;
pub mod indicator;
pub mod matcher;
+pub mod parser;
mod util;
diff --git a/src/parser.rs b/src/parser.rs
new file mode 100644
index 0000000..83c05a1
--- /dev/null
+++ b/src/parser.rs
@@ -0,0 +1,20 @@
+//! The definition of the "kairos" syntax, for parsing user input into TimeType objects
+//!
+//! The syntax itself is described in the grammar.rustpeg file.
+//! Here goes a documentation on the syntax
+//!
+//! # Syntax
+//!
+//!
+//!
+//!
+//!
+//!
+//!
+//!
+//!
+
+mod grammar {
+ include!(concat!(env!("OUT_DIR"), "/grammar.rs"));
+}
+