diff --git a/internal/shsh/match_utils.go b/internal/shsh/match_utils.go deleted file mode 100644 index e69de29..0000000 diff --git a/pkg/shsh/.token.go.swp b/pkg/shsh/.parsers.go.swp similarity index 83% rename from pkg/shsh/.token.go.swp rename to pkg/shsh/.parsers.go.swp index 95b314d..38eb4f4 100644 Binary files a/pkg/shsh/.token.go.swp and b/pkg/shsh/.parsers.go.swp differ diff --git a/pkg/shsh/parsers.go b/pkg/shsh/parsers.go new file mode 100644 index 0000000..7ba839f --- /dev/null +++ b/pkg/shsh/parsers.go @@ -0,0 +1,37 @@ +// TODO: think about package names +// Should we have one for all our code? +package shsh + +import ( + "strings" +) + +/* + * 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 +) + +func Parse(arg *Token) { + +} + +func string_delimiters_valid(arg string) bool { + +} + +func list_is_operation(arg *Token) bool { + +} + +func string_is_operator(arg string) bool { + +} diff --git a/pkg/shsh/token.go b/pkg/shsh/token.go index cb71c6a..da572b5 100644 --- a/pkg/shsh/token.go +++ b/pkg/shsh/token.go @@ -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