This repository has been archived by the owner on Mar 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokens.go
70 lines (59 loc) · 1.91 KB
/
tokens.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package arnoldc
var (
// This is a map of valid instructions for ArnoldC to their token.
instructions map[string]int
// This is a map of valid "macros" for ArnoldC to their token.
macros map[string]int
)
func init() {
macros = map[string]int{
"NO PROBLEMO": TRUE,
"I LIED": FALSE,
}
instructions = map[string]int{
// Functions
"IT'S SHOWTIME": MAIN_OPEN,
"YOU HAVE BEEN TERMINATED": MAIN_CLOSE,
"LISTEN TO ME VERY CAREFULLY": METHOD_OPEN,
"HASTA LA VISTA, BABY": METHOD_CLOSE,
"I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE": DECLARE_PARAMETER,
"GIVE THESE PEOPLE AIR": END_PARAMETER_DECLARATION,
"I'LL BE BACK": RETURN,
"DO IT NOW": CALL_METHOD,
"GET YOUR ASS TO MARS": ASSIGN_FROM_CALL,
// Simple built ins
"TALK TO THE HAND": PRINT,
// Variable declaration
"HEY CHRISTMAS TREE": DECLARE,
"YOU SET US UP": INITIALIZE,
// Munging
"GET TO THE CHOPPER": ASSIGNMENT,
"ENOUGH TALK": ASSIGNMENT_END,
"HERE IS MY INVITATION": FIRST_OPERAND,
// Arithmetic
"GET UP": ADD,
"GET DOWN": SUBTRACT,
"YOU'RE FIRED": MULTIPLY,
"HE HAD TO SPLIT": DIVIDE,
// Logic
"YOU ARE NOT YOU YOU ARE ME": EQUAL_TO,
"LET OFF SOME STEAM BENNET": GREATER_THAN,
"CONSIDER THAT A DIVORCE": OR,
"KNOCK KNOCK": AND,
// If/Else
"BECAUSE I'M GOING TO SAY PLEASE": IF,
"BULLSHIT": ELSE,
"YOU HAVE NO RESPECT FOR LOGIC": END_IF,
// While loops
"STICK AROUND": WHILE,
"CHILL": END_WHILE,
}
}
func instructionToString(instruction int) string {
for s, tk := range instructions {
if tk == instruction {
return s
}
}
return "UNKNOWN"
}