From 855383faac38f57a17e757696e67b9e515168bc3 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Sun, 13 Jun 2021 13:11:02 +0800 Subject: [PATCH 01/11] add `rickroll` lexeme in lexer --- src/lexer.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lexer.rs b/src/lexer.rs index 143aa6f3..3f686c07 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -111,6 +111,9 @@ pub enum Token { #[token("rlyeh")] Rlyeh, + #[token("rickroll")] + Rickroll, + // Literals /// True, False #[regex("true|false", get_bool)] From 286a12b28e54db117dc77b27bae225dbb58404aa Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Sun, 13 Jun 2021 13:11:51 +0800 Subject: [PATCH 02/11] add `StmtKind::Rickroll` --- src/ast.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ast.rs b/src/ast.rs index 95df4728..a7bfdbe5 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -75,6 +75,7 @@ pub enum StmtKind { Print(Expr), Melo(Iden), Rlyeh, + Rickroll } impl Stmt { From 3646c5e32ec3fc417eaf7b0ecf8fcaee1d273c70 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Sun, 13 Jun 2021 13:22:01 +0800 Subject: [PATCH 03/11] handle `StmtKind::Rickroll` --- src/interpret.rs | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/interpret.rs b/src/interpret.rs index eb6bb2e4..1fb2d6aa 100644 --- a/src/interpret.rs +++ b/src/interpret.rs @@ -305,6 +305,75 @@ impl ExecEnv { // here at some point. ~~Alex exit(random()); } + StmtKind::Rickroll => { + stdout().write_all(b"We're no strangers to love +You know the rules and so do I +A full commitments what I'm thinking of +You wouldn't get this from another guy + +I just wanna tell you how I'm feeling +Gotta make you understand + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +We've known each other for so long +Your heart's been aching but you're too shy to say it +Inside we both know what's been going on +We know the game and we're gonna play it + +And if you ask me how I'm feeling +Don't tell me you're too blind to see + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +Never gonna give, never gonna give +(Give you up) + +We've known each other for so long +Your heart's been aching but you're too shy to say it +Inside we both know what's been going on +We know the game and we're gonna play it + +I just wanna tell you how I'm feeling +Gotta make you understand + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye").expect("Failed to write to stdout") + } } Ok(HaltStatus::Finished) From fa0d3968f542563f45b6892b97e56a40120b9b28 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Sun, 13 Jun 2021 13:22:30 +0800 Subject: [PATCH 04/11] Update interpret.rs --- src/interpret.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/interpret.rs b/src/interpret.rs index 1fb2d6aa..3c6fc41b 100644 --- a/src/interpret.rs +++ b/src/interpret.rs @@ -306,6 +306,7 @@ impl ExecEnv { exit(random()); } StmtKind::Rickroll => { + // possibly move the entire rickroll string into a constant? ~~HTGAzureX1212. stdout().write_all(b"We're no strangers to love You know the rules and so do I A full commitments what I'm thinking of From 227fa8e35ba14399e23088037d1d74f95625098e Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Sun, 13 Jun 2021 13:24:09 +0800 Subject: [PATCH 05/11] handle `Token::Rickroll` in parser --- src/parser.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index f7b7b9b1..59f10120 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -78,6 +78,10 @@ impl<'source> Parser<'source> { self.semi_terminated(StmtKind::Rlyeh)?, start..self.lexer.span().end, )), + Token::Rickroll => Ok(Stmt::new( + self.semi_terminated(StmtKind::Rickroll)?, + start..self.lexer.span().end + )), Token::Identifier(_) | Token::Char From 72e48d1b86c723583e7478362f12d0c6070e0519 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Mon, 14 Jun 2021 09:40:42 +0800 Subject: [PATCH 06/11] `rustfmt`: add trailing comma --- src/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ast.rs b/src/ast.rs index a7bfdbe5..16b7c861 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -75,7 +75,7 @@ pub enum StmtKind { Print(Expr), Melo(Iden), Rlyeh, - Rickroll + Rickroll, } impl Stmt { From 712e6cef6778da3ec4d9693d675fbde101518a1e Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Mon, 14 Jun 2021 09:41:20 +0800 Subject: [PATCH 07/11] Create rickroll --- resources/rickroll | 1 + 1 file changed, 1 insertion(+) create mode 100644 resources/rickroll diff --git a/resources/rickroll b/resources/rickroll new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/resources/rickroll @@ -0,0 +1 @@ + From b526d5c57539683414f18f4a82927779b2dff3c7 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Mon, 14 Jun 2021 09:42:23 +0800 Subject: [PATCH 08/11] move `rickroll` content into a file --- src/interpret.rs | 69 +----------------------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/src/interpret.rs b/src/interpret.rs index 3c6fc41b..0730a259 100644 --- a/src/interpret.rs +++ b/src/interpret.rs @@ -306,74 +306,7 @@ impl ExecEnv { exit(random()); } StmtKind::Rickroll => { - // possibly move the entire rickroll string into a constant? ~~HTGAzureX1212. - stdout().write_all(b"We're no strangers to love -You know the rules and so do I -A full commitments what I'm thinking of -You wouldn't get this from another guy - -I just wanna tell you how I'm feeling -Gotta make you understand - -Never gonna give you up -Never gonna let you down -Never gonna run around and desert you -Never gonna make you cry -Never gonna say goodbye -Never gonna tell a lie and hurt you - -We've known each other for so long -Your heart's been aching but you're too shy to say it -Inside we both know what's been going on -We know the game and we're gonna play it - -And if you ask me how I'm feeling -Don't tell me you're too blind to see - -Never gonna give you up -Never gonna let you down -Never gonna run around and desert you -Never gonna make you cry -Never gonna say goodbye -Never gonna tell a lie and hurt you - -Never gonna give you up -Never gonna let you down -Never gonna run around and desert you -Never gonna make you cry -Never gonna say goodbye -Never gonna tell a lie and hurt you - -Never gonna give, never gonna give -(Give you up) - -We've known each other for so long -Your heart's been aching but you're too shy to say it -Inside we both know what's been going on -We know the game and we're gonna play it - -I just wanna tell you how I'm feeling -Gotta make you understand - -Never gonna give you up -Never gonna let you down -Never gonna run around and desert you -Never gonna make you cry -Never gonna say goodbye -Never gonna tell a lie and hurt you - -Never gonna give you up -Never gonna let you down -Never gonna run around and desert you -Never gonna make you cry -Never gonna say goodbye -Never gonna tell a lie and hurt you - -Never gonna give you up -Never gonna let you down -Never gonna run around and desert you -Never gonna make you cry -Never gonna say goodbye").expect("Failed to write to stdout") + stdout().write_all(include_str!("../resources/rickroll").as_bytes()).expect("Failed to write to stdout") } } From 953128887ba647dba91f7e85c791846fd59fdbd8 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Mon, 14 Jun 2021 09:42:38 +0800 Subject: [PATCH 09/11] Update rickroll --- resources/rickroll | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/resources/rickroll b/resources/rickroll index 8b137891..447419bd 100644 --- a/resources/rickroll +++ b/resources/rickroll @@ -1 +1,67 @@ +b"We're no strangers to love +You know the rules and so do I +A full commitments what I'm thinking of +You wouldn't get this from another guy +I just wanna tell you how I'm feeling +Gotta make you understand + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +We've known each other for so long +Your heart's been aching but you're too shy to say it +Inside we both know what's been going on +We know the game and we're gonna play it + +And if you ask me how I'm feeling +Don't tell me you're too blind to see + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +Never gonna give, never gonna give +(Give you up) + +We've known each other for so long +Your heart's been aching but you're too shy to say it +Inside we both know what's been going on +We know the game and we're gonna play it + +I just wanna tell you how I'm feeling +Gotta make you understand + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye +Never gonna tell a lie and hurt you + +Never gonna give you up +Never gonna let you down +Never gonna run around and desert you +Never gonna make you cry +Never gonna say goodbye" From 26df745deed70de3af3eba1240f1be25ffb72a5e Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Mon, 14 Jun 2021 20:52:38 +0800 Subject: [PATCH 10/11] move `rickroll` to `src/` folder --- {resources => src}/rickroll | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {resources => src}/rickroll (100%) diff --git a/resources/rickroll b/src/rickroll similarity index 100% rename from resources/rickroll rename to src/rickroll From aa729450106a5b3dc0dcb552eeadb24860dcd594 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Mon, 14 Jun 2021 20:53:27 +0800 Subject: [PATCH 11/11] comply with the move of `rickroll` --- src/interpret.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interpret.rs b/src/interpret.rs index 0730a259..f47b33ad 100644 --- a/src/interpret.rs +++ b/src/interpret.rs @@ -306,7 +306,7 @@ impl ExecEnv { exit(random()); } StmtKind::Rickroll => { - stdout().write_all(include_str!("../resources/rickroll").as_bytes()).expect("Failed to write to stdout") + stdout().write_all(include_str!("rickroll").as_bytes()).expect("Failed to write to stdout") } }