summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2018-05-23 09:43:49 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2018-05-23 09:43:49 +0100
commit8e45d269f606f3f1b2ea67f607d5e02d532d6c55 (patch)
tree0aab76d3b6e86e28102445713b463d54f220b233
parent2dbab9da4669ace4ffe761820373840fbfe84790 (diff)
downloadcanopied-8e45d269f606f3f1b2ea67f607d5e02d532d6c55.tar.bz2
Moved QValue and friends in-crate because they were pointlessly small sub-crates
-rw-r--r--Cargo.toml12
-rw-r--r--exprparser/Cargo.toml8
-rw-r--r--exprparser/design.mdwn18
-rw-r--r--exprparser/src/lib.rs11
-rw-r--r--qexpr/Cargo.toml8
-rw-r--r--qvalues/Cargo.toml6
-rw-r--r--src/exprast.rs (renamed from exprparser/src/types.rs)0
-rw-r--r--src/exprparser.rs (renamed from exprparser/src/parser.rs)2
-rw-r--r--src/main.rs23
-rw-r--r--src/qexpr.rs (renamed from qexpr/src/lib.rs)7
-rw-r--r--src/qvalue.rs (renamed from qvalues/src/lib.rs)18
11 files changed, 29 insertions, 84 deletions
diff --git a/Cargo.toml b/Cargo.toml
index bf79fbd..96923fb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,15 +14,5 @@ serde_yaml = "0.7.3"
socketcan = "1.7.0"
time = "0.1.39"
tokio = "0.1.5"
-
-[dependencies.qvalues]
-path = "qvalues"
-
-[dependencies.exprparser]
-path = "exprparser"
-
-[dependencies.qexpr]
-path = "qexpr"
-
-[workspace]
+nom = "4.0"
diff --git a/exprparser/Cargo.toml b/exprparser/Cargo.toml
deleted file mode 100644
index df04c1d..0000000
--- a/exprparser/Cargo.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-[package]
-name = "exprparser"
-version = "0.1.0"
-authors = ["Daniel Silverstone <daniel.silverstone@codethink.co.uk>"]
-
-[dependencies]
-nom = {version = "4.0", features = [ "verbose-errors"]}
-log = "0.4.1"
diff --git a/exprparser/design.mdwn b/exprparser/design.mdwn
deleted file mode 100644
index 84ddef3..0000000
--- a/exprparser/design.mdwn
+++ /dev/null
@@ -1,18 +0,0 @@
-# Expression parser for Canopied
-
-Expressions are simple (for now):
-
- expr ::= <term> "+" <expr>
- | <term> "-" <expr>
- | <term>
-
- term ::= <factor> "*" <term>
- | <factor> "/" <term>
- | <factor>
-
- factor ::= "(" <expr> ")"
- | <const>
-
- <const> ::= integer | floatynumber
-
-We will use Nom, and construct an expression parse tree as our output.
diff --git a/exprparser/src/lib.rs b/exprparser/src/lib.rs
deleted file mode 100644
index 233e095..0000000
--- a/exprparser/src/lib.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-#[macro_use]
-extern crate nom;
-
-#[macro_use]
-extern crate log;
-
-mod parser;
-mod types;
-
-pub use parser::*;
-pub use types::*;
diff --git a/qexpr/Cargo.toml b/qexpr/Cargo.toml
deleted file mode 100644
index 90bbac3..0000000
--- a/qexpr/Cargo.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-[package]
-name = "qexpr"
-version = "0.1.0"
-authors = ["Daniel Silverstone <daniel.silverstone@codethink.co.uk>"]
-
-[dependencies]
-qvalues = { path = "../qvalues" }
-exprparser = { path = "../exprparser" }
diff --git a/qvalues/Cargo.toml b/qvalues/Cargo.toml
deleted file mode 100644
index 1cf08ec..0000000
--- a/qvalues/Cargo.toml
+++ /dev/null
@@ -1,6 +0,0 @@
-[package]
-name = "qvalues"
-version = "0.1.0"
-authors = ["Daniel Silverstone <daniel.silverstone@codethink.co.uk>"]
-
-[dependencies]
diff --git a/exprparser/src/types.rs b/src/exprast.rs
index 8551661..8551661 100644
--- a/exprparser/src/types.rs
+++ b/src/exprast.rs
diff --git a/exprparser/src/parser.rs b/src/exprparser.rs
index 625a231..9250dfd 100644
--- a/exprparser/src/parser.rs
+++ b/src/exprparser.rs
@@ -1,4 +1,4 @@
-use types::*;
+use exprast::*;
use nom::double_s;
diff --git a/src/main.rs b/src/main.rs
index 07df2f4..76aea88 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -14,23 +14,30 @@ extern crate serde_yaml;
#[macro_use]
extern crate lazy_static;
-mod types;
+#[macro_use]
+extern crate nom;
+
mod canstream;
-mod isotp;
mod definitions;
+mod exprast;
+mod exprparser;
+mod isotp;
+mod qexpr;
+mod qvalue;
+mod types;
-use tokio::prelude::*;
-use std::env::args;
use futures::sync::mpsc;
-use tokio::timer::Interval;
-use std::time::{Duration, Instant};
-use std::sync::Mutex;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
+use std::env::args;
+use std::sync::Mutex;
+use std::time::{Duration, Instant};
use std::vec::Vec;
+use tokio::prelude::*;
+use tokio::timer::Interval;
-use types::Value;
use definitions::CadencedECUs;
+use types::Value;
fn packet_print(id: u16, bytes: &[u8]) -> String {
let mut ret: String = String::new();
diff --git a/qexpr/src/lib.rs b/src/qexpr.rs
index fa59c5c..248b6fc 100644
--- a/qexpr/src/lib.rs
+++ b/src/qexpr.rs
@@ -1,8 +1,5 @@
-extern crate exprparser;
-extern crate qvalues;
-
-use exprparser::*;
-use qvalues::*;
+use exprast::*;
+use qvalue::*;
use std::collections::HashMap;
diff --git a/qvalues/src/lib.rs b/src/qvalue.rs
index 49d0770..d1de25f 100644
--- a/qvalues/src/lib.rs
+++ b/src/qvalue.rs
@@ -1,3 +1,5 @@
+use std::ops;
+
#[derive(Eq, PartialEq, PartialOrd, Copy, Clone)]
pub enum BaseQuantity {
Voltage,
@@ -46,20 +48,20 @@ impl Quantifier {
}
}
-impl std::ops::Index<BaseQuantity> for Quantifier {
+impl ops::Index<BaseQuantity> for Quantifier {
type Output = i8;
fn index(&self, q: BaseQuantity) -> &i8 {
&self.0[q as usize]
}
}
-impl std::ops::IndexMut<BaseQuantity> for Quantifier {
+impl ops::IndexMut<BaseQuantity> for Quantifier {
fn index_mut(&mut self, q: BaseQuantity) -> &mut i8 {
&mut self.0[q as usize]
}
}
-impl std::ops::Mul for Quantifier {
+impl ops::Mul for Quantifier {
type Output = Self;
fn mul(self, rhs: Self) -> Self {
let mut ret = Quantifier::new();
@@ -70,7 +72,7 @@ impl std::ops::Mul for Quantifier {
}
}
-impl std::ops::Div for Quantifier {
+impl ops::Div for Quantifier {
type Output = Self;
fn div(self, rhs: Self) -> Self {
let mut ret = Quantifier::new();
@@ -110,7 +112,7 @@ impl QValue {
}
}
-impl std::ops::Add for QValue {
+impl ops::Add for QValue {
type Output = Option<QValue>;
fn add(self, rhs: Self) -> Self::Output {
@@ -125,7 +127,7 @@ impl std::ops::Add for QValue {
}
}
-impl std::ops::Sub for QValue {
+impl ops::Sub for QValue {
type Output = Option<QValue>;
fn sub(self, rhs: Self) -> Self::Output {
@@ -140,7 +142,7 @@ impl std::ops::Sub for QValue {
}
}
-impl std::ops::Mul for QValue {
+impl ops::Mul for QValue {
type Output = Self;
fn mul(self, rhs: Self) -> Self {
@@ -151,7 +153,7 @@ impl std::ops::Mul for QValue {
}
}
-impl std::ops::Div for QValue {
+impl ops::Div for QValue {
type Output = Self;
fn div(self, rhs: Self) -> Self {