Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"compiler/noirc_errors",
"compiler/noirc_driver",
"compiler/noirc_printable_type",
"compiler/noirc_span",
"compiler/fm",
"compiler/wasm",
# Crates related to tooling built on top of the Noir compiler
Expand Down Expand Up @@ -101,6 +102,7 @@ noirc_errors = { path = "compiler/noirc_errors" }
noirc_evaluator = { path = "compiler/noirc_evaluator" }
noirc_frontend = { path = "compiler/noirc_frontend" }
noirc_printable_type = { path = "compiler/noirc_printable_type" }
noirc_span = { path = "compiler/noirc_span" }

# Noir tooling workspace dependencies
noir_greybox_fuzzer = { path = "tooling/greybox_fuzzer" }
Expand Down
6 changes: 3 additions & 3 deletions acvm-repo/acir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ workspace = true
acir_field.workspace = true
brillig.workspace = true
noir_protobuf.workspace = true
noirc_span.workspace = true

color-eyre.workspace = true
serde.workspace = true
thiserror.workspace = true
flate2.workspace = true
bincode.workspace = true
base64.workspace = true
num-bigint.workspace = true
num_enum.workspace = true
num-traits.workspace = true
prost.workspace = true
rmp-serde.workspace = true
serde-big-array = "0.5.1"
Expand All @@ -47,12 +50,9 @@ serde-generate = "0.25.1"
rustc-hash.workspace = true
criterion.workspace = true
pprof.workspace = true
num-bigint.workspace = true
regex.workspace = true
rmpv.workspace = true
insta.workspace = true
num-traits.workspace = true
noirc_errors.workspace = true
similar-asserts.workspace = true

acir = { path = ".", features = ["arb"] } # Self to turn on `arb`.
Expand Down
1 change: 0 additions & 1 deletion acvm-repo/acir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#[doc = include_str!("../README.md")]
pub mod circuit;
pub mod native_types;
#[cfg(test)]
mod parser;
mod proto;
mod serialization;
Expand Down
11 changes: 9 additions & 2 deletions acvm-repo/acir/src/parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::str::{CharIndices, FromStr};

use acir_field::{AcirField, FieldElement};

use noirc_errors::{Position, Span};

use noirc_span::{Position, Span};
use num_bigint::BigInt;
use num_traits::One;
use thiserror::Error;
Expand Down Expand Up @@ -50,6 +49,14 @@ impl<'a> Lexer<'a> {
}
self.next_token()
}
'/' if self.peek_char() == Some('/') => {
while let Some(char) = self.next_char() {
if char == '\n' {
break;
}
}
self.next_token()
}
'(' => self.single_char_token(Token::LeftParen),
')' => self.single_char_token(Token::RightParen),
'[' => self.single_char_token(Token::LeftBracket),
Expand Down
13 changes: 7 additions & 6 deletions acvm-repo/acir/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::BTreeSet, str::FromStr};
use acir_field::{AcirField, FieldElement};

use lexer::{Lexer, LexerError};
use noirc_errors::Span;
use noirc_span::Span;
use thiserror::Error;
use token::{Keyword, SpannedToken, Token};

Expand All @@ -21,6 +21,7 @@ use crate::{
};

mod lexer;
#[cfg(test)]
mod tests;
mod token;

Expand Down Expand Up @@ -153,14 +154,14 @@ impl<'a> Parser<'a> {
self.parse_witness_ordered_set()
}

fn parse_witness_ordered_set(&mut self) -> ParseResult<BTreeSet<Witness>> {
fn parse_witness_vector(&mut self) -> ParseResult<Vec<Witness>> {
self.eat_or_error(Token::LeftBracket)?;

let mut witnesses = BTreeSet::new();
let mut witnesses = Vec::new();

while !self.eat(Token::RightBracket)? {
let witness = self.eat_witness_or_error()?;
witnesses.insert(witness);
witnesses.push(witness);

// Eat optional comma
if self.eat(Token::Comma)? {
Expand All @@ -176,8 +177,8 @@ impl<'a> Parser<'a> {
Ok(witnesses)
}

fn parse_witness_vector(&mut self) -> ParseResult<Vec<Witness>> {
self.parse_witness_ordered_set().map(|set| set.into_iter().collect::<Vec<_>>())
Comment thread
asterite marked this conversation as resolved.
fn parse_witness_ordered_set(&mut self) -> ParseResult<BTreeSet<Witness>> {
self.parse_witness_vector().map(|vec| vec.into_iter().collect::<BTreeSet<_>>())
}

fn parse_opcodes(&mut self) -> ParseResult<Vec<Opcode<FieldElement>>> {
Expand Down
12 changes: 12 additions & 0 deletions acvm-repo/acir/src/parser/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,18 @@ fn memory_init() {
assert_circuit_roundtrip(src);
}

#[test]
fn memory_init_duplicate_witness() {
let src = "
current witness index : _4
private parameters indices : []
public parameters indices : []
return value indices : []
INIT (id: 4, len: 2, witnesses: [_0, _0])
";
assert_circuit_roundtrip(src);
}

#[test]
fn memory_databus() {
let src = "
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acir/src/parser/token.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use acir_field::FieldElement;
use noirc_errors::{Position, Span, Spanned};
use noirc_span::{Position, Span, Spanned};

#[derive(Debug)]
pub(crate) struct SpannedToken(Spanned<Token>);
Expand Down
1 change: 1 addition & 0 deletions acvm-repo/acvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ark-bls12-381 = { version = "^0.5.0", default-features = false, features = [
ark-ff.workspace = true
ark-bn254.workspace = true
bn254_blackbox_solver.workspace = true
insta.workspace = true
proptest.workspace = true
num-bigint.workspace = true
zkhash = { version = "^0.2.0", default-features = false }
Expand Down
9 changes: 9 additions & 0 deletions acvm-repo/acvm/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,12 @@ pub fn compile<F: AcirField>(

(acir, transformation_map)
}

#[macro_export]
macro_rules! assert_circuit_snapshot {
($acir:expr, $($arg:tt)*) => {
#[allow(unused_mut)]
let acir_string = $acir.to_string();
insta::assert_snapshot!(acir_string, $($arg)*)
};
}
Loading
Loading