Add bilingual manual and localized docs routes
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
# Lexical Structure and Syntax
|
||||
|
||||
This chapter summarizes the surface syntax.
|
||||
See the EBNF in [Grammar](./grammar.md) for the precise grammar.
|
||||
|
||||
## Language name and extension
|
||||
|
||||
The project is named **Decodal**.
|
||||
Its full descriptive name is **Deferred Constraint Data Language**, abbreviated **DCDL**.
|
||||
Source files use the `.dcdl` extension.
|
||||
|
||||
```text
|
||||
config.dcdl
|
||||
schema.dcdl
|
||||
service.dcdl
|
||||
```
|
||||
|
||||
## Module source
|
||||
|
||||
An entire file can contain a single expression.
|
||||
A sequence of field definitions at the top level is treated as an implicit object.
|
||||
|
||||
```dcdl
|
||||
host = String;
|
||||
port = Int default 8080;
|
||||
```
|
||||
|
||||
The source above is equivalent to:
|
||||
|
||||
```dcdl
|
||||
{
|
||||
host = String;
|
||||
port = Int default 8080;
|
||||
}
|
||||
```
|
||||
|
||||
## Comments
|
||||
|
||||
A comment begins with `#` and continues to the end of the line.
|
||||
|
||||
```dcdl
|
||||
# comment
|
||||
host = "127.0.0.1"; # trailing comment
|
||||
```
|
||||
|
||||
## Semicolons
|
||||
|
||||
Semicolons separate object fields, `let` bindings, and `match` arms.
|
||||
A trailing semicolon is allowed.
|
||||
|
||||
```dcdl
|
||||
{
|
||||
host = "127.0.0.1";
|
||||
port = 8000;
|
||||
}
|
||||
```
|
||||
|
||||
## Identifiers
|
||||
|
||||
An identifier begins with an ASCII letter and may continue with ASCII letters, digits, or `_`.
|
||||
Naming conventions can use `lower_snake`, `lowerCamel`, or `UpperCamel`.
|
||||
|
||||
```dcdl
|
||||
my_config
|
||||
mkConfig
|
||||
IPv4Address
|
||||
```
|
||||
|
||||
## Path references
|
||||
|
||||
Use a dot to reference a field.
|
||||
|
||||
```dcdl
|
||||
config.host
|
||||
config.feature_hoge.enable
|
||||
```
|
||||
|
||||
Fields inside an object can also be defined with a dot path.
|
||||
|
||||
```dcdl
|
||||
{
|
||||
feature_hoge.enable = false;
|
||||
}
|
||||
```
|
||||
|
||||
This represents the same structure as:
|
||||
|
||||
```dcdl
|
||||
{
|
||||
feature_hoge = {
|
||||
enable = false;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Reserved words
|
||||
|
||||
The following words are reserved:
|
||||
|
||||
```text
|
||||
let
|
||||
in
|
||||
match
|
||||
import
|
||||
default
|
||||
as
|
||||
true
|
||||
false
|
||||
```
|
||||
|
||||
## Operators
|
||||
|
||||
The primary operators are:
|
||||
|
||||
```text
|
||||
+ - * / arithmetic
|
||||
++ array concatenation
|
||||
! && || logical operations
|
||||
== != < <= > >= comparisons
|
||||
& constraint-preserving composition
|
||||
// patch composition
|
||||
default fallback specification
|
||||
as range containment check and refinement from left to right
|
||||
=> function
|
||||
. field reference / dot-path definition
|
||||
... value constraint for an array or associative array
|
||||
```
|
||||
|
||||
Operator precedence is defined in [Operators](./operators.md).
|
||||
Reference in New Issue
Block a user