From 3ffdd15b41e430c5bf65126adfd8d8736a3d55de 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 143aa6f..3f686c0 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 f9f891cd200fa5d6ba9f64e3139321f751ca88a0 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 95df472..a7bfdbe 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 141feac31c96b7832ca09339fc8a8ad1e9a3e998 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 eb6bb2e..1fb2d6a 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 1bba8120184c2ab752e0edf0669cac3609d9b137 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 1fb2d6a..3c6fc41 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 aa5000c6c8460132db254be55369ddcca744a5ef 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 f7b7b9b..59f1012 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 7ceab0d3fdc4eba6056f5aac137d9ee908ef4f91 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 a7bfdbe..16b7c86 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 acff3e2139d47e9d11f72e7810256f0ee6f52ca8 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 0000000..8b13789 --- /dev/null +++ b/resources/rickroll @@ -0,0 +1 @@ + From 087768fcbca0345682b410b8fc17c48238478407 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 3c6fc41..0730a25 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 552c793e2f425b18afb3f0eb28f9a8cf902295eb 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 8b13789..447419b 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 6a01893f2e36b76258ab36acd13b0e5e6f7be245 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 aa33fe88db5141ebb9d827543fd03d2848d47b5f 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 0730a25..f47b33a 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") } }