mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-25 18:49:50 -04:00
Cleanup: formatting and todos
cargo fmt changed a fixme to a todo
This commit is contained in:
parent
594e14cd0f
commit
389f395383
10
src/ast.rs
10
src/ast.rs
@ -54,8 +54,8 @@ macro_rules! value_node {
|
||||
};
|
||||
}
|
||||
|
||||
pub type FieldList = Vec<(Token, Expression)>; // str is expected to be a symbol
|
||||
pub type SelectorList = Vec<Token>; // str is expected to always be a symbol.
|
||||
pub type FieldList = Vec<(Token, Expression)>; // Token is expected to be a symbol
|
||||
pub type SelectorList = Vec<Token>; // Token is expected to always be a symbol.
|
||||
|
||||
#[derive(Debug,PartialEq,Clone)]
|
||||
pub struct LocatedNode<T> {
|
||||
@ -497,11 +497,7 @@ mod ast_test {
|
||||
#[test]
|
||||
pub fn test_macro_validation_selector_fail() {
|
||||
let def = MacroDef {
|
||||
argdefs: vec![Positioned::new("foo".to_string(),
|
||||
Position {
|
||||
line: 1,
|
||||
column: 0,
|
||||
})],
|
||||
argdefs: vec![Positioned::new("foo".to_string(), Position {line: 1, column: 0})],
|
||||
fields: vec![
|
||||
(Token::new("f1", Position{line: 1, column: 1}), Expression::Binary(BinaryOpDef{
|
||||
kind: BinaryExprType::Add,
|
||||
|
33
src/build.rs
33
src/build.rs
@ -444,7 +444,7 @@ impl Builder {
|
||||
}
|
||||
}
|
||||
&Val::List(ref elems) => {
|
||||
// FIXME(jwall): better error reporting here would probably be good.
|
||||
// TODO(jwall): better error reporting here would probably be good.
|
||||
let idx = try!(next.fragment.parse::<usize>());
|
||||
if idx < elems.len() {
|
||||
stack.push_back(elems[idx].clone());
|
||||
@ -943,13 +943,20 @@ mod test {
|
||||
]
|
||||
))),
|
||||
])));
|
||||
b.out.entry(Positioned::new("var2".to_string(),
|
||||
Position {line: 1, column: 0}))
|
||||
b.out
|
||||
.entry(Positioned::new("var2".to_string(),
|
||||
Position {
|
||||
line: 1,
|
||||
column: 0,
|
||||
}))
|
||||
.or_insert(Rc::new(Val::Int(2)));
|
||||
b.out.entry(Positioned::new("var3".to_string(),
|
||||
Position {line: 1, column: 0}))
|
||||
.or_insert(Rc::new(Val::Tuple(
|
||||
vec![(Positioned::new("lvl1".to_string(),
|
||||
b.out
|
||||
.entry(Positioned::new("var3".to_string(),
|
||||
Position {
|
||||
line: 1,
|
||||
column: 0,
|
||||
}))
|
||||
.or_insert(Rc::new(Val::Tuple(vec![(Positioned::new("lvl1".to_string(),
|
||||
Position {line: 1, column: 0}),
|
||||
Rc::new(Val::Int(4)))])));
|
||||
|
||||
@ -985,8 +992,13 @@ mod test {
|
||||
#[test]
|
||||
fn test_eval_selector_list_expr() {
|
||||
let mut b = Builder::new();
|
||||
b.out.entry(Positioned::new("var1".to_string(), Position{line: 1, column: 1})).or_insert(Rc::new(Val::List(
|
||||
vec![
|
||||
b.out
|
||||
.entry(Positioned::new("var1".to_string(),
|
||||
Position {
|
||||
line: 1,
|
||||
column: 1,
|
||||
}))
|
||||
.or_insert(Rc::new(Val::List(vec![
|
||||
Rc::new(Val::String("val1".to_string())),
|
||||
Rc::new(Val::Tuple(vec![
|
||||
(Positioned::new("var2".to_string(), Position{line: 1, column: 1}),
|
||||
@ -1001,7 +1013,8 @@ mod test {
|
||||
Token::new("0", Position{line: 1, column: 1})
|
||||
], 1, 1))),
|
||||
Val::String("val1".to_string()))
|
||||
], b);
|
||||
],
|
||||
b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -27,11 +27,9 @@ pub struct ConverterRunner {
|
||||
impl ConverterRunner {
|
||||
pub fn new(typ: &str) -> Result<Self, String> {
|
||||
if typ == "flags" {
|
||||
return Ok(ConverterRunner {
|
||||
converter: Box::new(flags::FlagConverter::new()),
|
||||
});
|
||||
return Ok(ConverterRunner { converter: Box::new(flags::FlagConverter::new()) });
|
||||
}
|
||||
return Err(format!("Unknown Target output type: {}", typ))
|
||||
return Err(format!("Unknown Target output type: {}", typ));
|
||||
}
|
||||
|
||||
pub fn convert(&self, v: Rc<Val>, w: Box<Write>) -> io::Result<()> {
|
||||
|
11
src/parse.rs
11
src/parse.rs
@ -175,11 +175,11 @@ pub fn selector_or_symbol(input: Span) -> IResult<Span, Value> {
|
||||
match sym {
|
||||
IResult::Incomplete(i) => {
|
||||
return IResult::Incomplete(i);
|
||||
},
|
||||
}
|
||||
IResult::Error(_) => {
|
||||
// TODO(jwall): Maybe be smarter about the error reporting here?
|
||||
return ws!(input, selector_value);
|
||||
},
|
||||
}
|
||||
IResult::Done(rest, val) => {
|
||||
return IResult::Done(rest, val);
|
||||
}
|
||||
@ -555,10 +555,10 @@ pub fn parse(input: Span) -> IResult<Span, Vec<Statement>> {
|
||||
match ws!(i, statement) {
|
||||
IResult::Error(e) => {
|
||||
return IResult::Error(e);
|
||||
},
|
||||
}
|
||||
IResult::Incomplete(i) => {
|
||||
return IResult::Incomplete(i);
|
||||
},
|
||||
}
|
||||
IResult::Done(rest, stmt) => {
|
||||
out.push(stmt);
|
||||
i = rest;
|
||||
@ -576,7 +576,8 @@ pub fn parse(input: Span) -> IResult<Span, Vec<Statement>> {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::{Statement, Expression, Value, MacroDef, SelectDef, CallDef};
|
||||
use super::{number, symbol, parse, field_value, selector_value, selector_or_symbol, tuple, grouped_expression, list_expression};
|
||||
use super::{number, symbol, parse, field_value, selector_value, selector_or_symbol, tuple,
|
||||
grouped_expression, list_expression};
|
||||
use super::{copy_expression, macro_expression, select_expression};
|
||||
use super::{format_expression, call_expression, expression};
|
||||
use super::{expression_statement, let_statement, import_statement, statement};
|
||||
|
Loading…
x
Reference in New Issue
Block a user