michelson-ast

Overview

michelson-ast-rs is a Rust library for generating Michelson code. This library can handle the Abstract Syntax Tree (AST) of Michelson, the smart contract language for Tezos.

Usage

To generate Michelson code using this library, you can write a program like the following: ```rust use michelsonast::instruction::Instruction; use michelsonast::instructionwithcomment::InstructionWithComment; use michelsonast::program::Program; use michelsonast::ty::Ty; use michelson_ast::val::Val;

fn main() { let program = Program { storage: Ty::Unit, parameter: Ty::Unit, code: vec![ InstructionWithComment { comment: Some("=> Unit".tostring()), instruction: Instruction::Cdr, }, InstructionWithComment { comment: Some("=> {} : Unit".tostring()), instruction: Instruction::Nil { ty: Ty::Operation }, }, InstructionWithComment { comment: Some("=> (Pair {} Unit)".to_string()), instruction: Instruction::Pair, }, ], };

let result = program.to_string();
println!("{}", result);

} ```

Example output

storage unit; parameter unit; code { CDR; # => Unit NIL operation; # => {} : Unit PAIR; # => (Pair {} Unit) }