SHS/pkg/shsh/token.go
2019-11-12 13:25:53 -08:00

65 lines
1.3 KiB
Go

package token;
import (
"strings"
"bytes"
)
type operation func(Token) Token
/*
* LIST: a list of elements
* OPERAND: an element which is
*/
type parse_tag enum {
LIST_T iota
OPERAND_T iota
OPERATOR_T iota
OPERATION_T iota
}
type Token struct {
Token *next
interface{} *_inner
}
func lex(string input) string {
ret := new(Token)
iter := &ret
// buffered reader via new or make i dunno
bool buff_is_dirty = false;
for pos, char := range input {
switch char {
case ' ', '\t', '\n', '\f', '\r':
// parse new token
case '\'', '\"', '`':
// parse new token
case '(':
// match paren
// parse list
case ')':
// SHOULDNT HAPPEN
default:
// add to buffer
buf_is_dirty = true
}
if buf_is_dirty {
// clear buffer
buf_is_dirty = false
}
}
}
func parse(Token *arg) {
// if operand determine if operator
// determine operator precense in symbol table
// Determine if a list is an operation or a list
}
func eval(Token *tree) Token* {
// Find operations
// Simplify operations deepest first
// return tree of final Tokens
}