6 releases

0.3.1 Nov 4, 2024
0.3.0 May 18, 2023
0.2.1 Apr 30, 2022
0.1.1 Apr 14, 2022
0.1.0 Jan 24, 2022

#211 in Programming languages

Download history 14/week @ 2024-09-21 126/week @ 2024-11-02 13/week @ 2024-11-09 3/week @ 2024-11-16 1/week @ 2024-11-23

143 downloads per month
Used in brainfuckm

MIT license

71KB
2K SLoC

POETIC

Rust library to parse and interpret poetic source code

It supports all of the instructions and handles digit conversion accordingly, with the only difference being that it dynamically allocates more memory if needed instead of 30.000 bytes. This means memory pointer wrapping at the "end" is not possible. Maybe in the future through a option. https://mcaweb.matc.edu/winslojr/vicom128/final/tutorial/index.html

Tests

There are tests for the parser and interpreter which you can run with:

cargo test

Usage

It will first parse the string source input and parse it to intermediate opcode number representation.

    let mut buf = fs::read_to_string("input.ptc").unwrap();

    let intermediate = Parser::parse_intermediate(&buf);

Then it will convert the intermediate representation to the instructions.

    let instructions = Parser::parse_instructions(&intermediate);

These instructions can then be executed with the interpreter

    let mut interpreter = Interpreter::new(code);
    interpreter.run();

You can let the interpreter just fully execute it with the run method or step through every instruction with the step method.

Example

An example usage can be found at https://github.com/mztikk/poetic_interpreter which is a cli application that will take a poetic source file and execute it.

Dependencies

~245–700KB
~12K SLoC