From 67b9c8c52526042ecea6402fde4dc30d0589075f Mon Sep 17 00:00:00 2001 From: hellerve Date: Wed, 24 May 2017 13:34:45 -0400 Subject: [PATCH] ast: better representation --- src/main.rs | 66 ++++++++--------------------------------------------- 1 file changed, 9 insertions(+), 57 deletions(-) diff --git a/src/main.rs b/src/main.rs index ae4cf06..c817533 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,61 +3,13 @@ use std::io; use std::io::Read; use std::env; -enum Exec { -/*Addition operation*/ - ADD(0, "add"), -/*Subtraction operation*/ - SUB(0, "sub"), -/*Multiplication operation*/ - MULT(0, "mult"), -/*Division operation*/ - DIV(0, "div"), -/*Modulo operation*/ - MOD(0, "mod"), -/*< operation*/ - LT(0, "lt"), -/*== operation*/ - EQ(0, "eq"), -/*> operation*/ - GT(0, "gt"), -/*branch operation*/ - BR(1, "br"), -/*branch if true operation*/ - BRT(1, "brt"), -/*branch if false operation*/ - BRF(1, "brf"), -/*put operation*/ - CONST(1, "const"), -/*load variable operation*/ - LOAD(1, "load"), -/*load global variable operation*/ - GLOAD(1, "gload"), -/*store variable operation*/ - STORE(1, "store"), -/*store global variable operation*/ - GSTORE(1, "gstore"), -/*print operation*/ - PRINT(0, "print"), -/*pop operation*/ - POP(0, "pop"), -/*end/halt operation*/ - HALT(0, "halt"), -/*<= operation*/ - LEQ(0, "leq"), -/*>= operation*/ - GEQ(0, "geq"), -/*call subroutine operation*/ - CALL(2, "call"), -/*return from subroutine operation*/ - RET(0, "ret"), -/*print integer operation*/ - IPRINT(0, "iprint"), -/*fetch operation*/ - FETCH(0, "fetch"), -/*++ operation*/ - INC(0, "inc"), -/*-- operation*/ - DEC(0, "dec") +const EXEC: [(i32, (&'static str, i32)); 1] = [ + (0, ("add", 0)) +]; + +struct Exec { + arguments: i32, + name: String } fn usage(pname: String) { @@ -95,9 +47,9 @@ fn main() { println!("{}", e); return; } - } + }; let parsed = parse(contents); - let execd = exec(contents); + let execd = exec(parsed); }