Add bilingual manual and localized docs routes
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# Bool
|
||||
|
||||
`Bool` is the primitive type constraint for Boolean values.
|
||||
|
||||
## Examples
|
||||
|
||||
```dcdl
|
||||
enable = Bool default true;
|
||||
disable = Bool default false;
|
||||
```
|
||||
|
||||
## Literals
|
||||
|
||||
`Bool` accepts the following literals:
|
||||
|
||||
```dcdl
|
||||
true
|
||||
false
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
# Float
|
||||
|
||||
`Float` is the primitive type constraint for floating-point values.
|
||||
|
||||
## Examples
|
||||
|
||||
```dcdl
|
||||
ratio = Float;
|
||||
threshold = Float default 0.5;
|
||||
```
|
||||
|
||||
## Relationship to Int
|
||||
|
||||
`Int` and `Float` are distinct primitive type constraints.
|
||||
A `Float` constraint requires a concrete `Float`, and an `Int` constraint requires a concrete `Int`.
|
||||
|
||||
Arithmetic and comparison expressions can treat `Int` and `Float` as numeric values.
|
||||
Mixed arithmetic produces a `Float` result.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Value
|
||||
|
||||
This chapter defines the kinds of values handled by the language.
|
||||
|
||||
Primitive types are built-in constraints that values must satisfy, rather than ordinary data values.
|
||||
|
||||
```dcdl
|
||||
name = String;
|
||||
retry = Int default 3;
|
||||
ratio = Float;
|
||||
enable = Bool default true;
|
||||
tags = [...String];
|
||||
```
|
||||
|
||||
The primitive types are `String`, `Int`, `Float`, and `Bool`.
|
||||
`Unknown` is not a primitive type; it is the top abstract range containing every Decodal value. An `Unknown` without a concrete value or default cannot be materialized.
|
||||
An array is not a primitive type and is described as `[...T]` with a required element constraint.
|
||||
Links to each type specification are collected in the [manual contents](../../index.md).
|
||||
|
||||
See [Constraints and Defaults](../constraints-and-defaults.md) for details about primitive types and constraint composition.
|
||||
@@ -0,0 +1,18 @@
|
||||
# Int
|
||||
|
||||
`Int` is the primitive type constraint for integer values.
|
||||
|
||||
## Examples
|
||||
|
||||
```dcdl
|
||||
retry = Int default 3;
|
||||
port = Int & >= 1 & <= 65535;
|
||||
```
|
||||
|
||||
## Constraint composition
|
||||
|
||||
`Int` can be composed with numeric comparison constraints.
|
||||
|
||||
```dcdl
|
||||
NarrowedPort = Int & >= 1 & <= 65535 & > 443;
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
# String
|
||||
|
||||
`String` is the primitive type constraint for string values.
|
||||
|
||||
A string literal is enclosed in `"`.
|
||||
|
||||
```dcdl
|
||||
"hello"
|
||||
"line 1\nline 2"
|
||||
```
|
||||
|
||||
`$`, `{`, and `}` have no special meaning inside a string; Decodal does not perform string interpolation.
|
||||
|
||||
## Examples
|
||||
|
||||
```dcdl
|
||||
name = String;
|
||||
greeting = String default "hello";
|
||||
```
|
||||
|
||||
## Constraint composition
|
||||
|
||||
`String` can be composed with string constraints.
|
||||
|
||||
```dcdl
|
||||
message = String & /Hello! .*/;
|
||||
```
|
||||
|
||||
Enable regex-constraint validation with the Rust crate's `regex` feature.
|
||||
Without that feature, a regex constraint cannot be validated against a concrete string and produces a diagnostic.
|
||||
Reference in New Issue
Block a user