]> Cypherpunks repositories - keks.git/commitdiff
PREC command could be used in theory with FLOAT
authorSergey Matveev <stargrave@stargrave.org>
Thu, 9 Oct 2025 19:28:54 +0000 (22:28 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 9 Oct 2025 19:41:56 +0000 (22:41 +0300)
c/lib/schema.c
go/schema/check.go
spec/schema/cmds
spec/schema/tcl
tcl/schema.tcl

index bb2d853b541f064bfc8e8ad9e3afa14766953439136c88f69a42ef96101b76f9..7f1b93777b03a48ee5a73cf94082c108f70526fa5950df2f6a7a2f02434bb230 100644 (file)
@@ -35,7 +35,7 @@ static const char CmdLT[] = "<";
 static const char CmdNotExists[] = "!E";
 static const char CmdSchema[] = "S";
 static const char CmdTake[] = ".";
-static const char CmdTimePrec[] = "TP";
+static const char CmdPrec[] = "P";
 static const char CmdType[] = "T";
 static const char CmdUTC[] = "UTC";
 
@@ -473,7 +473,7 @@ Eached:
             }
             err.code = KEKSSchemaErrNo;
         }
-    } else if (KEKSStrEqual(&(schema->list[idxSchema].atom), CmdTimePrec)) {
+    } else if (KEKSStrEqual(&(schema->list[idxSchema].atom), CmdPrec)) {
         idxSchema = schema->list[idxSchema].next;
         if (idxSchema == 0) {
             err.code = KEKSSchemaErrInvalidSchema;
@@ -483,10 +483,10 @@ Eached:
         err.offSchema = schema->offsets[idxSchema];
         if (schema->list[idxSchema].atom.typ != KEKSItemPint) {
             err.code = KEKSSchemaErrInvalidSchema;
-            err.msg = "non-int TIMEPREC";
+            err.msg = "non-int PREC";
             return err;
         }
-        err.msg = "TIMEPREC";
+        err.msg = "PREC";
         err.code = KEKSSchemaErrNo;
         if (v != SIZE_MAX) {
             if (data->list[v].atom.typ != KEKSItemTAI64) {
@@ -562,7 +562,7 @@ Eached:
                 break;
             default:
                 err.code = KEKSSchemaErrInvalidSchema;
-                err.msg = "unknown TIMEPREC value";
+                err.msg = "unknown PREC value";
                 return err;
             }
         }
index 1dde03e758c00ba445152e3fbdba89b88bb3fc7e33db748ed5a881f9f43f1173..2b47b93dd6c385037bfc54e0a6dedbeec0662398cad5e036cf19bf607fe7fe5b 100644 (file)
@@ -39,7 +39,7 @@ const (
        CmdNotExists = "!E"
        CmdSchema    = "S"
        CmdTake      = "."
-       CmdTimePrec  = "TP"
+       CmdPrec      = "P"
        CmdType      = "T"
        CmdUTC       = "UTC"
        Magic        = "schema"
@@ -486,7 +486,7 @@ func Check(schemaName string, schemas map[string][][]any, data any) error {
                                        }}
                                }
                        }
-               case CmdTimePrec:
+               case CmdPrec:
                        if vs == nil {
                                continue
                        }
index 5a4b8c05e040af285efdb800e11ed05c3655cc4dbc26e2b1efe8d7673e584084..6e750eed251754492d9c1e76696254789cd2529d0bfe5e9f1ce95d0b318370dd 100644 (file)
@@ -54,10 +54,11 @@ LT | ["<", n]
 SCHEMA | ["S", s]
     Check chosen (if it exists) element against schema named "s".
 
-TIMEPREC | ["TP", p]
-    Check that chosen (if it exists) element, of time type, has value of
-    maximal specified time precision. "p" is integer with following
-    possible values:
+PREC | ["P", p]
+    Check that chosen (if it exists) element, has specified precision.
+    It chosen element of time type, then check its value is at most
+    precise as 10^{-p} seconds. "p" is integer with following possible
+    values:
          0: only full seconds allowed, no parts;
          3: only up to milliseconds;
          6: only up to microseconds;
@@ -65,6 +66,7 @@ TIMEPREC | ["TP", p]
         12: only up to picoseconds;
         15: only up to femtoseconds;
         18: up to attoseconds;
+    If chosen element of float type, then TODO.
 
 UTC | ["UTC"]
     Check that chosen (if it exists) element, of TAI type,
index a664a4cd001f734ec857c40bf2515eb493ac678ba5b2fbfad5052d8edaa6e1eb..2651db380b9d76f23de74a18b15734e7074b452349ea8f8e4b06d58ea518fb20 100644 (file)
@@ -70,8 +70,8 @@ strings are not empty.
 
 "=v" checks that given bin/str/hexlet/magic has specified binary value.
 
-"prec=p" issues TIMEPREC command, but instead of specifying the raw
-integer values, you choose one of: s, ms, us, ns, ps, fs.
+"prec=p" issues PREC command, but instead of specifying the raw
+integer values, you choose one of: s, ms, us, ns, ps, fs for time type.
 
 "utc" issues UTC command.
 
index 30d193da242374871cf85bc4e15ab855f5bc6fb460af37a509a8e738b2aba985..b8a373b6784c96870f82a196c6f5f3ec8a7b43e8b33103ebb826ac57d07b1eea 100755 (executable)
@@ -27,7 +27,7 @@ proc EQ {v} {subst {LIST {{STR =} {BIN $v}}}}
 proc GT {n} {subst {LIST {{STR >} {INT $n}}}}
 proc LT {n} {subst {LIST {{STR <} {INT $n}}}}
 proc SCHEMA {s} {subst {LIST {{STR S} {STR $s}}}}
-proc TIMEPREC {p} {subst {LIST {{STR TP} {INT $p}}}}
+proc PREC {p} {subst {LIST {{STR P} {INT $p}}}}
 proc UTC {} {return {LIST {{STR UTC}}}}
 
 proc TAKE {k} {
@@ -55,7 +55,7 @@ proc TYPE {types} {
     subst {LIST {$l}}
 }
 
-set timeprecArgs [dict create s 0 ms 3 us 6 ns 9 ps 12 fs 15]
+set precArgs [dict create s 0 ms 3 us 6 ns 9 ps 12 fs 15]
 
 proc field {k types args} {
     upvar _cmds _cmds buf buf
@@ -99,9 +99,9 @@ proc field {k types args} {
     set i [lsearch -glob $args "prec=*"]
     if {$i != -1} {
         set p [string range [lindex $args $i] 5 end]
-        variable timeprecArgs
-        set p [dict get $timeprecArgs $p]
-        lappend _cmds [TIMEPREC $p]
+        variable precArgs
+        set p [dict get $precArgs $p]
+        lappend _cmds [PREC $p]
     }
     if {[lsearch -exact $args utc] != -1} {
         lappend _cmds [UTC]
@@ -145,7 +145,7 @@ proc do {v} {
     MAP $_pairs
 }
 
-namespace export TAKE EXISTS !EXISTS EACH EQ TYPE GT LT SCHEMA TIMEPREC UTC
+namespace export TAKE EXISTS !EXISTS EACH EQ TYPE GT LT SCHEMA PREC UTC
 namespace export do process field
 
 }