From 2cc6ff7e968fd7d48a9371d3152ff79c83d2b314 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Fri, 13 Mar 2026 16:21:01 +0100 Subject: [PATCH] Working simple parser --- examples/emulator.rs | 13 +++++++++++++ src/parser/mod.rs | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 examples/emulator.rs diff --git a/examples/emulator.rs b/examples/emulator.rs new file mode 100644 index 0000000..6469ccf --- /dev/null +++ b/examples/emulator.rs @@ -0,0 +1,13 @@ +use archforge::parser::parse_program; + +fn main() { + let p = parse_program("increment(x) { + ADD $counter, %x, $counter + } + + main() { + increment(5) + }").unwrap(); + + println!("{p:?}"); +} \ No newline at end of file diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 3a085f2..65552c3 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -118,6 +118,8 @@ fn parse_operand(pair: Pair) -> Operand { Rule::global_reg | Rule::local_reg => Operand::Reg(parse_reg(pair)), + Rule::reg => Operand::Reg(parse_reg(pair.into_inner().next().unwrap())), + Rule::pointer_expr => { let inner = pair.into_inner().next().unwrap(); Operand::Pointer(Box::new(parse_operand(inner)))