Skip to content

Commit

Permalink
new parser integration
Browse files Browse the repository at this point in the history
  • Loading branch information
neotheprogramist committed Feb 8, 2024
1 parent 3d99b76 commit 5b660f3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 141 deletions.
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

scarb build && \
cargo run --release -- ./target/dev/cairo_verifier.sierra.json < ./resources/in.txt
cargo run --release -- ./target/dev/cairo_verifier.sierra.json < ./resources/main_proof.json
19 changes: 8 additions & 11 deletions runner/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
[package]
name = "runner"
version.workspace = true
edition.workspace = true
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow.workspace = true
cairo-args-runner.workspace = true
clap.workspace = true
lalrpop-util.workspace = true
serde.workspace = true
serde_json.workspace = true

[build-dependencies]
lalrpop.workspace = true
anyhow = "1.0.79"
cairo-args-runner = "1.0.1"
clap = { version = "4.4.18", features = ["derive"] }
cairo-proof-parser = { git = "https://github.com/cartridge-gg/cairo-proof-parser", tag = "v0.1.0" }
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
3 changes: 0 additions & 3 deletions runner/build.rs

This file was deleted.

66 changes: 0 additions & 66 deletions runner/src/ast.rs

This file was deleted.

33 changes: 16 additions & 17 deletions runner/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use std::io::{stdin, Read};

use cairo_args_runner::{run, Arg, VecFelt252};
use cairo_args_runner::{Arg, Felt252, VecFelt252};
use clap::Parser;
use lalrpop_util::lalrpop_mod;

mod ast;

lalrpop_mod!(pub parser);
use cairo_proof_parser::parse;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
Expand All @@ -16,21 +13,23 @@ struct Cli {
}

fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
let args = Cli::parse();
let mut input = String::new();
stdin().read_to_string(&mut input)?;
let exprs = parse(input)?.to_string();

let parsed = parser::CairoParserOutputParser::new()
.parse(&input)
.map_err(|e| anyhow::anyhow!("{}", e))?;
let result = parsed.to_string();

let target = cli.target;
let function = "main";
let args: VecFelt252 = serde_json::from_str(&result).unwrap();

let result = run(&target, function, &[Arg::Array(args.to_vec())])?;
run(exprs, args.target)?;

println!("{result:?}");
Ok(())
}

fn run(parsed: String, target: String) -> anyhow::Result<Vec<Felt252>> {
let target = target;
let function = "main";
let args: VecFelt252 = serde_json::from_str(&parsed).unwrap();
Ok(cairo_args_runner::run(
&target,
function,
&[Arg::Array(args.to_vec())],
)?)
}
43 changes: 0 additions & 43 deletions runner/src/parser.lalrpop

This file was deleted.

0 comments on commit 5b660f3

Please sign in to comment.