Refuse a name registered as a builtin and a transform, build the offered calls once, and drop the done item

This commit is contained in:
2026-09-25 08:46:53 +02:00
committed by Lillem4n
parent d81cfd5757
commit fbc8fe78c9
4 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -120,8 +120,8 @@ type builtin struct {
operands func(args []string) []string
// number proves what a call prints, token its body: the bounds of its number and the
// datatype of its text, prints or one inside it; nil for a builtin whose text is no number.
prints DataType
number func(token string, prints DataType, args []string) proven
prints DataType
}
// funcCall splits a "{token}" body shaped name(args) into its parts; ok is false
-4
View File
@@ -19,10 +19,6 @@ Self-sufficiency 5.6), every seat capped by Locality or Self-sufficiency.
This round, in order:
- Register a transform once: `transforms` restates the `lowercase`, `uppercase` and
`ascii` entries in `builtins`, and `valueProof.template` classifies by the first while
render calls the second. Derive the numeric builtins `valueProof.template` lists in
its error text from `builtin.number` while there.
- Split `drawCheck.reads`'s six-term condition into named predicates.
- Rename what names two things: `template.go` holds the token grammar while `template`
is `node.go`'s type and `Template` `inline.go`'s; `kind` `'b'` is a brace body in
+6 -3
View File
@@ -14,11 +14,14 @@ var transforms = map[string]func(string) string{
"uppercase": strings.ToUpper,
}
func withTransforms(builtins map[string]builtin) map[string]builtin {
func withTransforms(calls map[string]builtin) map[string]builtin {
for name, fn := range transforms {
builtins[name] = builtin{arity: 1, check: transformArg, prep: transformPrep(fn), operands: transformOperand}
if _, clash := calls[name]; clash {
panic("fejkdata: " + name + " is registered as a builtin and a transform")
}
calls[name] = builtin{arity: 1, check: transformArg, prep: transformPrep(fn), operands: transformOperand}
}
return builtins
return calls
}
// unwrapTransform peels nested transform calls off an operand arg, returning the
+4 -2
View File
@@ -149,8 +149,8 @@ func (p *valueProof) template(t *template) proven {
case t.fixed:
return literalValue(t.lit)
case len(t.ops) != 1:
v := unproven(notOneValue(t.format, numberCalls(false)))
v.notOperand = notOneValue(t.format, numberCalls(true))
v := unproven(notOneValue(t.format, typedCalls))
v.notOperand = notOneValue(t.format, operandCalls)
return v
}
o := t.ops[0]
@@ -288,6 +288,8 @@ func printing(token string, prints DataType, v proven) proven {
return v
}
var typedCalls, operandCalls = numberCalls(false), numberCalls(true)
// numberCalls lists the builtins printing a number, or with text also those whose text
// is one.
func numberCalls(text bool) string {