Fix parsing of subtractions and negations in the absence of space.

This commit is contained in:
KtorZ
2023-01-21 12:43:11 +01:00
parent bb360cd7c8
commit 333a990249
2 changed files with 111 additions and 7 deletions

View File

@@ -7,13 +7,7 @@ use ordinal::Ordinal;
use super::{error::ParseError, token::Token};
pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, Error = ParseError> {
let int = choice((
text::int(10),
just("-")
.ignore_then(text::int(10))
.map(|value: String| format!("-{}", &value)),
))
.map(|value| Token::Int { value });
let int = text::int(10).map(|value| Token::Int { value });
let ordinal = text::int(10)
.from_str()