Implemented unary operator parsing
This commit is contained in:
parent
86e7ade051
commit
093bd79c82
8 changed files with 142 additions and 16 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
type Operator struct {
|
||||
Symbol string
|
||||
Precedence int8
|
||||
Operands int
|
||||
Operands int8
|
||||
}
|
||||
|
||||
// Operators defines the operators used in the language.
|
||||
|
@ -19,6 +19,7 @@ var Operators = map[token.Kind]*Operator{
|
|||
token.Period: {".", 13, 2},
|
||||
token.Call: {"λ", 12, 1},
|
||||
token.Array: {"@", 12, 2},
|
||||
token.Negate: {"-", 11, 1},
|
||||
token.Not: {"!", 11, 1},
|
||||
token.Mul: {"*", 10, 2},
|
||||
token.Div: {"/", 10, 2},
|
||||
|
@ -73,7 +74,7 @@ func numOperands(symbol token.Kind) int {
|
|||
return -1
|
||||
}
|
||||
|
||||
return operator.Operands
|
||||
return int(operator.Operands)
|
||||
}
|
||||
|
||||
func precedence(symbol token.Kind) int8 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue