summaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
authorSanto Cariotti <dcariotti24@gmail.com>2020-06-08 21:47:14 +0200
committerSanto Cariotti <dcariotti24@gmail.com>2020-06-08 21:50:55 +0200
commitaabc169cf496ae3e1d285ec163a248818c56cacb (patch)
tree705db93f98f077fceb8899d3cf014cf0c2b526c8 /src/parser
parentf28e2cf215dcc25fa39ed9460a26ef9be76ff81e (diff)
chore: init parser
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/mod.rs33
1 files changed, 33 insertions, 0 deletions
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<String>,
+}
+
+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");
+}