feat: stuff
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func ParseExpression(i *iterator.Iterator[tokenizer.Token]) (lambda.Expression, error) {
|
||||
token, err := i.Next()
|
||||
token, err := i.Pop()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get next token: %w", err)
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func ParseExpression(i *iterator.Iterator[tokenizer.Token]) (lambda.Expression,
|
||||
atoms := []string{}
|
||||
|
||||
for {
|
||||
atom, atomErr := i.Next()
|
||||
atom, atomErr := i.Pop()
|
||||
if atomErr != nil {
|
||||
return nil, fmt.Errorf("could not find parameter or terminator of function: %w", atomErr)
|
||||
} else if atom.Type == tokenizer.TokenVariable {
|
||||
@@ -72,7 +72,7 @@ func ParseExpression(i *iterator.Iterator[tokenizer.Token]) (lambda.Expression,
|
||||
args = append(args, arg)
|
||||
}
|
||||
|
||||
closing, closingErr := i.Next()
|
||||
closing, closingErr := i.Pop()
|
||||
if closingErr != nil {
|
||||
return nil, fmt.Errorf("could not parse call terminating parenthesis: %w", closingErr)
|
||||
} else if closing.Type != tokenizer.TokenCloseParen {
|
||||
@@ -94,6 +94,5 @@ func ParseExpression(i *iterator.Iterator[tokenizer.Token]) (lambda.Expression,
|
||||
}
|
||||
|
||||
func GetTree(tokens []tokenizer.Token) (lambda.Expression, error) {
|
||||
i := iterator.New(tokens)
|
||||
return ParseExpression(&i)
|
||||
return ParseExpression(iterator.New(tokens))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user