mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-23 18:29:50 -04:00
MAINT: Formatting cleanup.
This commit is contained in:
parent
9b5b7aa793
commit
8009c6a8a5
@ -605,9 +605,11 @@ impl MacroDef {
|
|||||||
stack.push(expr);
|
stack.push(expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&Expression::Call(ref def) => for expr in def.arglist.iter() {
|
&Expression::Call(ref def) => {
|
||||||
|
for expr in def.arglist.iter() {
|
||||||
stack.push(expr);
|
stack.push(expr);
|
||||||
},
|
}
|
||||||
|
}
|
||||||
&Expression::Simple(ref val) => {
|
&Expression::Simple(ref val) => {
|
||||||
let mut syms_set = self.validate_value_symbols(&mut stack, val);
|
let mut syms_set = self.validate_value_symbols(&mut stack, val);
|
||||||
bad_symbols.extend(syms_set.drain());
|
bad_symbols.extend(syms_set.drain());
|
||||||
|
@ -302,7 +302,8 @@ impl Builder {
|
|||||||
"Error building file: {}\n{}",
|
"Error building file: {}\n{}",
|
||||||
self.file.to_string_lossy(),
|
self.file.to_string_lossy(),
|
||||||
e.as_ref()
|
e.as_ref()
|
||||||
).as_ref(),
|
)
|
||||||
|
.as_ref(),
|
||||||
);
|
);
|
||||||
Err(Box::new(err))
|
Err(Box::new(err))
|
||||||
}
|
}
|
||||||
@ -578,12 +579,7 @@ impl Builder {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
&Val::List(ref elems) => {
|
&Val::List(ref elems) => {
|
||||||
self.lookup_in_list(
|
self.lookup_in_list(&mut stack, sl, (&next.pos, &next.fragment), elems)?;
|
||||||
&mut stack,
|
|
||||||
sl,
|
|
||||||
(&next.pos, &next.fragment),
|
|
||||||
elems
|
|
||||||
)?;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -737,7 +733,9 @@ impl Builder {
|
|||||||
left: Rc<Val>,
|
left: Rc<Val>,
|
||||||
right: Rc<Val>,
|
right: Rc<Val>,
|
||||||
) -> Result<Rc<Val>, Box<Error>> {
|
) -> Result<Rc<Val>, Box<Error>> {
|
||||||
Ok(Rc::new(Val::Boolean(left.equal(right.as_ref(), pos.clone())?)))
|
Ok(Rc::new(Val::Boolean(
|
||||||
|
left.equal(right.as_ref(), pos.clone())?,
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_not_deep_equal(
|
fn do_not_deep_equal(
|
||||||
@ -746,7 +744,9 @@ impl Builder {
|
|||||||
left: Rc<Val>,
|
left: Rc<Val>,
|
||||||
right: Rc<Val>,
|
right: Rc<Val>,
|
||||||
) -> Result<Rc<Val>, Box<Error>> {
|
) -> Result<Rc<Val>, Box<Error>> {
|
||||||
Ok(Rc::new(Val::Boolean(!left.equal(right.as_ref(), pos.clone())?)))
|
Ok(Rc::new(Val::Boolean(
|
||||||
|
!left.equal(right.as_ref(), pos.clone())?,
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_gt(&self, pos: &Position, left: Rc<Val>, right: Rc<Val>) -> Result<Rc<Val>, Box<Error>> {
|
fn do_gt(&self, pos: &Position, left: Rc<Val>, right: Rc<Val>) -> Result<Rc<Val>, Box<Error>> {
|
||||||
@ -981,7 +981,8 @@ impl Builder {
|
|||||||
let first = a.0.clone();
|
let first = a.0.clone();
|
||||||
let t = a.1.clone();
|
let t = a.1.clone();
|
||||||
(first, t.1)
|
(first, t.1)
|
||||||
}).collect(),
|
})
|
||||||
|
.collect(),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,7 +1074,7 @@ impl Builder {
|
|||||||
self.file.clone(),
|
self.file.clone(),
|
||||||
self.assets.clone(),
|
self.assets.clone(),
|
||||||
self.env.clone(),
|
self.env.clone(),
|
||||||
argvals
|
argvals,
|
||||||
)?;
|
)?;
|
||||||
return Ok(Rc::new(Val::Tuple(fields)));
|
return Ok(Rc::new(Val::Tuple(fields)));
|
||||||
}
|
}
|
||||||
@ -1184,7 +1185,7 @@ impl Builder {
|
|||||||
self.file.clone(),
|
self.file.clone(),
|
||||||
self.assets.clone(),
|
self.assets.clone(),
|
||||||
self.env.clone(),
|
self.env.clone(),
|
||||||
argvals
|
argvals,
|
||||||
)?;
|
)?;
|
||||||
if let Some(v) = Self::find_in_fieldlist(&def.field, &fields) {
|
if let Some(v) = Self::find_in_fieldlist(&def.field, &fields) {
|
||||||
match def.typ {
|
match def.typ {
|
||||||
|
@ -212,7 +212,8 @@ mod exec_test {
|
|||||||
"let script = {
|
"let script = {
|
||||||
command = \"/bin/echo\",
|
command = \"/bin/echo\",
|
||||||
};",
|
};",
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
let result = b.get_out_by_name("script").unwrap();
|
let result = b.get_out_by_name("script").unwrap();
|
||||||
let mut expected = "#!/usr/bin/env bash\n".to_string();
|
let mut expected = "#!/usr/bin/env bash\n".to_string();
|
||||||
expected.push_str("# Turn on unofficial Bash-Strict-Mode\n");
|
expected.push_str("# Turn on unofficial Bash-Strict-Mode\n");
|
||||||
@ -236,7 +237,8 @@ mod exec_test {
|
|||||||
quux = \"baz\",
|
quux = \"baz\",
|
||||||
},
|
},
|
||||||
};",
|
};",
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
let result = b.get_out_by_name("script").unwrap();
|
let result = b.get_out_by_name("script").unwrap();
|
||||||
let mut expected = "#!/usr/bin/env bash\n".to_string();
|
let mut expected = "#!/usr/bin/env bash\n".to_string();
|
||||||
expected.push_str("# Turn on unofficial Bash-Strict-Mode\n");
|
expected.push_str("# Turn on unofficial Bash-Strict-Mode\n");
|
||||||
@ -267,7 +269,8 @@ mod exec_test {
|
|||||||
{flag1 = 1},
|
{flag1 = 1},
|
||||||
],
|
],
|
||||||
};",
|
};",
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
let result = b.get_out_by_name("script").unwrap();
|
let result = b.get_out_by_name("script").unwrap();
|
||||||
let mut expected = "#!/usr/bin/env bash\n".to_string();
|
let mut expected = "#!/usr/bin/env bash\n".to_string();
|
||||||
expected.push_str("# Turn on unofficial Bash-Strict-Mode\n");
|
expected.push_str("# Turn on unofficial Bash-Strict-Mode\n");
|
||||||
|
@ -75,7 +75,8 @@ impl FlagConverter {
|
|||||||
&Val::List(ref _def) => {
|
&Val::List(ref _def) => {
|
||||||
eprintln!("Skipping List...");
|
eprintln!("Skipping List...");
|
||||||
}
|
}
|
||||||
&Val::Tuple(ref flds) => for &(ref name, ref val) in flds.iter() {
|
&Val::Tuple(ref flds) => {
|
||||||
|
for &(ref name, ref val) in flds.iter() {
|
||||||
if let &Val::Empty = val.as_ref() {
|
if let &Val::Empty = val.as_ref() {
|
||||||
self.write_flag_name(pfx, &name.val, w)?;
|
self.write_flag_name(pfx, &name.val, w)?;
|
||||||
continue;
|
continue;
|
||||||
@ -93,7 +94,8 @@ impl FlagConverter {
|
|||||||
self.write(pfx, &val, w)?;
|
self.write(pfx, &val, w)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
}
|
||||||
&Val::Macro(ref _def) => {
|
&Val::Macro(ref _def) => {
|
||||||
// This is ignored
|
// This is ignored
|
||||||
eprintln!("Skipping macro...");
|
eprintln!("Skipping macro...");
|
||||||
|
@ -40,8 +40,7 @@ impl JsonConverter {
|
|||||||
) -> std::io::Result<serde_json::Value> {
|
) -> std::io::Result<serde_json::Value> {
|
||||||
let mut mp = serde_json::Map::new();
|
let mut mp = serde_json::Map::new();
|
||||||
for &(ref k, ref v) in items.iter() {
|
for &(ref k, ref v) in items.iter() {
|
||||||
mp.entry(k.val.clone())
|
mp.entry(k.val.clone()).or_insert(self.convert_value(v)?);
|
||||||
.or_insert(self.convert_value(v)?);
|
|
||||||
}
|
}
|
||||||
Ok(serde_json::Value::Object(mp))
|
Ok(serde_json::Value::Object(mp))
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,7 @@ impl TomlConverter {
|
|||||||
fn convert_tuple(&self, items: &Vec<(ast::PositionedItem<String>, Rc<Val>)>) -> ConvertResult {
|
fn convert_tuple(&self, items: &Vec<(ast::PositionedItem<String>, Rc<Val>)>) -> ConvertResult {
|
||||||
let mut mp = toml::value::Table::new();
|
let mut mp = toml::value::Table::new();
|
||||||
for &(ref k, ref v) in items.iter() {
|
for &(ref k, ref v) in items.iter() {
|
||||||
mp.entry(k.val.clone())
|
mp.entry(k.val.clone()).or_insert(self.convert_value(v)?);
|
||||||
.or_insert(self.convert_value(v)?);
|
|
||||||
}
|
}
|
||||||
Ok(toml::Value::Table(mp))
|
Ok(toml::Value::Table(mp))
|
||||||
}
|
}
|
||||||
|
@ -538,7 +538,8 @@ fn tuple_to_macro<'a>(
|
|||||||
.map(|s| PositionedItem {
|
.map(|s| PositionedItem {
|
||||||
pos: s.pos().clone(),
|
pos: s.pos().clone(),
|
||||||
val: s.to_string(),
|
val: s.to_string(),
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
match val {
|
match val {
|
||||||
Value::Tuple(v) => Ok(Expression::Macro(MacroDef {
|
Value::Tuple(v) => Ok(Expression::Macro(MacroDef {
|
||||||
argdefs: arglist,
|
argdefs: arglist,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user