Skip to content

Commit

Permalink
Merge pull request #783 from axone-protocol/feat/more-predicates
Browse files Browse the repository at this point in the history
Feat/more predicates
  • Loading branch information
ccamel authored Oct 16, 2024
2 parents 5e06f6d + 2bc22de commit 5e9b7b5
Show file tree
Hide file tree
Showing 36 changed files with 1,043 additions and 113 deletions.
21 changes: 21 additions & 0 deletions docs/predicate/atomic_list_concat_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
sidebar_position: 1
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

# atomic_list_concat/2

## Description

`atomic_list_concat/2` is a predicate that unifies an Atom with the concatenated elements of a List.

## Signature

```text
atomic_list_concat(+List, ?Atom)
```

where:

- List is a list of strings, atoms, integers, floating point numbers or non\-integer rationals
- Atom is an Atom representing the concatenation of the elements of List
24 changes: 24 additions & 0 deletions docs/predicate/atomic_list_concat_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
sidebar_position: 2
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

# atomic_list_concat/3

## Description

`atomic_list_concat/3` is a predicate that unifies an Atom with the concatenated elements of a List using a given separator.

The atomic\_list\_concat/3 predicate creates an atom just like atomic\_list\_concat/2, but inserts Separator between each pair of inputs.

## Signature

```text
atomic_list_concat(+List, +Separator, ?Atom)
```

where:

- List is a list of strings, atoms, integers, floating point numbers or non\-integer rationals
- Separator is an atom \(possibly empty\)
- Atom is an Atom representing the concatenation of the elements of List
2 changes: 1 addition & 1 deletion docs/predicate/bank_balances_2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 1
sidebar_position: 3
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/bank_locked_balances_2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 2
sidebar_position: 4
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/bank_spendable_balances_2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 3
sidebar_position: 5
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/bech32_address_2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 6
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/block_height_1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 7
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/block_time_1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 6
sidebar_position: 8
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/chain_id_1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 7
sidebar_position: 9
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/consult_1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 8
sidebar_position: 10
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/crypto_data_hash_3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 9
sidebar_position: 11
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/current_output_1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 10
sidebar_position: 12
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/did_components_2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 11
sidebar_position: 13
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/ecdsa_verify_4.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 12
sidebar_position: 14
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/eddsa_verify_4.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 13
sidebar_position: 15
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/hex_bytes_2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 14
sidebar_position: 16
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/json_prolog_2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 15
sidebar_position: 17
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
23 changes: 23 additions & 0 deletions docs/predicate/json_read_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
sidebar_position: 18
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

# json_read/2

## Description

`json_read/2` is a predicate that reads a JSON from a stream and unifies it with a Prolog term.

See json\_prolog/2 for the canonical representation of the JSON term.

The signature is as follows:

```text
json_read(+Stream, ?Term) is det
```

Where:

- Stream is the input stream from which the JSON is read.
- Term is the Prolog term that represents the JSON structure.
23 changes: 23 additions & 0 deletions docs/predicate/json_write_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
sidebar_position: 19
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

# json_write/2

## Description

`json_write/2` is a predicate that writes a Prolog term as a JSON to a stream.

The JSON object is of the same format as produced by json\_read/2.

The signature is as follows:

```text
json_write(+Stream, +Term) is det
```

Where:

- Stream is the output stream to which the JSON is written.
- Term is the Prolog term that represents the JSON structure.
2 changes: 1 addition & 1 deletion docs/predicate/open_3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 17
sidebar_position: 21
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/open_4.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 16
sidebar_position: 20
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/read_string_3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 18
sidebar_position: 22
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
28 changes: 28 additions & 0 deletions docs/predicate/read_term_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
sidebar_position: 23
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

# read_term/3

## Description

`read_term/3` is a predicate that reads a term from a stream or alias.

The signature is as follows:

```text
read_term(+Stream, -Term, +Options)
```

where:

- Stream represents the stream or alias to read the term from.
- Term represents the term to read.
- Options represents the options to control the reading process.

