diff --git a/operand-const.go b/operand-const.go deleted file mode 100644 index 3d5d423..0000000 --- a/operand-const.go +++ /dev/null @@ -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) -} diff --git a/operand-literal.go b/operand-literal.go new file mode 100644 index 0000000..74d2704 --- /dev/null +++ b/operand-literal.go @@ -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) +}