feat: support negation of int

* add unary op
* parse, typecheck, and code gen it
* express boolean not as unary op as well, previously called negate

Co-authored-by: rvcas <x@rvcas.dev>
This commit is contained in:
Kasey White
2022-12-27 20:30:50 -05:00
committed by Lucas
parent 542e39f093
commit 083b7fcb5f
8 changed files with 72 additions and 36 deletions

View File

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