Valid options are:

- singletons\(Vars\): Vars is unified with a list of variables that occur only once in the term.
- variables\(Vars\): Vars is unified with a list of variables that occur in the term.
- variable\_names\(Vars\): Vars is unified with a list of Name = Var terms, where Name is an atom and Var is a variable.
2 changes: 1 addition & 1 deletion docs/predicate/source_file_1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 19
sidebar_position: 24
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
2 changes: 1 addition & 1 deletion docs/predicate/string_bytes_3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 20
sidebar_position: 25
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
30 changes: 30 additions & 0 deletions docs/predicate/term_to_atom_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
sidebar_position: 26
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

# term_to_atom/2

## Description

`term_to_atom/2` is a predicate that describes Atom as a term that unifies with Term.

## Signature

```text
term_to_atom(?Term, ?Atom)
```

where:

- Term is a term that unifies with Atom.
- Atom is an atom.

When Atom is instantiated, Atom is parsed and the result unified with Term. If Atom has no valid syntax, a syntax\_error exception is raised. Otherwise, Term is “written” on Atom using write\_term/2 with the option quoted\(true\).

## Example

```text
# Convert the atom to a term.
- term_to_atom(foo, foo).
```
2 changes: 1 addition & 1 deletion docs/predicate/uri_encoded_3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 21
sidebar_position: 27
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

Expand Down
30 changes: 30 additions & 0 deletions docs/predicate/write_term_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
sidebar_position: 28
---
[//]: # (This file is auto-generated. Please do not modify it yourself.)

# write_term/3

## Description

`write_term/3` is a predicate that writes a term to a stream or alias.

The signature is as follows:

```text
write_term(+Stream, +Term, +Options)
```

where:

- Stream represents the stream or alias to write the term to.
- Term represents the term to write.
- Options represents the options to control the writing process.

Valid options are:

- quoted\(Bool\): If true, atoms and strings that need quotes will be quoted. The default is false.
- ignore\_ops\(Bool\): If true, the generic term representation \(\<functor\>\(\<args\> ... \)\) will be used for all terms. Otherwise \(default\), operators will be used where appropriate.
- numbervars\(Bool\): If true, variables will be numbered. The default is false.
- variable\_names\(\+List\): Assign names to variables in Term. List is a list of Name = Var terms, where Name is an atom and Var is a variable.
- max\_depth\(\+Int\): The maximum depth to which the term is written. The default is infinite.
9 changes: 7 additions & 2 deletions x/logic/interpreter/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ var registry = orderedmap.New[string, any](
{Key: "get_byte/2", Value: engine.GetByte},
{Key: "peek_byte/2", Value: engine.PeekByte},
{Key: "put_byte/2", Value: engine.PutByte},
{Key: "read_term/3", Value: engine.ReadTerm},
{Key: "write_term/3", Value: engine.WriteTerm},
{Key: "read_term/3", Value: predicate.ReadTerm3},
{Key: "write_term/3", Value: predicate.WriteTerm3},
{Key: "op/3", Value: engine.Op},
{Key: "current_op/3", Value: engine.CurrentOp},
{Key: "char_conversion/2", Value: engine.CharConversion},
Expand Down Expand Up @@ -118,6 +118,11 @@ var registry = orderedmap.New[string, any](
{Key: "eddsa_verify/4", Value: predicate.EDDSAVerify},
{Key: "ecdsa_verify/4", Value: predicate.ECDSAVerify},
{Key: "string_bytes/3", Value: predicate.StringBytes},
{Key: "term_to_atom/2", Value: predicate.TermToAtom},
{Key: "atomic_list_concat/2", Value: predicate.AtomicListConcat2},
{Key: "atomic_list_concat/3", Value: predicate.AtomicListConcat3},
{Key: "json_read/2", Value: predicate.JSONRead},
{Key: "json_write/2", Value: predicate.JSONWrite},
}...),
)

Expand Down
Loading

0 comments on commit 5e9b7b5

Please sign in to comment.