all constant value are now stored in the same data struct (same constructor). Also nil const added
This commit is contained in:
parent
04f934ab04
commit
15bbfacd47
@ -4,52 +4,10 @@
|
||||
// operand-const.go
|
||||
package expr
|
||||
|
||||
// -------- bool const term
|
||||
func newBoolTerm(tk *Token) *term {
|
||||
// -------- const term
|
||||
func newConstTerm(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 {
|
||||
return &term{
|
||||
tk: *tk,
|
||||
parent: nil,
|
||||
children: nil,
|
||||
position: posLeaf,
|
||||
priority: priValue,
|
||||
evalFunc: evalConst,
|
||||
}
|
||||
}
|
||||
|
||||
// -------- 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,
|
||||
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user