Commit Graph

146 Commits

Author SHA1 Message Date
Gastón Zanitti
945d613f15 Remove lookups from PilStatement (#1782)
Co-authored-by: chriseth <chris@ethereum.org>
2024-09-12 10:02:46 +00:00
Lucas Clemente Vella
83e2c841e6 Trying buildjet CI runner (#1777) 2024-09-11 08:53:12 +00:00
Gastón Zanitti
4f190b9bf9 Lookups as Binary ops (#1770)
Co-authored-by: chriseth <chris@ethereum.org>
2024-09-10 15:15:58 +00:00
Gastón Zanitti
73f49a4553 Traits unification (#1625)
Co-authored-by: chriseth <chris@ethereum.org>
2024-09-09 13:37:42 +00:00
chriseth
6688249331 Support captured vars (#1645)
Co-authored-by: Thibaut Schaeffer <schaeffer.thibaut@gmail.com>
2024-09-06 12:55:15 +00:00
Thibaut Schaeffer
7f259b43c7 Support degree ranges (#1667)
We currently hardcode the range of degrees that variable degree machines
are preprocessed for. Expose that in machines instead.

This changes pil namespaces to accept a min and max degree:
```
namespace main(123..456);
namespace main(5); // allowed for backward compatibility, translates to `5..5`
```

It adds two new builtins:
```
std::prover::min_degree
std::prover::max_degree
```

And sets the behavior of the `std::prover::degree` builtin to only
succeed if `min_degree` and `max_degree` are equal.
2024-09-03 12:37:44 +00:00
Gastón Zanitti
ea2f06df16 LambdaExpression formatting (#1733)
This PR fixes issue #1728.
1) Removes the blank space that was printed even if the body of the
blocks was empty.
2) Adds the Precedence trait to LambdaExpressions to correctly handle
the use of parentheses.
2024-09-02 09:27:05 +00:00
Gastón Zanitti
4fbac58bd2 Parameterized expressions (#1627)
This PR 'parameterise' Expressions to be able to choose when they can be
converted into a StructExpression and when they cannot. This
modification allows us to overcome ambiguities with Structs and to adopt
the standard Structs syntax:
```
struct Point{ x: int, y: int }
let p: Point = Point{ x: 1, y: 2 };
```

This PR replace #1591 to be able to include this modifications before
merging structs.

---------

Co-authored-by: chriseth <chris@ethereum.org>
2024-08-28 16:48:35 +00:00
Gastón Zanitti
0dc3ae762f Depreciation of . by :: in paths (#1694) 2024-08-23 07:39:50 +00:00
chriseth
7ecf0de94b Change intermediate column syntax. (#1630)
Fixes #1190 
Fixes https://github.com/powdr-labs/powdr/issues/1488

```
// creates intermediate column.
let x: inter = ...
// same here, expects an array on the rhs
let x: inter[k] = ...

// Creates an intermediate column, this is printed from Analyzed
col x = ...;
// Creates an array of intermediate columns, this is printed from analyzed and it's actually new syntax.
col x[k] = ...;

// old syntax for intermediate columns, this just defines a "generic variable" after the change,
// essentially an intermediate column that is always inlined.
let x: expr = ...;
```

---------

Co-authored-by: Leo <leo@powdrlabs.com>
2024-08-03 13:12:57 +00:00
Gastón Zanitti
2e7c473413 Impl parsing (#1490)
This PR splits from the main Trait implementation PR
https://github.com/powdr-labs/powdr/pull/1450 to simplify the review
process.

It includes only the parsing of the impls (trait parsing PR here: #1489
) and some functionality necessary for the code to compile.

---------

Co-authored-by: chriseth <chris@ethereum.org>
2024-07-30 13:49:58 +00:00
chriseth
d1924ecd29 Fixed cols in functions (#1545) 2024-07-26 09:31:52 +00:00
chriseth
fbf2b4074d Store references to captured variables. (#1554) 2024-07-10 20:45:02 +00:00
Gastón Zanitti
70e4f7c39b Trait parsing (#1489)
This PR splits from the main Trait implementation PR #1450 to simplify
the review process.

It includes only the parsing of the traits (not impls) and some
functionality necessary for the code to compile.

---------

Co-authored-by: chriseth <chris@ethereum.org>
2024-07-09 13:25:39 +00:00
chriseth
48b206037f Remove constants. (#1526)
Co-authored-by: schaeff <thibaut@schaeff.fr>
2024-07-08 11:43:39 +00:00
chriseth
38ce19da50 Source reference for pattern (#1411)
Co-authored-by: Thibaut Schaeffer <schaeffer.thibaut@gmail.com>
2024-07-03 21:14:32 +00:00
chriseth
effc3d0164 Support parsing empty namespace (#1529) 2024-07-03 16:56:14 +00:00
Gastón Zanitti
91d41df9a0 Allow blocks to be empty (#1435)
This PR builds on top of #1393.
It mainly modifies the grammar by changing the way SelectedExpressions
are declared, to allow blocks to be empty.

---------

Co-authored-by: chriseth <chris@ethereum.org>
2024-07-01 15:05:32 +00:00
Leandro Pacheco
2b5a308484 Machine arguments (#1356)
Fixes #1493

Allow passing machines as argument when instantiating submachines, as
in:
```
use std::machines::binary::Binary;

machine Main with degree: 262144 {
    reg pc[@pc];
    reg X[<=];
    reg Y[<=];
    reg Z[<=];
    reg A;

    Binary binary;
    WithArg sub(binary);

    instr and X, Y -> Z ~ binary.and;
    instr or X, Y -> Z ~ binary.or;
    instr xor X, Y -> Z ~ binary.xor;
    ...
}

machine WithArg(bin: Binary) {
    reg pc[@pc];
    reg X[<=];
    reg Y[<=];
    reg Z[<=];
    reg A;
    reg B;

    instr and X, Y -> Z ~ bin.and;
    instr or X, Y -> Z ~ bin.or;
    instr xor X, Y -> Z ~ bin.xor;
    ...
}
```
2024-07-01 10:38:08 +00:00
Leandro Pacheco
abbe26618f Instructions with link statements (#1439)
Allow VM instructions to use the `link` notation, unifying the way
machines are linked from VMs and block machines.
Previous syntax for "external instructions" not allowed anymore, and
should use the new `link` syntax.
2024-06-18 17:31:38 +00:00
Thibaut Schaeffer
5f6e1cd0f3 Move parentheses tests to ast (#1448)
For consistency with #1444, no changes to the tests themselves.
2024-06-18 08:16:14 +00:00
chriseth
970c567415 Add end to source ref (#1402) 2024-06-04 14:57:18 +00:00
chriseth
adee683796 Refactor error to use SourceRef (#1398) 2024-05-31 14:47:05 +00:00
chriseth
9ee58fe7d0 Store contents in SourceRef and change to offset instead of line/col. (#1396) 2024-05-28 15:33:38 +00:00
Gastón Zanitti
0d9669e26c SourceRef in expressions (#1357)
This PR solves issue https://github.com/powdr-labs/powdr/issues/1293.

Includes PRs that modify some Expression in order to match fields. It is
recommended to review/merge those first:
- #1351 
- #1352
- #1353
- #1354
- #1355


All comments are welcome :)

---------

Co-authored-by: chriseth <chris@ethereum.org>
2024-05-26 16:52:07 +00:00
Gastón Zanitti
0757e57e8d BlockExpression struct in Expressions (#1355)
This PR is part of issue https://github.com/powdr-labs/powdr/pull/1345.
In particular, it adds the struct BlockExpression to Expressions to
homogenize the structure before including source references.
2024-05-23 10:56:54 +00:00
Gastón Zanitti
c10ffb1fe1 MatchExpression struct in Expressions (#1354)
This PR is part of issue https://github.com/powdr-labs/powdr/pull/1345.
In particular, it adds the struct MatchExpression to Expressions to
homogenise the structure before including source references.
2024-05-22 18:10:56 +00:00
Gastón Zanitti
98da4955de UnaryExpression struct in Expressions (#1352)
This PR is part of issue https://github.com/powdr-labs/powdr/pull/1345.
In particular, it adds the struct UnaryOperation to Expressions to
homogenise the structure before including source references.
2024-05-22 08:48:29 +00:00
Gastón Zanitti
29b0ee6672 BinaryExpression struct in Expressions (#1351)
This PR is part of issue #1345.
In particular, it adds the struct BinaryOperation to Expressions to
homogenise the structure before including source references.

---------

Co-authored-by: Thibaut Schaeffer <schaeffer.thibaut@gmail.com>
2024-05-21 17:58:30 +00:00
Leo
34d04ed873 move internal dependencies to shared version (#1379)
Trying this out which will make releases much easier
2024-05-15 10:46:34 +00:00
Gastón Zanitti
3f2792f98f Number struct in Expressions (#1353)
This PR is part of issue https://github.com/powdr-labs/powdr/pull/1345.
In particular, it adds the struct Number to Expressions to homogenize
the structure before including source references.
2024-05-10 08:06:01 +00:00
Amin Latifi
9472671b9b Reduce Number of Expression Parentheses (#1289)
Adds binary operation precedence support to avoid unnecessary
parentheses in expression printed format

- #962

---------

Co-authored-by: chriseth <chris@ethereum.org>
2024-05-09 07:33:26 +00:00
chriseth
62c3eadc4c Re-enable non-inlined format args (#1362)
Fixes https://github.com/powdr-labs/powdr/issues/1360
2024-05-08 16:27:22 +00:00
chriseth
3e43e33796 Constr as user-defined enum (#1252)
Turns some of the built-in types into user types in the prelude.
2024-05-01 10:29:19 +00:00
Leandro Pacheco
930f24ac43 small improvements to machine properties handing (#1321)
- change lalrpop parsing errors to `String` to allow formatted msgs
- implement Display for MachineProperties and MachineArguments
2024-04-26 10:52:10 +00:00
Leandro Pacheco
cea207ff3f Machine properties using with syntax (#1267)
This implements issue #1251.
Basically `machine Foo(a,b) { ... }` is now `machine Foo with latch: a,
operation_id: b { ... }`
2024-04-25 16:02:01 +00:00
chriseth
3643af03dd Generic enums (#1222) 2024-04-18 12:30:03 +00:00
chriseth
b2e0beef36 Enum pattern (#1216) 2024-04-17 13:11:09 +00:00
chriseth
161f4d8181 Parse turbofish (#1219) 2024-04-04 16:31:11 +00:00
chriseth
3960f8c6e5 Make degree optional for namespace. (#1235) 2024-04-04 12:33:23 +00:00
chriseth
6096afb218 Patterns in let statements and function parameters (#1214)
Co-authored-by: Leo <leo@powdrlabs.com>
2024-04-03 18:39:19 +00:00
chriseth
4e5c464df4 Flexible array pattern (#1208)
Depends on #1205 

Will document in https://github.com/powdr-labs/powdr/pull/1214
2024-04-03 11:48:07 +00:00
chriseth
f46d59dfe1 Basic version of patterns. (#1205)
Depends on #1187 

Implements part of https://github.com/powdr-labs/powdr/issues/982

Will document in https://github.com/powdr-labs/powdr/pull/1214
2024-04-03 09:30:42 +00:00
chriseth
28f0bb9c1d Statements in blocks and function annotations (#1187)
Adds statements at block level and introduces function kinds to be
either pure, constr or query.

closes https://github.com/powdr-labs/powdr/issues/960

---------

Co-authored-by: Leo <leo@powdrlabs.com>
2024-04-02 08:23:39 +00:00
chriseth
f91350e9da Support the empty tuple. (#1213) 2024-04-01 17:22:23 +00:00
chriseth
989087634c Some dependency cleanup. (#1209) 2024-03-28 12:23:35 +00:00
chriseth
f42ca35f83 Let statements in expressions. (#1138)
Allows braced blocks everywhere where expressions are expected.
The statements in those blocks can be `let x` or `let x = ...`.
The former declares a new witness column, the latter just binds a local
variable.

fixes #959
2024-03-25 21:08:45 +00:00
schaeff
8065794633 allow expression in degree statement 2024-03-22 19:20:29 +01:00
chriseth
3bc1ec0f90 Wrap match. 2024-03-21 16:27:13 +01:00
Georg Wiese
80fafbe19c Spell-check 2024-03-20 16:12:55 +01:00