owo_code/
lib.rs

1//! No documentation right now because I cannot be bothered. I mean, *does* this
2//! really need any documentation, doesn't the README.md explain the 79 lines of
3//! code well enough, lol? Also hi there, hope you've been having a good day.
4
5use proc_macro::{Group, Ident, TokenStream, TokenTree};
6
7/// Macro for a macro. Nice.
8macro_rules! replace_keywords {
9	($upon:ident {$($owo:ident => $rust:ident),*})  =>{
10		match $upon {
11			$(
12				TokenTree::Ident(ident) if ident.to_string() == stringify!($owo) =>
13					TokenTree::Ident(Ident::new(stringify!($rust), ident.span())),
14				TokenTree::Ident(ident) if ident.to_string() == stringify!($rust) =>
15					TokenTree::Ident(Ident::new_raw(stringify!($rust), ident.span())),
16			)*
17
18			token => token
19		}
20	}
21}
22
23#[proc_macro]
24pub fn owo_code(input: TokenStream) -> TokenStream {
25	iterate_tokens(input)
26}
27
28fn iterate_tokens(tokens: TokenStream) -> TokenStream {
29	tokens.into_iter()
30		.map(|token| match token {
31			TokenTree::Group(group) =>
32				Group::new(group.delimiter(), iterate_tokens(group.stream())).into(),
33			token => parse_token(token)
34		})
35		.collect()
36}
37
38fn parse_token(token: TokenTree) -> TokenTree {
39	replace_keywords!(token {
40		Me_Irl => Self,
41		ass => as,
42		assync => async,
43		owoit => await,
44		buwueak => break,
45		cowonst => const,
46		cowontinue => continue,
47		cock => crate,
48		swow => dyn,
49		yelse => else,
50		enyum => enum,
51		extewn => extern,
52		fawse => false,
53		fuwun => fn,
54		yiff => if,
55		fillme => impl,
56		penetrate => in,
57		wet => let,
58		hecc => loop,
59		sex => match,
60		discowdmodewatow => mod,
61		movemedaddy => move,
62		mutt => mut,
63		pubes => pub,
64		wef => ref,
65		yEET => return,
66		me_irl => self,
67		etewnyaw => static,
68		stwuct => struct,
69		soup => super,
70		twait => trait,
71		twue => true,
72		tippitytap => type,
73		communyism => union,
74		AAAAAAA => unsafe,
75		usemedaddy => use,
76		howl => where,
77		whine => while
78	})
79}