BRANCHING (TURING COMPLETE????)

This commit is contained in:
2025-03-29 15:08:15 -04:00
parent 021434d2f1
commit f57af3b2b5
25 changed files with 780 additions and 486 deletions
+14 -2
View File
@@ -1,4 +1,4 @@
use super::{Node, PIdent, Parsable, ParseResult, ParserCtx, Symbol, CompilerMsg};
use super::{CompilerMsg, Node, PIdent, Parsable, ParseResult, ParserCtx, Symbol};
pub struct PInstruction {
pub op: Node<PIdent>,
@@ -36,7 +36,19 @@ impl Parsable for PAsmArg {
return ParseResult::Ok(Self::Value(ident));
}
let next = ctx.expect_peek()?;
let mut next = ctx.expect_peek()?;
if next.is_symbol(Symbol::Minus) {
ctx.next();
if let Some(mut ident) = ctx.maybe_parse::<PIdent>() {
// TODO: this is so messed up
if let Some(i) = ident.as_mut() {
i.0.insert(0, '-')
}
return ParseResult::Ok(Self::Value(ident));
}
next = ctx.expect_peek()?;
}
if !next.is_symbol(Symbol::OpenCurly) {
return ParseResult::Err(CompilerMsg::unexpected_token(
next,