228 lines
3.6 KiB
Go
228 lines
3.6 KiB
Go
package varaq
|
|
|
|
type TokenType int64
|
|
|
|
const (
|
|
UNDEFINED TokenType = iota
|
|
IDENTIFIER
|
|
STRING
|
|
NUMBER
|
|
BOOLEAN
|
|
LIST
|
|
SCRIPT
|
|
FUNCTION
|
|
ERROR
|
|
LEFTPAREN
|
|
RIGHTPAREN
|
|
LEFTBRACE
|
|
RIGHTBRACE
|
|
TILDE
|
|
SLASH
|
|
STAR
|
|
FALSE
|
|
TRUE
|
|
PI
|
|
E
|
|
EOF
|
|
POP
|
|
DUP
|
|
EXCH
|
|
CLEAR
|
|
REMEMBER
|
|
FORGET
|
|
DUMP
|
|
NAME
|
|
SET
|
|
IFYES
|
|
IFNO
|
|
CHOOSE
|
|
EVAL
|
|
ESCAPE
|
|
REPEAT
|
|
SPLIT
|
|
CONS
|
|
SHATTER
|
|
EMPTY
|
|
COMPOSE
|
|
STREQ
|
|
STRCUT
|
|
STRMEASURE
|
|
STRTIE
|
|
EXPLODE
|
|
ADD
|
|
SUB
|
|
MUL
|
|
DIV
|
|
IDIV
|
|
MOD
|
|
POW
|
|
SQRT
|
|
ADD1
|
|
SUB1
|
|
SIN
|
|
COS
|
|
TAN
|
|
ATAN
|
|
LN
|
|
LOG
|
|
LOG3
|
|
CLIP
|
|
SMOOTH
|
|
HOWMUCH
|
|
SETRAND
|
|
RAND
|
|
NUMBERIZE
|
|
ISOLATE
|
|
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
|
|
OVER
|
|
ROT
|
|
DEPTH
|
|
SERVEHTTP
|
|
READALL
|
|
)
|
|
|
|
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",
|
|
OVER: "OVER",
|
|
ROT: "ROT",
|
|
DEPTH: "DEPTH",
|
|
SERVEHTTP: "SERVEHTTP",
|
|
READALL: "READALL",
|
|
}
|
|
|
|
func (me TokenType) String() string {
|
|
return tokens[me]
|
|
}
|
|
|
|
type Token struct {
|
|
Toktype TokenType
|
|
Lexeme string
|
|
Literal any
|
|
Line int
|
|
}
|