Function pumpkinscript::textparser::parse [] [src]

pub fn parse(script: &str) -> Result<Program, ParseError>

Parses human-readable PumpkinScript

The format is simple, it is a sequence of space-separated tokens, with binaries represented as:

  • 0x<hexadecimal> (hexadecimal form)
  • "STRING" (string form, newline and double quotes can be escaped with \)
  • integer (integer form, will convert to a big endian big integer)
  • 'instruction (instruction in a binary form)

The rest of the instructions considered to be instructions.

One additional piece of syntax is code included within square brackets: [DUP]. This means that the parser will take the code inside, compile it to the binary form and add as a data push. This is useful for instructions like EVAL. Inside of this syntax, you can use so-called "unwrapping" syntax that can embed a value of a instruction into this code:

PumpkinDB> 1 'a SET [`a] 'b SET 2 'a SET b EVAL
0x01

It is also possible to unwrap multiple levels:

PumpkinDB> "A" 'a SET [[2 ``a DUP] EVAL] 'b SET "B" 'a SET b EVAL
0x02 "A" "A"

Example

parse("0xABCD DUP DROP DROP")

It's especially useful for testing but there is a chance that there will be a "suboptimal" protocol that allows to converse with PumpkinDB over telnet