basic parsing functions, to be improved later
This commit is contained in:
parent
45d32cef6b
commit
900ab87f92
2 changed files with 23 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ package shsh
|
|||
|
||||
import (
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
/*
|
||||
|
|
@ -42,14 +43,33 @@ func Parse(arg *Token) {
|
|||
}
|
||||
|
||||
func string_delimiters_valid(arg string) bool {
|
||||
// TODO: Enhance this function
|
||||
go
|
||||
delim := arg[0]
|
||||
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 {
|
||||
|
||||
return ((*Token) arg._inner).tag == OPERATOR_T
|
||||
}
|
||||
|
||||
// theres probly a way better way to do it.
|
||||
func string_is_operator(arg string) bool {
|
||||
for _, r := range arg {
|
||||
if !unicode.IsLetter(r) && r != '_' {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue