repo oops

This commit is contained in:
Aidan Hahn 2019-11-18 22:44:24 -08:00
parent 8faa02f7f7
commit d38f53208b
No known key found for this signature in database
GPG key ID: 327711E983899316
4 changed files with 40 additions and 26 deletions

View file

@ -1,33 +1,16 @@
package token;
package shsh;
import (
"strings"
)
type operation func(Token) Token
/*
* LIST: a list of elements
* OPERAND: a string or number
* OPERATOR: an entry in a symtable
* OPERATION: a list starting with an operator
*/
type parse_tag int
const (
LIST_T parse_tag = iota
OPERAND_T parse_tag = iota
OPERATOR_T parse_tag = iota
OPERATION_T parse_tag = iota
)
type Token struct {
next *Token
tag parse_tag
_inner interface{}
}
func lex(string input) Token {
func Lex(input string) Token {
ret := new(Token)
iter := &ret
delim := ' '
@ -36,6 +19,7 @@ func lex(string input) Token {
for pos, char := range input {
switch char {
// TODO: User configurable delimiters
case '\'', '"', '`':
delim = char
case '(':
@ -49,7 +33,6 @@ func lex(string input) Token {
default:
tok.WriteRune(char)
buf_is_dirty = true
}
if iter_alloced {
@ -60,12 +43,6 @@ func lex(string input) Token {
}
}
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