Last active
March 17, 2021 20:40
-
-
Save korzio/6ff8349cf49286f85691a0f782ec46b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func nud(acc interface{}, next token.Token) iterator { | |
// Node{Token: token.Token{Type: token.PLUS, Literal: "+"}, Left: &Node{Token: token.Token{Type: token.INT, Literal: "2"}}} | |
node := ast.Node{Token: &next} | |
it := iterator{nud: &node} | |
accIt, isIt := acc.(iterator) | |
if isIt { | |
// { , {... } | |
node.Left = accIt.nud | |
// save current stack | |
it.stack = accIt.stack | |
} | |
// finish nud iteration | |
if next.Type == token.INT { | |
it.left = &node | |
it.nud = nil | |
} | |
return it | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment