From 1e7ddc475e461a2ef66755f83b66ffb8e93b0fa0 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sun, 21 May 2023 11:04:41 -0700 Subject: [PATCH] Add demo eat command --- demo/demo.rpy | 3 ++- src/lib.rs | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/demo/demo.rpy b/demo/demo.rpy index 5a94c16..dbe8e1d 100644 --- a/demo/demo.rpy +++ b/demo/demo.rpy @@ -1,2 +1,3 @@ "Bob sat on the bench." -"Bob" "Good morning!" \ No newline at end of file +"Bob" "Good morning!" +eat "potato" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 252e2dd..9c7dcf5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,10 @@ pub enum Command { Say { name: Option, text: String, - } + }, + Eat { + food: String, + }, } use Command::*; @@ -124,6 +127,9 @@ pub fn parse_file(file_path: &str) -> Vec { name: Some(name.to_owned()), text: text.to_owned(), }, + [Keyword(keyword), Str(food)] if keyword.eq("eat") => Eat { + food: food.to_owned(), + }, _ => panic!("Unknown command {}", describe_line(&line)), }); }