From aabc169cf496ae3e1d285ec163a248818c56cacb Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 8 Jun 2020 21:47:14 +0200 Subject: chore: init parser --- src/parser/mod.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/parser/mod.rs (limited to 'src/parser/mod.rs') diff --git a/src/parser/mod.rs b/src/parser/mod.rs new file mode 100644 index 0000000..4cf7e00 --- /dev/null +++ b/src/parser/mod.rs @@ -0,0 +1,33 @@ +pub enum CommandType { + Label, + Mov, + Add, +} + +pub enum CommandArgsType { + Nil, + Label, + NotLabel, +} + +pub struct CommandArgs { + arg_type: CommandArgsType, + args_vec: Vec, +} + +pub struct Row { + pub command: CommandType, + pub args: CommandArgs, +} + +#[test] +fn check_row() { + let r: Row = Row { + command: CommandType::Mov, + args: CommandArgs { + arg_type: CommandArgsType::NotLabel, + args_vec: vec!["r0".to_string(), "r1".to_string()], + }, + }; + assert_eq!(r.args.args_vec[0], "r0"); +} -- cgit v1.2.3-18-g5258