Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate parsing_a_string.rs #33

Closed
clarus opened this issue Mar 23, 2023 · 1 comment · Fixed by #186
Closed

Translate parsing_a_string.rs #33

clarus opened this issue Mar 23, 2023 · 1 comment · Fixed by #186
Assignees

Comments

@clarus
Copy link
Collaborator

clarus commented Mar 23, 2023

Translate the file https://github.com/formal-land/coq-of-rust/blob/main/examples-from-rust-book/conversion/parsing_a_string.rs

@klausnat klausnat self-assigned this Mar 31, 2023
@InfiniteEchoes
Copy link
Collaborator

InfiniteEchoes commented Apr 6, 2023

Known Issue: Missing Binary Operators Support

The following error message is being produced:

File "./conversion/parsing_a_string.v", line 9, characters 13-16:
Error: The reference add was not found in the current environment.

The 5th line in parsing_a_string.rs is

let sum = parsed + turbo_parsed;let sum = parsed + turbo_parsed;

Which will be translated into the following line in parsing_a_string.v:

  let sum := add parsed turbo_parsed in

From expression.rs it seems like this is the only code that translates the binary operator + into add:

fn compile_bin_op(bin_op: &BinOp) -> String {
    match bin_op.node {
        BinOpKind::Add => "add".to_string(),
        BinOpKind::Sub => "sub".to_string(),
        BinOpKind::Mul => "mul".to_string(),
        BinOpKind::Div => "div".to_string(),
        BinOpKind::Rem => "rem".to_string(),
        BinOpKind::And => "andb".to_string(),
        BinOpKind::Or => "or".to_string(),
        BinOpKind::BitXor => "bit_xor".to_string(),
        BinOpKind::BitAnd => "bit_and".to_string(),
        BinOpKind::BitOr => "bit_or".to_string(),
        BinOpKind::Shl => "shl".to_string(),
        BinOpKind::Shr => "shr".to_string(),
        BinOpKind::Eq => "eqb".to_string(),
        BinOpKind::Lt => "lt".to_string(),
        BinOpKind::Le => "le".to_string(),
        BinOpKind::Ne => "ne".to_string(),
        BinOpKind::Ge => "ge".to_string(),
        BinOpKind::Gt => "gt".to_string(),
    }
}

On the Coq side, CoqOfRust.v is missing support for all binary operators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants