Improved SSA and added unused value checks
All checks were successful
/ test (push) Successful in 17s
All checks were successful
/ test (push) Successful in 17s
This commit is contained in:
parent
cc2e98ca49
commit
2b703e9af2
25 changed files with 519 additions and 213 deletions
|
@ -13,9 +13,9 @@ type operator struct {
|
|||
Operands int8
|
||||
}
|
||||
|
||||
// operators defines the operators used in the language.
|
||||
// Operators defines the Operators used in the language.
|
||||
// The number corresponds to the operator priority and can not be zero.
|
||||
var operators = [64]operator{
|
||||
var Operators = [64]operator{
|
||||
token.Dot: {".", 13, 2},
|
||||
token.Call: {"λ", 12, 1},
|
||||
token.Array: {"@", 12, 2},
|
||||
|
@ -59,9 +59,9 @@ var operators = [64]operator{
|
|||
}
|
||||
|
||||
func numOperands(symbol token.Kind) int {
|
||||
return int(operators[symbol].Operands)
|
||||
return int(Operators[symbol].Operands)
|
||||
}
|
||||
|
||||
func precedence(symbol token.Kind) int8 {
|
||||
return operators[symbol].Precedence
|
||||
return Operators[symbol].Precedence
|
||||
}
|
|
@ -17,9 +17,9 @@ func (expr *Expression) write(builder *strings.Builder, source []byte) {
|
|||
|
||||
switch expr.Token.Kind {
|
||||
case token.Call:
|
||||
builder.WriteString(operators[token.Call].Symbol)
|
||||
builder.WriteString(Operators[token.Call].Symbol)
|
||||
case token.Array:
|
||||
builder.WriteString(operators[token.Array].Symbol)
|
||||
builder.WriteString(Operators[token.Array].Symbol)
|
||||
default:
|
||||
builder.WriteString(expr.Token.String(source))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue