Working reading
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
init() {
|
||||
|
||||
$link -> $counter
|
||||
|
||||
}
|
||||
|
||||
increment(x) {
|
||||
|
||||
ADD $counter, %x, $counter
|
||||
MOV $counter, %r
|
||||
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
increment(5)
|
||||
increment(3)
|
||||
|
||||
PRINT $counter, -> $link
|
||||
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
use std::path::Path;
|
||||
|
||||
use archforge::runtime::Runtime;
|
||||
|
||||
fn main() {
|
||||
let mut runtime = Runtime::new();
|
||||
|
||||
runtime.execute_script(Path::new("example.forge"));
|
||||
|
||||
runtime.call_function("main", vec![]);
|
||||
}
|
||||
|
||||
+3
-3
@@ -116,9 +116,7 @@ fn parse_operand(pair: Pair<Rule>) -> Operand {
|
||||
match pair.as_rule() {
|
||||
Rule::number => Operand::Number(pair.as_str().parse().unwrap()),
|
||||
|
||||
Rule::global_reg | Rule::local_reg => Operand::Reg(parse_reg(pair)),
|
||||
|
||||
Rule::reg => Operand::Reg(parse_reg(pair.into_inner().next().unwrap())),
|
||||
Rule::reg | Rule::global_reg | Rule::local_reg => Operand::Reg(parse_reg(pair)),
|
||||
|
||||
Rule::pointer_expr => {
|
||||
let inner = pair.into_inner().next().unwrap();
|
||||
@@ -135,6 +133,8 @@ fn parse_reg(pair: Pair<Rule>) -> Reg {
|
||||
|
||||
Rule::local_reg => Reg::Local(pair.as_str()[1..].to_string()),
|
||||
|
||||
Rule::reg => parse_reg(pair.into_inner().next().unwrap()),
|
||||
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user