From 1d91e68b05ba7e2339483343dcba9152c1102d9c Mon Sep 17 00:00:00 2001 From: Erin Date: Wed, 4 Jan 2023 15:30:03 +0100 Subject: [PATCH] shorten file --- ablescript/src/lexer.rs | 151 ++++++++++------------------------------ 1 file changed, 37 insertions(+), 114 deletions(-) diff --git a/ablescript/src/lexer.rs b/ablescript/src/lexer.rs index a450c76b..6c661877 100644 --- a/ablescript/src/lexer.rs +++ b/ablescript/src/lexer.rs @@ -1,137 +1,60 @@ use logos::{Lexer, Logos}; #[derive(Logos, Debug, PartialEq, Eq, Clone)] +#[rustfmt::skip] pub enum Token { // Symbols - #[token("(")] - LeftParen, - - #[token(")")] - RightParen, - - #[token("[")] - LeftBracket, - - #[token("]")] - RightBracket, - - #[token("{")] - LeftCurly, - - #[token("}")] - RightCurly, - - #[token(";")] - Semicolon, - - #[token(",")] - Comma, + #[token("(")] LeftParen, + #[token(")")] RightParen, + #[token("[")] LeftBracket, + #[token("]")] RightBracket, + #[token("{")] LeftCurly, + #[token("}")] RightCurly, + #[token(";")] Semicolon, + #[token(",")] Comma, // Operators - #[token("+")] - Plus, - - #[token("-")] - Minus, - - #[token("*")] - Star, - - #[token("/")] - FwdSlash, - - #[token("=:")] - Assign, - - #[token("<=")] - Arrow, + #[token("+")] Plus, + #[token("-")] Minus, + #[token("*")] Star, + #[token("/")] FwdSlash, + #[token("=:")] Assign, + #[token("<=")] Arrow, // Logical operators - #[token("<")] - LessThan, - - #[token(">")] - GreaterThan, - - #[token("=")] - Equals, - - #[token("ain't")] - Aint, + #[token("<")] LessThan, + #[token(">")] GreaterThan, + #[token("=")] Equals, + #[token("ain't")] Aint, // Keywords - #[token("functio")] - Functio, - - /// Brain fuck FFI - #[token("bff")] - Bff, - - /// Variable bro - #[token("dim")] - Dim, - - /// Prints the preceding things - #[token("print")] - Print, - - /// Read input into preceding variable - #[token("read")] - Read, - - /// Ban the following variable from ever being used again - #[token("melo")] - Melo, - - #[token("T-Dark")] - TDark, + #[token("functio")] Functio, + #[token("bff")] Bff, + #[token("dim")] Dim, + #[token("print")] Print, + #[token("read")] Read, + #[token("melo")] Melo, + #[token("T-Dark")] TDark, // Control flow keywords - #[token("unless")] - Unless, + #[token("unless")] Unless, + #[token("loop")] Loop, + #[token("enough")] Enough, + #[token("and again")] AndAgain, + #[token("finally")] Finally, + #[token("rlyeh")] Rlyeh, - #[token("loop")] - Loop, - - /// Break out of the loop - #[token("enough")] - Enough, - - /// Jump at the start of the loop - #[token("and again")] - AndAgain, - - /// Run at the end of the program - #[token("finally")] - Finally, - - /// Crash with random error (see discussion #17) - #[token("rlyeh")] - Rlyeh, - - #[token("rickroll")] - Rickroll, + #[token("rickroll")] Rickroll, // Literals - /// String - #[token("/*", get_string)] - String(String), - - /// Integer - #[regex(r"-?[0-9]+", get_value)] - Integer(isize), - - // A character (to be base-55 converted) - #[regex(r"\p{XID_Start}", get_value)] - Char(char), - - /// An identifier + #[token("/*", get_string)] String(String), + #[regex(r"-?[0-9]+", get_value)] Integer(isize), + #[regex(r"\p{XID_Start}", get_value)] Char(char), #[regex(r"\p{XID_Start}[\p{XID_Continue}]+", get_ident)] #[token("and ", |_| "and".to_owned())] Identifier(String), - #[regex(r"owo .*")] - Comment, + #[regex(r"owo .*")] Comment, #[regex(r"[ \t\n\f]+", logos::skip)] #[error]