repo oops
This commit is contained in:
parent
8faa02f7f7
commit
d38f53208b
4 changed files with 40 additions and 26 deletions
Binary file not shown.
37
pkg/shsh/parsers.go
Normal file
37
pkg/shsh/parsers.go
Normal file
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue