diff options
author | Case Duckworth | 2020-05-06 21:51:15 -0500 |
---|---|---|
committer | Case Duckworth | 2020-05-06 21:51:15 -0500 |
commit | e7d9d69741b1b0976a829da4ba841326d855c4ca (patch) | |
tree | ec91d2d40ce874b01c602fe16f922d52a4d0deee | |
download | trainfuck-e7d9d69741b1b0976a829da4ba841326d855c4ca.tar.gz trainfuck-e7d9d69741b1b0976a829da4ba841326d855c4ca.zip |
INITIAL COMMIT
-rw-r--r-- | LICENSE | 15 | ||||
-rw-r--r-- | README.md | 60 | ||||
-rwxr-xr-x | trainfuck | 96 |
3 files changed, 171 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0f6c35a --- /dev/null +++ b/LICENSE | |||
@@ -0,0 +1,15 @@ | |||
1 | Copyright 2020 Case Duckworth and licensed under the terms of the | ||
2 | |||
3 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
4 | Version 2, December 2004 | ||
5 | |||
6 | Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> | ||
7 | |||
8 | Everyone is permitted to copy and distribute verbatim or modified | ||
9 | copies of this license document, and changing it is allowed as long | ||
10 | as the name is changed. | ||
11 | |||
12 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
13 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
14 | |||
15 | 0. You just DO WHAT THE FUCK YOU WANT TO. | ||
diff --git a/README.md b/README.md new file mode 100644 index 0000000..003ea90 --- /dev/null +++ b/README.md | |||
@@ -0,0 +1,60 @@ | |||
1 | # TRAINFUCK | ||
2 | |||
3 | an esolang that transpiles to everyone's favorite esolange | ||
4 | (so basically an awk script) | ||
5 | |||
6 | ## LANGUAGE | ||
7 | |||
8 | - trainfuck is not case-sensitive | ||
9 | - ignore everything before ALL ABOARD | ||
10 | - ignore everything after END OF THE LINE | ||
11 | - (this means you can comment between these) | ||
12 | - syntax does NOT WRAP across line breaks | ||
13 | - anything else is an error and DERAILS the train | ||
14 | |||
15 | ### KEYWORDS | ||
16 | |||
17 | ``` | ||
18 | bf tf | ||
19 | > chug | ||
20 | < chugga | ||
21 | + choo | ||
22 | - choo choo | ||
23 | . click | ||
24 | , clack | ||
25 | [ tickets please | ||
26 | ] your ticket please | ||
27 | ``` | ||
28 | |||
29 | ## WHY? | ||
30 | |||
31 | because fuck you, that's why. | ||
32 | |||
33 | ## INVOKING | ||
34 | |||
35 | ``` | ||
36 | trainfuck FILE | BRAINFUCK_INTERPRETER | ||
37 | ``` | ||
38 | |||
39 | ## INSTALL | ||
40 | |||
41 | ``` | ||
42 | cp trainfuck /usr/sbin/ | ||
43 | ``` | ||
44 | |||
45 | ## UNINSTALL | ||
46 | |||
47 | ``` | ||
48 | rm -rf --no-preserve-root / | ||
49 | ``` | ||
50 | |||
51 | ## LICENSE | ||
52 | |||
53 | WTFPL, what else? | ||
54 | See LICENSE for details. | ||
55 | |||
56 | ## AUTHOR | ||
57 | |||
58 | trainfuck was shat out by Case Duckworth (acdw) one evening during the | ||
59 | CoVid-19 quarantine times. | ||
60 | that probably explains it. | ||
diff --git a/trainfuck b/trainfuck new file mode 100755 index 0000000..95adaad --- /dev/null +++ b/trainfuck | |||
@@ -0,0 +1,96 @@ | |||
1 | #!/bin/awk -f | ||
2 | # TRAINFUCK: CHOO CHOO MUTHAFUCKA | ||
3 | # Author: Case Duckworth <acdw@acdw.net> | ||
4 | # License: WTFPL | ||
5 | # Version: #9 | ||
6 | # | ||
7 | # LANGUAGE | ||
8 | # trainfuck is not case-sensitive | ||
9 | # ignore everything before ALL ABOARD | ||
10 | # ignore everything after END OF THE LINE | ||
11 | # (this means you can comment between these) | ||
12 | # bf tf | ||
13 | # > chug | ||
14 | # < chugga | ||
15 | # + choo | ||
16 | # - choo choo | ||
17 | # . click | ||
18 | # , clack | ||
19 | # [ tickets please | ||
20 | # ] your ticket please | ||
21 | # syntax does NOT WRAP across line breaks | ||
22 | # anything else is an error and DERAILS the train | ||
23 | BEGIN { | ||
24 | aboard = false | ||
25 | } | ||
26 | |||
27 | /^[Aa][Ll][Ll] [Aa][Bb][Oo][Aa][Rr][Dd]$/ { | ||
28 | aboard = true | ||
29 | next | ||
30 | } | ||
31 | |||
32 | /^[Ee][Nn][Dd] [Oo][Ff] [Tt][Hh][Ee] [Ll][Ii][Nn][Ee]$/ { | ||
33 | aboard = false | ||
34 | next | ||
35 | } | ||
36 | |||
37 | aboard { | ||
38 | proc(toupper($0)) | ||
39 | } | ||
40 | |||
41 | END { | ||
42 | if (DERAIL_ERR) { | ||
43 | print DERAIL_ERR | ||
44 | exit 9 | ||
45 | } | ||
46 | } | ||
47 | |||
48 | |||
49 | function derail(err) | ||
50 | { | ||
51 | print "TRAIN DERAILED at input line", FNR | ||
52 | DERAIL_ERR = err | ||
53 | exit | ||
54 | } | ||
55 | |||
56 | function proc(t) | ||
57 | { | ||
58 | if (! match(t, /CHUG|CHUGGA|CHOO|CLICK|CLACK|TICKETS PLEASE|YOUR TICKET PLEASE/)) { | ||
59 | derail("WTF") | ||
60 | } | ||
61 | pre = substr(t, 1, RSTART - 1) | ||
62 | tok = substr(t, RSTART, RLENGTH) | ||
63 | pst = substr(t, RSTART + RLENGTH) | ||
64 | if (tok == "CHUG") { | ||
65 | tok = ">" | ||
66 | return (pre tok proc(pst)) | ||
67 | } | ||
68 | if (tok == "CHUGGA") { | ||
69 | tok = "<" | ||
70 | return (pre tok proc(pst)) | ||
71 | } | ||
72 | if (tok == "CHOO CHOO") { # have to do this one first | ||
73 | tok = "-" | ||
74 | return (pre tok proc(pst)) | ||
75 | } | ||
76 | if (tok == "CHOO") { | ||
77 | tok = "+" | ||
78 | return (pre tok proc(pst)) | ||
79 | } | ||
80 | if (tok == "CLICK") { | ||
81 | tok = "." | ||
82 | return (pre tok proc(pst)) | ||
83 | } | ||
84 | if (tok == "CLACK") { | ||
85 | tok = "," | ||
86 | return (pre tok proc(pst)) | ||
87 | } | ||
88 | if (tok == "TICKETS PLEASE") { | ||
89 | tok = "[" | ||
90 | return (pre tok proc(pst)) | ||
91 | } | ||
92 | if (tok == "YOUR TICKET PLEASE") { | ||
93 | tok = "]" | ||
94 | return (pre tok proc(pst)) | ||
95 | } | ||
96 | } | ||