basic parsing functions, to be improved later

This commit is contained in:
Aidan 2019-11-21 19:58:28 -08:00
parent 45d32cef6b
commit 900ab87f92
No known key found for this signature in database
GPG key ID: 327711E983899316
2 changed files with 23 additions and 3 deletions

Binary file not shown.

View file

@ -4,6 +4,7 @@ package shsh
import ( import (
"strings" "strings"
"unicode"
) )
/* /*
@ -42,14 +43,33 @@ func Parse(arg *Token) {
} }
func string_delimiters_valid(arg string) bool { func string_delimiters_valid(arg string) bool {
// TODO: Enhance this function delim := arg[0]
go iter := 0
if delim != arg[len(arg) - 1] {
return false
}
for _, r := range arg {
if delim == r {
iter += 1
}
}
return iter == 2
} }
func list_is_operation(arg *Token) bool { func list_is_operation(arg *Token) bool {
return ((*Token) arg._inner).tag == OPERATOR_T
} }
// theres probly a way better way to do it.
func string_is_operator(arg string) bool { func string_is_operator(arg string) bool {
for _, r := range arg {
if !unicode.IsLetter(r) && r != '_' {
return false
}
}
return true
} }