Formatting: cargo fmt.

This commit is contained in:
Jeremy Wall 2018-05-14 21:34:38 -05:00
parent f4b5cf1b0c
commit 00c1e1751a
11 changed files with 138 additions and 137 deletions

View File

@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std;
use std::collections::HashSet;
use std::borrow::Borrow;
use std::convert::Into;
use std::cmp::Ordering;
use std::cmp::PartialOrd;
use std::cmp::Eq;
use std::cmp::Ordering;
use std::cmp::PartialEq;
use std::hash::Hasher;
use std::cmp::PartialOrd;
use std::collections::HashSet;
use std::convert::Into;
use std::hash::Hash;
use std::hash::Hasher;
macro_rules! enum_type_equality {
( $slf:ident, $r:expr, $( $l:pat ),* ) => {

View File

@ -13,23 +13,23 @@
// limitations under the License.
//! The build stage of the ucg compiler.
use std::env;
use std::fs::File;
use std::io::Read;
use std::error::Error;
use std::collections::{HashMap, HashSet, VecDeque};
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet, VecDeque};
use std::convert::From;
use std::env;
use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::fs::File;
use std::io::Read;
use std::ops::Deref;
use std::rc::Rc;
use std::convert::From;
use tokenizer::Span;
use ast::tree::*;
use error;
use format;
use parse::parse;
use error;
use tokenizer::Span;
impl MacroDef {
/// Expands a ucg Macro using the given arguments into a new Tuple.

View File

@ -13,9 +13,9 @@
// limitations under the License.
//! An environment variable converter.
use std::rc::Rc;
use std::io::Write;
use std::io::Result;
use std::io::Write;
use std::rc::Rc;
use ast::tree::*;
use build::Val;

View File

@ -13,9 +13,9 @@
// limitations under the License.
//! Contains code for converting a UCG Val into the command line flag output target.
use std::rc::Rc;
use std::io::Write;
use std::io::Result;
use std::io::Write;
use std::rc::Rc;
use build::Val;
use convert::traits::Converter;

View File

@ -8,9 +8,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Flags contains code for converting a UCG Val into the json output target.
use std::rc::Rc;
use std::io::Write;
use std::io::Result;
use std::io::Write;
use std::rc::Rc;
use serde_json;

View File

@ -13,9 +13,9 @@
// limitations under the License.
//! The conversion stage of the ucg compiler.
pub mod env;
pub mod flags;
pub mod json;
pub mod env;
pub mod traits;
use std::io;

View File

@ -13,9 +13,9 @@
// limitations under the License.
//! The traits used by the ucg compiler for converting Val intermediate format into the output formats..
use std::rc::Rc;
use std::io::Write;
use std::io::Result;
use std::io::Write;
use std::rc::Rc;
use build::Val;

View File

@ -409,17 +409,17 @@ extern crate serde_json;
pub mod ast;
#[macro_use]
pub mod tokenizer;
pub mod parse;
pub mod build;
pub mod convert;
pub mod error;
pub mod parse;
mod format;
pub use ast::tree::Value;
pub use ast::tree::Expression;
pub use ast::tree::Statement;
pub use ast::tree::Value;
pub use parse::parse;
pub use build::Builder;
pub use build::Val;
pub use parse::parse;

View File

@ -16,12 +16,12 @@ extern crate clap;
extern crate ucglib;
use std::fs::File;
use std::rc::Rc;
use std::io;
use std::process;
use std::rc::Rc;
use ucglib::build::Val;
use ucglib::build;
use ucglib::build::Val;
use ucglib::convert::ConverterRunner;
// TODO(jwall): List the target output types automatically.

View File

@ -13,17 +13,17 @@
// limitations under the License.
//! The Parsing stage of the ucg compiler.
use std::str::FromStr;
use std::borrow::Borrow;
use std::str::FromStr;
use nom_locate::LocatedSpan;
use nom;
use nom::InputLength;
use nom::IResult;
use nom::InputLength;
use nom_locate::LocatedSpan;
use ast::tree::*;
use tokenizer::*;
use error;
use tokenizer::*;
type NomResult<'a, O> = nom::IResult<TokenIter<'a>, O, error::Error>;
@ -844,8 +844,8 @@ mod test {
use super::*;
use tokenizer::{tokenize, TokenIter};
use nom_locate::LocatedSpan;
use nom::IResult;
use nom_locate::LocatedSpan;
macro_rules! assert_parse {
($parsemac:ident($i:expr), $out:expr) => {
@ -1801,7 +1801,7 @@ mod test {
(
make_tok!("foo", 1, 1),
Expression::Simple(Value::Selector(
make_selector!(make_expr!("bar", 1, 7) => [ make_tok!("baz", 1, 11) ] => 1, 7)
make_selector!(make_expr!("bar", 1, 7) => [ make_tok!("baz", 1, 11) ] => 1, 7),
))
)
);

View File

@ -13,12 +13,12 @@
// limitations under the License.
//! The tokenization stage of the ucg compiler.
use nom_locate::LocatedSpan;
use nom;
use nom::{alpha, digit, is_alphanumeric, multispace};
use nom::{InputIter, InputLength, Slice};
use ast::tree::*;
use error;
use nom;
use nom::{InputIter, InputLength, Slice};
use nom::{alpha, digit, is_alphanumeric, multispace};
use nom_locate::LocatedSpan;
use std;
use std::result::Result;
@ -121,16 +121,15 @@ macro_rules! do_tag_tok {
// paramater even though we don't explicitely pass it below. I don't
// particularly like this but I'm living with it for now.
($i:expr, $type:expr, $tag:expr) => {
do_parse!($i,
span: position!() >>
frag: tag!($tag) >>
(Token{
do_parse!(
$i,
span: position!() >> frag: tag!($tag) >> (Token {
typ: $type,
pos: Position::from(span),
fragment: frag.fragment.to_string(),
})
)
}
};
}
named!(emptytok( Span ) -> Token,
@ -472,34 +471,32 @@ macro_rules! match_type {
match_type!($i, PUNCT => token_clone)
};
($i:expr, $t:expr, $msg:expr, $h:expr) => {
{
($i:expr, $t:expr, $msg:expr, $h:expr) => {{
let i_ = $i.clone();
use nom::Slice;
use std::convert::Into;
if i_.input_len() == 0 {
nom::IResult::Error(
nom::ErrorKind::Custom(error::Error::new(
nom::IResult::Error(nom::ErrorKind::Custom(error::Error::new(
format!("End of Input! {}", $msg),
error::ErrorType::IncompleteParsing,
Position{line: 0, column: 0})))
Position { line: 0, column: 0 },
)))
} else {
let tok = &(i_[0]);
if tok.typ == $t {
match $h(tok) {
Result::Ok(v) => nom::IResult::Done($i.slice(1..), v),
Result::Err(e) => nom::IResult::Error(
nom::ErrorKind::Custom(e.into())),
Result::Err(e) => nom::IResult::Error(nom::ErrorKind::Custom(e.into())),
}
} else {
nom::IResult::Error(nom::ErrorKind::Custom(error::Error::new(
$msg.to_string(),
error::ErrorType::UnexpectedToken,
tok.pos.clone())))
tok.pos.clone(),
)))
}
}
}
};
}};
}
/// nom style macro that matches various Tokens by type and value and allows optional
@ -518,11 +515,16 @@ macro_rules! match_token {
};
($i:expr,BAREWORD => $f:expr, $h:expr) => {
match_token!($i, TokenType::BAREWORD, $f, format!("Not a BAREWORD ({})", $f), $h)
match_token!(
$i,
TokenType::BAREWORD,
$f,
format!("Not a BAREWORD ({})", $f),
$h
)
};
($i:expr, $t:expr, $f:expr, $msg:expr, $h:expr) => {
{
($i:expr, $t:expr, $f:expr, $msg:expr, $h:expr) => {{
let i_ = $i.clone();
use nom::Slice;
use std::convert::Into;
@ -530,17 +532,16 @@ macro_rules! match_token {
if tok.typ == $t && &tok.fragment == $f {
match $h(tok) {
Result::Ok(v) => nom::IResult::Done($i.slice(1..), v),
Result::Err(e) => nom::IResult::Error(
nom::ErrorKind::Custom(e.into())),
Result::Err(e) => nom::IResult::Error(nom::ErrorKind::Custom(e.into())),
}
} else {
nom::IResult::Error(nom::ErrorKind::Custom(error::Error::new(
format!("{} Instead is ({})", $msg, tok.fragment),
error::ErrorType::UnexpectedToken,
tok.pos.clone())))
tok.pos.clone(),
)))
}
}
};
}};
}
/// nom style macro that matches punctuation Tokens.
@ -599,7 +600,7 @@ macro_rules! impl_token_iter_slice {
}
}
}
}
};
}
impl_token_iter_slice!(std::ops::Range<usize>);
@ -713,7 +714,7 @@ mod tokenizer_test {
assert_eq!(tok.fragment, $input);
assert_eq!(tok.typ, $typ);
}
}
};
}
#[test]