fleshed out parser loop
This commit is contained in:
parent
cb84db53d8
commit
45d32cef6b
3 changed files with 21 additions and 1 deletions
Binary file not shown.
|
|
@ -21,11 +21,29 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Parse(arg *Token) {
|
func Parse(arg *Token) {
|
||||||
|
switch arg.tag {
|
||||||
|
case LIST_T:
|
||||||
|
for i := arg; i; i = i.next {
|
||||||
|
Parse(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
if list_is_operation(arg) {
|
||||||
|
arg.tag = OPERATION_T
|
||||||
|
}
|
||||||
|
|
||||||
|
case OPERAND_T:
|
||||||
|
if string_is_operator(arg._inner) {
|
||||||
|
arg.tag = OPERATOR_T
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
;// TODO: Tag a parse error?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func string_delimiters_valid(arg string) bool {
|
func string_delimiters_valid(arg string) bool {
|
||||||
|
// TODO: Enhance this function
|
||||||
|
go
|
||||||
}
|
}
|
||||||
|
|
||||||
func list_is_operation(arg *Token) bool {
|
func list_is_operation(arg *Token) bool {
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,13 @@ func Lex(input string) Token {
|
||||||
if is_list {
|
if is_list {
|
||||||
// TODO: Pass a pointer out of Lex and store a pointer
|
// TODO: Pass a pointer out of Lex and store a pointer
|
||||||
*iter._inner = Lex(tok.String())
|
*iter._inner = Lex(tok.String())
|
||||||
|
*iter.tag = LIST_T
|
||||||
is_list = false
|
is_list = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: Store a pointer to the contents of the stringbuilder
|
// TODO: Store a pointer to the contents of the stringbuilder
|
||||||
*iter._inner = tok.String()
|
*iter._inner = tok.String()
|
||||||
|
*iter.tag = OPERAND_T
|
||||||
}
|
}
|
||||||
|
|
||||||
iter_alloced = true
|
iter_alloced = true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue