diff --git a/operand-const.go b/operand-const.go index 4cf8ac8..5a59674 100644 --- a/operand-const.go +++ b/operand-const.go @@ -4,22 +4,8 @@ // operand-const.go package expr -// -------- bool const term -func newBoolTerm(tk *Token) *term { - return &term{ - tk: *tk, - // class: classConst, - // kind: kindBool, - parent: nil, - children: nil, - position: posLeaf, - priority: priValue, - evalFunc: evalConst, - } -} - -// -------- integer const term -func newIntegerTerm(tk *Token) *term { +// -------- const term +func newConstTerm(tk *Token) *term { return &term{ tk: *tk, parent: nil, @@ -30,34 +16,6 @@ func newIntegerTerm(tk *Token) *term { } } -// -------- float const term -func newFloatTerm(tk *Token) *term { - return &term{ - tk: *tk, - // class: classConst, - // kind: kindFloat, - parent: nil, - children: nil, - position: posLeaf, - priority: priValue, - evalFunc: evalConst, - } -} - -// -------- string const term -func newStringTerm(tk *Token) *term { - return &term{ - tk: *tk, - // class: classConst, - // kind: kindString, - 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 @@ -66,8 +24,9 @@ func evalConst(ctx ExprContext, self *term) (v any, err error) { // init func init() { - registerTermConstructor(SymString, newStringTerm) - registerTermConstructor(SymInteger, newIntegerTerm) - registerTermConstructor(SymFloat, newFloatTerm) - registerTermConstructor(SymBool, newBoolTerm) + registerTermConstructor(SymString, newConstTerm) + registerTermConstructor(SymInteger, newConstTerm) + registerTermConstructor(SymFloat, newConstTerm) + registerTermConstructor(SymBool, newConstTerm) + registerTermConstructor(SymKwNil, newConstTerm) }