Skip to content

Commit

Permalink
docs: sync latest documents for spec references
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Nov 20, 2023
1 parent 8441131 commit 6dbdb67
Show file tree
Hide file tree
Showing 16 changed files with 1,580 additions and 974 deletions.
2 changes: 1 addition & 1 deletion docs/reference/lang/spec/error.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ schema is violated.
The syntax of the `assert` statement is the following.

```bnf
assert_stmt: 'assert' test ['if' test] [',' test]
assert_stmt: ASSERT simple_expr (IF simple_expr)? (COMMA test)?
```

In the basic form, an `assert` statement evaluates an expression. If the
Expand Down
8 changes: 8 additions & 0 deletions docs/reference/lang/spec/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,21 @@ KCL supports a few standard system modules. The following is the full list of th
Deserialize `value` (a string instance containing a JSON document) to a KCL object.
- dump_to_file(data: any, filename: str, ignore_private: bool = False, ignore_none: bool = False) -> None
Serialize a KCL object `data` to a JSON formatted str and write it into the file `filename`.
- validate(data: any) -> bool
Validate whether the given string is a valid JSON.
- yaml
- encode(data: any, sort_keys: bool = False, ignore_private: bool = False, ignore_none: bool = False) -> str
Serialize a KCL object `data` to a YAML formatted str.
- encode_all(data: [any], sort_keys: bool = False, ignore_private: bool = False, ignore_none: bool = False) -> str
Serialize a sequence of KCL objects into a YAML stream str.
- decode(value: str) -> any
Deserialize `value` (a string instance containing a YAML document) to a KCL object.
- decode_all(value: str) -> [any]
- dump_to_file(data: any, filename: str, ignore_private: bool = False, ignore_none: bool = False) -> None
Serialize a KCL object `data` to a YAML formatted str and write it into the file `filename`.
Parse all YAML documents in a stream and produce corresponding KCL objects.
- validate(value: str) -> str
Validate whether the given string is a valid YAML or YAML stream document.
- net
- split_host_port(ip_end_point: str) -> List[str]
Split the 'host' and 'port' from the ip end point.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/lang/spec/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A schema is a language element to define a type of configuration data.
To define a schema, the syntax is the following:

```bnf
schema_stmt: [decorators] "schema" ["relaxed"] identifier ["[" [arguments] "]"] ["(" operand_name ")"] ":" NEWLINE [schema_body]
schema_stmt: [decorators] "schema" identifier ["[" [arguments] "]"] ["(" operand_name ")"] ":" NEWLINE [schema_body]
schema_body: _INDENT (string NEWLINE)* [mixin_stmt] (schema_attribute_stmt | schema_index_signature | statement)* [check_block] _DEDENT
```

Expand Down
10 changes: 5 additions & 5 deletions docs/reference/lang/spec/statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ A small statement is comprised of a single logical line. Multiple statements in
Generally, assign_stmt is divided into assignment and augmented assignment. The syntax is the following:

```bnf
assign_stmt: target_primary ("=" target_primary)* "=" test | target_primary augassign test
augassign: "+=" | "-=" | "*=" | "**=" | "/=" | "//=" | "%=" | "&=" | "|=" | "^=" | "<<=" | ">>=" | "or" | "and"
assign_stmt: target_primary (":" type) ("=" target_primary)* "=" test | target_primary aug_assign test
aug_assign: "+=" | "-=" | "*=" | "**=" | "/=" | "//=" | "%=" | "&=" | "|=" | "^=" | "<<=" | ">>="
target_primary: identifier | target_primary DOT identifier
```

Expand Down Expand Up @@ -61,7 +61,7 @@ _x -= 1
_filename += ".k"
```

There is no concept of in-place modification in KCL. The `augassign` statement will modify a copy of the **target_primary** and assign the copy to **target_primary**.
There is no concept of in-place modification in KCL. The `aug_assign` statement will modify a copy of the **target_primary** and assign the copy to **target_primary**.

In particular, in KCL, the `|=` symbol represents the **union** operation, which is defined as follows:

Expand Down Expand Up @@ -117,7 +117,7 @@ Assert statements are a convenient way to insert debugging assertions into KCL c
The syntax is the following:

```
assert_stmt: ASSERT test ("," test)?
assert_stmt: ASSERT test ("if" test)? ("," test)?
```

The conditional expression in assert will be evaluated and get a boolean. Report an error if returning a `False`.
Expand Down Expand Up @@ -178,7 +178,7 @@ else:
Schema statements are used to define a type of configuration data. The syntax is the following:

```bnf
schema_stmt: [decorators] "schema" ["relaxed"] identifier ["[" [arguments] "]"] ["(" operand_name ")"] ":" NEWLINE [schema_body]
schema_stmt: [decorators] "schema" identifier ["[" [arguments] "]"] ["(" operand_name ")"] ":" NEWLINE [schema_body]
schema_body: _INDENT (string NEWLINE)* [mixin_stmt] (schema_attribute_stmt | statement)* [check_block] _DEDENT
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ schema is violated.
The syntax of the `assert` statement is the following.

```bnf
assert_stmt: 'assert' test ['if' test] [',' test]
assert_stmt: ASSERT simple_expr (IF simple_expr)? (COMMA test)?
```

In the basic form, an `assert` statement evaluates an expression. If the
Expand Down
Loading

0 comments on commit 6dbdb67

Please sign in to comment.