Fix bug in parsing order for literals.
This commit is contained in:
parent
2a89fd826e
commit
de5932b4c6
@ -402,14 +402,14 @@ fn rvalue(i: &str) -> IResult<&str, RValue> {
|
||||
alt((
|
||||
map(path, RValue::RVPath),
|
||||
map(template_string_rvalue, RValue::RVTemplate),
|
||||
map(postitive_integer_literal, |num| {
|
||||
RValue::RVLiteral(OwnedLiteral::LPositiveInteger(num))
|
||||
map(float_literal, |num| {
|
||||
RValue::RVLiteral(OwnedLiteral::LFloat(num))
|
||||
}),
|
||||
map(negative_integer_literal, |num| {
|
||||
RValue::RVLiteral(OwnedLiteral::LNegativeInteger(num))
|
||||
}),
|
||||
map(float_literal, |num| {
|
||||
RValue::RVLiteral(OwnedLiteral::LFloat(num))
|
||||
map(postitive_integer_literal, |num| {
|
||||
RValue::RVLiteral(OwnedLiteral::LPositiveInteger(num))
|
||||
}),
|
||||
))(i)
|
||||
}
|
||||
@ -739,6 +739,13 @@ mod tests {
|
||||
use nom::error::ErrorKind;
|
||||
use nom::Err::Error;
|
||||
|
||||
#[test]
|
||||
fn test_direct_literal() {
|
||||
assert_eq!(super::float_literal("-17.4"), Ok(("", -17.4)));
|
||||
assert_eq!(super::float_literal("17.1"), Ok(("", 17.1)));
|
||||
assert_eq!(super::negative_integer_literal("-12"), Ok(("", -12)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_reference() {
|
||||
assert_eq!(
|
||||
|
Loading…
x
Reference in New Issue
Block a user