operand-const.go -> operand-literal.go
This commit is contained in:
parent
efc92d434b
commit
8eb25bbc86
@ -1,33 +0,0 @@
|
|||||||
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
||||||
// All rights reserved.
|
|
||||||
|
|
||||||
// operand-const.go
|
|
||||||
package expr
|
|
||||||
|
|
||||||
// -------- const term
|
|
||||||
func newConstTerm(tk *Token) *term {
|
|
||||||
return &term{
|
|
||||||
tk: *tk,
|
|
||||||
parent: nil,
|
|
||||||
children: nil,
|
|
||||||
position: posLeaf,
|
|
||||||
priority: priValue,
|
|
||||||
evalFunc: evalConst,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------- eval func
|
|
||||||
func evalConst(ctx ExprContext, self *term) (v any, err error) {
|
|
||||||
v = self.tk.Value
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// init
|
|
||||||
func init() {
|
|
||||||
registerTermConstructor(SymString, newConstTerm)
|
|
||||||
registerTermConstructor(SymInteger, newConstTerm)
|
|
||||||
registerTermConstructor(SymFloat, newConstTerm)
|
|
||||||
registerTermConstructor(SymFraction, newConstTerm)
|
|
||||||
registerTermConstructor(SymBool, newConstTerm)
|
|
||||||
registerTermConstructor(SymKwNil, newConstTerm)
|
|
||||||
}
|
|
33
operand-literal.go
Normal file
33
operand-literal.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||||||
|
// All rights reserved.
|
||||||
|
|
||||||
|
// operand-literal.go
|
||||||
|
package expr
|
||||||
|
|
||||||
|
// -------- literal term
|
||||||
|
func newLiteralTerm(tk *Token) *term {
|
||||||
|
return &term{
|
||||||
|
tk: *tk,
|
||||||
|
parent: nil,
|
||||||
|
children: nil,
|
||||||
|
position: posLeaf,
|
||||||
|
priority: priValue,
|
||||||
|
evalFunc: evalLiteral,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- eval func
|
||||||
|
func evalLiteral(ctx ExprContext, self *term) (v any, err error) {
|
||||||
|
v = self.tk.Value
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// init
|
||||||
|
func init() {
|
||||||
|
registerTermConstructor(SymString, newLiteralTerm)
|
||||||
|
registerTermConstructor(SymInteger, newLiteralTerm)
|
||||||
|
registerTermConstructor(SymFloat, newLiteralTerm)
|
||||||
|
registerTermConstructor(SymFraction, newLiteralTerm)
|
||||||
|
registerTermConstructor(SymBool, newLiteralTerm)
|
||||||
|
registerTermConstructor(SymKwNil, newLiteralTerm)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user