diff --git a/.token.go.swp b/.token.go.swp deleted file mode 100644 index 280a049..0000000 Binary files a/.token.go.swp and /dev/null differ diff --git a/License b/License new file mode 100644 index 0000000..e69de29 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/Readme b/Readme new file mode 100644 index 0000000..e69de29 diff --git a/cmd/print_ast.go b/cmd/print_ast.go new file mode 100644 index 0000000..e96f7a4 --- /dev/null +++ b/cmd/print_ast.go @@ -0,0 +1,11 @@ +package main + +import ( + "strings" + "os" + "git.callpipe.com/aidan/shsh" +) + +func main() { + shsh.PrintSExpression(shsh.Lex(strings.Join(os.Args[1:], " "))) +} diff --git a/cmd/shsh/shsh.go b/cmd/shsh/shsh.go deleted file mode 100644 index ddc4e0f..0000000 --- a/cmd/shsh/shsh.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import ( - "bufio" - "os" - "git.callpipe.com/aidan/shsh" -) - -func main() { - scanner := bufio.NewScanner(os.Stdin) - for scanner.Scan() { - shsh.PrintSExpression(shsh.Lex(scanner.Text())) - } -} diff --git a/debug.go b/debug.go index d6bc4b8..f777ba8 100644 --- a/debug.go +++ b/debug.go @@ -13,12 +13,10 @@ func FmtToken(arg *Token) string { switch arg.tag { case LIST: - return fmt.Sprintf("(%s, List @ %p, %d)%s", "LIST", arg._inner, - arg.position, suffix) + return fmt.Sprintf("(%s, List @ %p)%s", "LIST", arg._inner, suffix) default: - return fmt.Sprintf("(%s, %s, %d)%s", GetTagAsStr(arg.tag), arg._inner, - arg.position, suffix) + return fmt.Sprintf("(%s, %s)%s", GetTagAsStr(arg.tag), arg._inner, suffix) } } @@ -54,12 +52,6 @@ loop: for iter := i; iter != nil; iter = iter.next { if iter.tag == LIST { lists.Push(iter._inner.(*Token)) - constructor.WriteString(FmtToken(&Token{ - next: iter.next, - tag: STRING, - position: iter.position, - _inner: "[LIST]"})) - continue } constructor.WriteString(FmtToken(iter)) diff --git a/shsh b/shsh deleted file mode 100755 index f8286ff..0000000 Binary files a/shsh and /dev/null differ diff --git a/token.go b/token.go index 9a5d77f..361caa7 100644 --- a/token.go +++ b/token.go @@ -26,9 +26,9 @@ func Lex(input string) *Token { } var ret *Token + var tok strings.Builder iter := &ret delim := ' ' - var tok strings.Builder is_list := false is_str := false