Add trailing commas to match arm blocks
This commit is contained in:
parent
f0ab317961
commit
bcfce4aaec
@ -2,4 +2,5 @@ edition = "2018"
|
|||||||
reorder_imports=true
|
reorder_imports=true
|
||||||
reorder_modules=true
|
reorder_modules=true
|
||||||
format_strings=true
|
format_strings=true
|
||||||
merge_imports=true
|
merge_imports=true
|
||||||
|
match_block_trailing_comma=true
|
@ -77,7 +77,7 @@ fn char_to_partial_token(c: char) -> PartialToken {
|
|||||||
} else {
|
} else {
|
||||||
PartialToken::Literal(c.to_string())
|
PartialToken::Literal(c.to_string())
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ fn resolve_literals(mut tokens: &[PartialToken]) -> Result<Vec<Token>, Error> {
|
|||||||
PartialToken::Token(token) => {
|
PartialToken::Token(token) => {
|
||||||
cutoff = 1;
|
cutoff = 1;
|
||||||
Some(token)
|
Some(token)
|
||||||
}
|
},
|
||||||
PartialToken::Literal(literal) => {
|
PartialToken::Literal(literal) => {
|
||||||
cutoff = 1;
|
cutoff = 1;
|
||||||
if let Ok(number) = literal.parse::<IntType>() {
|
if let Ok(number) = literal.parse::<IntType>() {
|
||||||
@ -195,11 +195,11 @@ fn resolve_literals(mut tokens: &[PartialToken]) -> Result<Vec<Token>, Error> {
|
|||||||
} else {
|
} else {
|
||||||
Some(Token::Identifier(literal.to_string()))
|
Some(Token::Identifier(literal.to_string()))
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
PartialToken::Whitespace => {
|
PartialToken::Whitespace => {
|
||||||
cutoff = 1;
|
cutoff = 1;
|
||||||
None
|
None
|
||||||
}
|
},
|
||||||
PartialToken::Eq => match second {
|
PartialToken::Eq => match second {
|
||||||
Some(PartialToken::Eq) => Some(Token::Eq),
|
Some(PartialToken::Eq) => Some(Token::Eq),
|
||||||
_ => return Err(Error::unmatched_partial_token(first, second)),
|
_ => return Err(Error::unmatched_partial_token(first, second)),
|
||||||
@ -209,21 +209,21 @@ fn resolve_literals(mut tokens: &[PartialToken]) -> Result<Vec<Token>, Error> {
|
|||||||
_ => {
|
_ => {
|
||||||
cutoff = 1;
|
cutoff = 1;
|
||||||
Some(Token::Not)
|
Some(Token::Not)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
PartialToken::Gt => match second {
|
PartialToken::Gt => match second {
|
||||||
Some(PartialToken::Eq) => Some(Token::Geq),
|
Some(PartialToken::Eq) => Some(Token::Geq),
|
||||||
_ => {
|
_ => {
|
||||||
cutoff = 1;
|
cutoff = 1;
|
||||||
Some(Token::Gt)
|
Some(Token::Gt)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
PartialToken::Lt => match second {
|
PartialToken::Lt => match second {
|
||||||
Some(PartialToken::Eq) => Some(Token::Leq),
|
Some(PartialToken::Eq) => Some(Token::Leq),
|
||||||
_ => {
|
_ => {
|
||||||
cutoff = 1;
|
cutoff = 1;
|
||||||
Some(Token::Lt)
|
Some(Token::Lt)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
PartialToken::Ampersand => match second {
|
PartialToken::Ampersand => match second {
|
||||||
Some(PartialToken::Ampersand) => Some(Token::And),
|
Some(PartialToken::Ampersand) => Some(Token::And),
|
||||||
|
@ -97,7 +97,7 @@ pub fn tokens_to_operator_tree(tokens: Vec<Token>) -> Result<Node, Error> {
|
|||||||
} else {
|
} else {
|
||||||
Some(Node::new(Neg))
|
Some(Node::new(Neg))
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
Token::Star => Some(Node::new(Mul)),
|
Token::Star => Some(Node::new(Mul)),
|
||||||
Token::Slash => Some(Node::new(Div)),
|
Token::Slash => Some(Node::new(Div)),
|
||||||
Token::Percent => Some(Node::new(Mod)),
|
Token::Percent => Some(Node::new(Mod)),
|
||||||
@ -116,14 +116,14 @@ pub fn tokens_to_operator_tree(tokens: Vec<Token>) -> Result<Node, Error> {
|
|||||||
Token::LBrace => {
|
Token::LBrace => {
|
||||||
root.push(Node::root_node());
|
root.push(Node::root_node());
|
||||||
None
|
None
|
||||||
}
|
},
|
||||||
Token::RBrace => {
|
Token::RBrace => {
|
||||||
if root.len() < 2 {
|
if root.len() < 2 {
|
||||||
return Err(Error::UnmatchedRBrace);
|
return Err(Error::UnmatchedRBrace);
|
||||||
} else {
|
} else {
|
||||||
root.pop()
|
root.pop()
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
Token::Comma => Some(Node::new(Tuple)),
|
Token::Comma => Some(Node::new(Tuple)),
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ pub fn tokens_to_operator_tree(tokens: Vec<Token>) -> Result<Node, Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
},
|
||||||
Token::Float(number) => Some(Node::new(Const::new(Value::Float(number)))),
|
Token::Float(number) => Some(Node::new(Const::new(Value::Float(number)))),
|
||||||
Token::Int(number) => Some(Node::new(Const::new(Value::Int(number)))),
|
Token::Int(number) => Some(Node::new(Const::new(Value::Int(number)))),
|
||||||
Token::Boolean(boolean) => Some(Node::new(Const::new(Value::Boolean(boolean)))),
|
Token::Boolean(boolean) => Some(Node::new(Const::new(Value::Boolean(boolean)))),
|
||||||
|
@ -20,7 +20,7 @@ impl Display for Value {
|
|||||||
value.fmt(f)?;
|
value.fmt(f)?;
|
||||||
}
|
}
|
||||||
write!(f, ")")
|
write!(f, ")")
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user