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
|
|
|
MIX
|
|
|
|
CONTRADICT
|
|
|
|
COMPL
|
|
|
|
SHIFTRIGHT
|
|
|
|
SHIFTLEFT
|
|
|
|
GT
|
|
|
|
LT
|
|
|
|
EQ
|
|
|
|
GE
|
|
|
|
LE
|
|
|
|
NE
|
|
|
|
NULL
|
|
|
|
NEGATIVE
|
|
|
|
ISNULL
|
|
|
|
ISINT
|
|
|
|
ISNUMBER
|
|
|
|
AND
|
|
|
|
OR
|
|
|
|
XOR
|
|
|
|
DISP
|
|
|
|
LISTEN
|
|
|
|
COMPLAIN
|
|
|
|
NEWLINE
|
|
|
|
TAB
|
|
|
|
WHEREAMI
|
|
|
|
VERSION
|
|
|
|
ARGV
|
|
|
|
TIME
|
|
|
|
GARBAGECOLLECT
|
2022-12-23 10:25:05 -05:00
|
|
|
OVER
|
|
|
|
ROT
|
|
|
|
DEPTH
|
2023-03-18 22:26:32 -04:00
|
|
|
SERVEHTTP
|
2023-03-22 22:26:58 -04:00
|
|
|
READALL
|
2022-09-03 23:15:35 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
var tokens = [...]string{
|
|
|
|
UNDEFINED: "UNDEFINED",
|
|
|
|
IDENTIFIER: "IDENTIFIER",
|
|
|
|
STRING: "STRING",
|
|
|
|
NUMBER: "NUMBER",
|
|
|
|
LIST: "LIST",
|
|
|
|
ERROR: "ERROR",
|
|
|
|
SCRIPT: "SCRIPT",
|
|
|
|
FUNCTION: "FUNCTION",
|
|
|
|
LEFTPAREN: "LEFTPAREN",
|
|
|
|
RIGHTPAREN: "RIGHTPAREN",
|
|
|
|
LEFTBRACE: "LEFTBRACE",
|
|
|
|
RIGHTBRACE: "RIGHTBRACE",
|
|
|
|
TILDE: "TILDE",
|
|
|
|
SLASH: "SLASH",
|
|
|
|
STAR: "STAR",
|
|
|
|
FALSE: "FALSE",
|
|
|
|
TRUE: "TRUE",
|
|
|
|
PI: "PI",
|
|
|
|
E: "E",
|
|
|
|
EOF: "EOF",
|
|
|
|
POP: "POP",
|
|
|
|
DUP: "DUP",
|
|
|
|
EXCH: "EXCH",
|
|
|
|
CLEAR: "CLEAR",
|
|
|
|
REMEMBER: "REMEMBER",
|
|
|
|
FORGET: "FORGET",
|
|
|
|
DUMP: "DUMP",
|
|
|
|
NAME: "NAME",
|
|
|
|
SET: "SET",
|
|
|
|
IFYES: "YES?",
|
|
|
|
IFNO: "NO?",
|
|
|
|
CHOOSE: "CHOOSE",
|
|
|
|
EVAL: "EVAL",
|
|
|
|
ESCAPE: "ESCAPE",
|
|
|
|
REPEAT: "REPEAT",
|
|
|
|
SPLIT: "SPLIT",
|
|
|
|
CONS: "CONS",
|
|
|
|
SHATTER: "SHATTER",
|
|
|
|
EMPTY: "EMPTY?",
|
|
|
|
COMPOSE: "COMPOSE",
|
|
|
|
STREQ: "STREQ?",
|
|
|
|
STRCUT: "STRCUT",
|
|
|
|
STRMEASURE: "STRMEASURE",
|
|
|
|
STRTIE: "STRTIE",
|
|
|
|
EXPLODE: "EXPLODE",
|
|
|
|
ADD: "ADD",
|
|
|
|
SUB: "SUB",
|
|
|
|
MUL: "MUL",
|
|
|
|
DIV: "DIV",
|
|
|
|
IDIV: "IDIV",
|
|
|
|
MOD: "MOD",
|
|
|
|
POW: "POW",
|
|
|
|
SQRT: "SQRT",
|
|
|
|
ADD1: "ADD1",
|
|
|
|
SUB1: "SUB1",
|
|
|
|
SIN: "SIN",
|
|
|
|
COS: "COS",
|
|
|
|
TAN: "TAN",
|
|
|
|
ATAN: "ATAN",
|
|
|
|
LN: "LN",
|
|
|
|
LOG: "LOG",
|
|
|
|
LOG3: "LOG3",
|
|
|
|
CLIP: "CLIP",
|
|
|
|
SMOOTH: "SMOOTH",
|
|
|
|
HOWMUCH: "HOWMUCH?",
|
|
|
|
SETRAND: "SETRAND",
|
|
|
|
RAND: "RAND",
|
|
|
|
NUMBERIZE: "NUMBERIZE",
|
|
|
|
ISOLATE: "ISOLATE",
|
|
|
|
MIX: "MIX",
|
|
|
|
CONTRADICT: "CONTRADICT",
|
|
|
|
COMPL: "COMPL",
|
|
|
|
SHIFTRIGHT: "SHIFTRIGHT",
|
|
|
|
SHIFTLEFT: "SHIFTLEFT",
|
|
|
|
GT: "GT?",
|
|
|
|
LT: "LT?",
|
|
|
|
EQ: "EQ?",
|
|
|
|
GE: "GE?",
|
|
|
|
LE: "LE?",
|
|
|
|
NE: "NE?",
|
|
|
|
NULL: "NULL",
|
|
|
|
NEGATIVE: "NEGATIVE",
|
|
|
|
ISNULL: "NULL?",
|
|
|
|
ISINT: "INT?",
|
|
|
|
ISNUMBER: "NUMBER?",
|
|
|
|
AND: "AND",
|
|
|
|
OR: "OR",
|
|
|
|
XOR: "XOR",
|
|
|
|
DISP: "DISP",
|
|
|
|
LISTEN: "LISTEN",
|
|
|
|
COMPLAIN: "COMPLAIN",
|
|
|
|
NEWLINE: "NEWLINE",
|
|
|
|
TAB: "TAB",
|
|
|
|
WHEREAMI: "WHEREAMI",
|
|
|
|
VERSION: "VERSION",
|
|
|
|
ARGV: "ARGV",
|
|
|
|
TIME: "TIME",
|
|
|
|
GARBAGECOLLECT: "GARBAGECOLLECT",
|
2022-12-23 10:25:05 -05:00
|
|
|
OVER: "OVER",
|
|
|
|
ROT: "ROT",
|
|
|
|
DEPTH: "DEPTH",
|
2023-03-18 22:26:32 -04:00
|
|
|
SERVEHTTP: "SERVEHTTP",
|
2023-03-22 22:26:58 -04:00
|
|
|
READALL: "READALL",
|
2022-09-03 23:15:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (me TokenType) String() string {
|
|
|
|
return tokens[me]
|
|
|
|
}
|
|
|
|
|
|
|
|
type Token struct {
|
|
|
|
Toktype TokenType
|
|
|
|
Lexeme string
|
|
|
|
Literal any
|
|
|
|
Line int
|
|
|
|
}
|