Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
749 B · 27 lines
Go
at main
123456789101112131415161718192021222324252627package expression
import "git.urbach.dev/cli/q/src/token"
// isComplete returns true if the expression is complete (a binary operation with a single operand is incomplete).func isComplete(expr *Expression) bool { if expr == nil { return false }
if expr.Token.Kind == token.Call || expr.Token.Kind == token.Struct || expr.Token.Kind == token.Type { // Even though token.Call is an operator and could be handled by the upcoming branch, // the number of operands is variable. // Therefore, we consider every single call expression as complete. return true }
if expr.Token.Kind.IsLiteral() { return true }
if expr.Token.Kind.IsOperator() && len(expr.Children) == numOperands(expr.Token.Kind) { return true }
return false}