Crates.io | michelson-ast |
lib.rs | michelson-ast |
version | 0.1.2 |
source | src |
created_at | 2023-03-19 16:50:37.914719 |
updated_at | 2023-05-25 19:45:38.102145 |
description | An AST for Michelson, a Tezos smart contract language |
homepage | https://github.com/woxjro/michelson-ast |
repository | https://github.com/woxjro/michelson-ast |
max_upload_size | |
id | 814527 |
size | 40,408 |
michelson-ast
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.
To generate Michelson code using this library, you can write a program like the following:
use michelson_ast::{
instruction::Instruction,
program::Program, ty::Ty,
wrapped_instruction::WrappedInstruction,
};
fn main() {
let program = Program {
storage: Ty::Unit,
parameter: Ty::Unit,
code: vec![
WrappedInstruction {
comment: Some("=> Unit".to_owned()),
instruction: Instruction::Cdr,
},
WrappedInstruction {
comment: Some("=> {} : Unit".to_owned()),
instruction: Instruction::Nil { ty: Ty::Operation },
},
WrappedInstruction {
comment: Some("=> (Pair {} Unit)".to_owned()),
instruction: Instruction::Pair,
},
],
};
println!("{}", program.to_string());
}
parameter unit;
storage unit;
code {
CDR; # => Unit
NIL operation; # => {} : Unit
PAIR; # => (Pair {} Unit)
}