bfx
An interpreter, compiler, and REPL for brainfuck-like languages
Loading...
Searching...
No Matches
grin.h File Reference
#include "bfx.h"

Go to the source code of this file.

Data Structures

struct  BFX_GrinData
 Data structure for Grin language. More...
 

Macros

#define BFX_GRIN_DEFAULT_PRECISION   4
 Default number of decimal places to print.
 

Enumerations

enum  BFX_GrinUnit { BFX_GRIN_DEG = 0 , BFX_GRIN_RAD = 1 }
 Unit of measurement for Grin language. More...
 

Functions

BFX_Error bfx_grin_init (BFX *)
 Initialize the Grin interpreter.
 
BFX_Error bfx_grin_run (BFX *)
 Run the Grin interpreter.
 
BFX_Error bfx_op_grin_inc_t (BFX *, BFX_FileIndex *)
 Increment value at tape pointer (Grin).
 
BFX_Error bfx_op_grin_dec_t (BFX *, BFX_FileIndex *)
 Decrement value at tape pointer (Grin).
 
BFX_Error bfx_op_grin_loop_start (BFX *, BFX_FileIndex *)
 Start of loop (Grin).
 
BFX_Error bfx_op_grin_loop_end (BFX *, BFX_FileIndex *)
 End of loop (Grin).
 
BFX_Error bfx_op_grin_putchar_ascii (BFX *, BFX_FileIndex *)
 Output current cell as ASCII character (Grin)
 
BFX_Error bfx_op_grin_putchar_number (BFX *, BFX_FileIndex *)
 Output current cell as a number (Grin)
 
BFX_Error bfx_op_grin_getchar_ascii (BFX *, BFX_FileIndex *)
 Set current cell to inputted ASCII character (Grin)
 
BFX_Error bfx_op_grin_getchar_number (BFX *, BFX_FileIndex *)
 Set current cell to inputted number (Grin)
 
BFX_Error bfx_op_grin_putchar_register_ascii (BFX *, BFX_FileIndex *)
 Print register as ASCII character (Grin)
 
BFX_Error bfx_op_grin_putchar_register_number (BFX *, BFX_FileIndex *)
 Print register as number (Grin)
 
BFX_Error bfx_op_grin_add (BFX *, BFX_FileIndex *)
 Add register to current cell (Grin)
 
BFX_Error bfx_op_grin_sub (BFX *, BFX_FileIndex *)
 Subtract register from current cell (Grin)
 
BFX_Error bfx_op_grin_mul (BFX *, BFX_FileIndex *)
 Multiply current cell by register (Grin)
 
BFX_Error bfx_op_grin_div (BFX *, BFX_FileIndex *)
 Divide current cell by register (Grin)
 
BFX_Error bfx_op_grin_exp (BFX *, BFX_FileIndex *)
 Raise current cell to the power of register (Grin)
 
BFX_Error bfx_op_grin_store (BFX *, BFX_FileIndex *)
 Store current cell value in register (Grin)
 
BFX_Error bfx_op_grin_load (BFX *, BFX_FileIndex *)
 Store register value in current cell (Grin)
 
BFX_Error bfx_op_grin_swap (BFX *, BFX_FileIndex *)
 Swap current cell value with register value (Grin)
 
BFX_Error bfx_op_grin_zero (BFX *, BFX_FileIndex *)
 Zero current cell value (Grin)
 
BFX_Error bfx_op_grin_zero_ptr (BFX *, BFX_FileIndex *)
 Zero cell at register value (Grin)
 
BFX_Error bfx_op_grin_mod (BFX *, BFX_FileIndex *)
 Modulo (Grin)
 
BFX_Error bfx_op_grin_round (BFX *, BFX_FileIndex *)
 Round current cell value (Grin)
 
BFX_Error bfx_op_grin_nand (BFX *, BFX_FileIndex *)
 NAND current cell value with register value (Grin)
 
BFX_Error bfx_op_grin_or (BFX *, BFX_FileIndex *)
 OR current cell value with register value (Grin)
 
BFX_Error bfx_op_grin_not (BFX *, BFX_FileIndex *)
 NOT current cell value (Grin)
 
BFX_Error bfx_op_grin_negate (BFX *, BFX_FileIndex *)
 Negate current cell value (Grin)
 
BFX_Error bfx_op_grin_simplify (BFX *, BFX_FileIndex *)
 Simplify current cell value (set to -1.0 if < -1.0, 1.0 if > 1.0, 0.0 otherwise) (Grin)
 
BFX_Error bfx_op_grin_print (BFX *, BFX_FileIndex *)
 Print from instruction pointer to next ')' (Grin)
 
BFX_Error bfx_op_grin_newline (BFX *, BFX_FileIndex *)
 Print a newline (Grin)
 
BFX_Error bfx_op_grin_sin (BFX *, BFX_FileIndex *)
 Sine of current cell value (Grin)
 
BFX_Error bfx_op_grin_cos (BFX *, BFX_FileIndex *)
 Cosine of current cell value (Grin)
 
BFX_Error bfx_op_grin_tan (BFX *, BFX_FileIndex *)
 Tangent of current cell value (Grin)
 
BFX_Error bfx_op_grin_arcsin (BFX *, BFX_FileIndex *)
 Arcsine of current cell value (Grin)
 
BFX_Error bfx_op_grin_arccos (BFX *, BFX_FileIndex *)
 Arccosine of current cell value (Grin)
 
BFX_Error bfx_op_grin_arctan (BFX *, BFX_FileIndex *)
 Arctangent of current cell value (Grin)
 
BFX_Error bfx_op_grin_inv (BFX *, BFX_FileIndex *)
 Inverse of current cell value (Grin)
 
BFX_Error bfx_op_grin_mod2 (BFX *, BFX_FileIndex *)
 Modulo of current cell value by 2 (Grin)
 
BFX_Error bfx_op_grin_e (BFX *, BFX_FileIndex *)
 Set current cell to Euler's number (Grin)
 
BFX_Error bfx_op_grin_pi (BFX *, BFX_FileIndex *)
 Set current cell to Pi (Grin)
 
BFX_Error bfx_op_grin_ln (BFX *, BFX_FileIndex *)
 Natural logarithm of current cell value (Grin)
 
BFX_Error bfx_op_grin_mean (BFX *, BFX_FileIndex *)
 Mean of current cell value and register value (Grin)
 
BFX_Error bfx_op_grin_sqrt (BFX *, BFX_FileIndex *)
 Square root of current cell value (Grin)
 
BFX_Error bfx_op_grin_log (BFX *, BFX_FileIndex *)
 Base-10 logarithm of current cell value (Grin)
 
BFX_Error bfx_op_grin_jump (BFX *, BFX_FileIndex *)
 Jump n instructions, n=register value (Grin)
 
BFX_Error bfx_op_grin_toggle_deg_rad (BFX *, BFX_FileIndex *)
 Toggle between degrees and radians (Grin)
 
BFX_Error bfx_op_grin_exit (BFX *, BFX_FileIndex *)
 Exit the program (Grin)
 

Detailed Description

This file contains function definitions related to interpreting the Grin language.

Macro Definition Documentation

◆ BFX_GRIN_DEFAULT_PRECISION

#define BFX_GRIN_DEFAULT_PRECISION   4

Default number of decimal places to print.

Enumeration Type Documentation

◆ BFX_GrinUnit

Unit of measurement for Grin language.

Enumerator
BFX_GRIN_DEG 

Degrees.

BFX_GRIN_RAD 

Radians.

Function Documentation

◆ bfx_grin_init()

BFX_Error bfx_grin_init ( BFX bfx)

Initialize the Grin interpreter.

Parameters
bfxPointer to the already-allocated interpreter struct

◆ bfx_grin_run()

BFX_Error bfx_grin_run ( BFX bfx)

Run the Grin interpreter.

This function initializes and runs the Grin interpreter.

Parameters
bfxPointer to the interpreter struct
Returns
Error code

◆ bfx_op_grin_add()

BFX_Error bfx_op_grin_add ( BFX bfx,
BFX_FileIndex index 
)

Add register to current cell (Grin)

◆ bfx_op_grin_arccos()

BFX_Error bfx_op_grin_arccos ( BFX bfx,
BFX_FileIndex index 
)

Arccosine of current cell value (Grin)

◆ bfx_op_grin_arcsin()

BFX_Error bfx_op_grin_arcsin ( BFX bfx,
BFX_FileIndex index 
)

Arcsine of current cell value (Grin)

◆ bfx_op_grin_arctan()

BFX_Error bfx_op_grin_arctan ( BFX bfx,
BFX_FileIndex index 
)

Arctangent of current cell value (Grin)

◆ bfx_op_grin_cos()

BFX_Error bfx_op_grin_cos ( BFX bfx,
BFX_FileIndex index 
)

Cosine of current cell value (Grin)

◆ bfx_op_grin_dec_t()

BFX_Error bfx_op_grin_dec_t ( BFX bfx,
BFX_FileIndex index 
)

Decrement value at tape pointer (Grin).

◆ bfx_op_grin_div()

BFX_Error bfx_op_grin_div ( BFX bfx,
BFX_FileIndex index 
)

Divide current cell by register (Grin)

◆ bfx_op_grin_e()

BFX_Error bfx_op_grin_e ( BFX bfx,
BFX_FileIndex index 
)

Set current cell to Euler's number (Grin)

◆ bfx_op_grin_exit()

BFX_Error bfx_op_grin_exit ( BFX bfx,
BFX_FileIndex index 
)

Exit the program (Grin)

◆ bfx_op_grin_exp()

BFX_Error bfx_op_grin_exp ( BFX bfx,
BFX_FileIndex index 
)

Raise current cell to the power of register (Grin)

◆ bfx_op_grin_getchar_ascii()

BFX_Error bfx_op_grin_getchar_ascii ( BFX bfx,
BFX_FileIndex index 
)

Set current cell to inputted ASCII character (Grin)

◆ bfx_op_grin_getchar_number()

BFX_Error bfx_op_grin_getchar_number ( BFX bfx,
BFX_FileIndex index 
)

Set current cell to inputted number (Grin)

◆ bfx_op_grin_inc_t()

BFX_Error bfx_op_grin_inc_t ( BFX bfx,
BFX_FileIndex index 
)

Increment value at tape pointer (Grin).

◆ bfx_op_grin_inv()

BFX_Error bfx_op_grin_inv ( BFX bfx,
BFX_FileIndex index 
)

Inverse of current cell value (Grin)

◆ bfx_op_grin_jump()

BFX_Error bfx_op_grin_jump ( BFX bfx,
BFX_FileIndex index 
)

Jump n instructions, n=register value (Grin)

◆ bfx_op_grin_ln()

BFX_Error bfx_op_grin_ln ( BFX bfx,
BFX_FileIndex index 
)

Natural logarithm of current cell value (Grin)

◆ bfx_op_grin_load()

BFX_Error bfx_op_grin_load ( BFX bfx,
BFX_FileIndex index 
)

Store register value in current cell (Grin)

◆ bfx_op_grin_log()

BFX_Error bfx_op_grin_log ( BFX bfx,
BFX_FileIndex index 
)

Base-10 logarithm of current cell value (Grin)

◆ bfx_op_grin_loop_end()

BFX_Error bfx_op_grin_loop_end ( BFX bfx,
BFX_FileIndex index 
)

End of loop (Grin).

◆ bfx_op_grin_loop_start()

BFX_Error bfx_op_grin_loop_start ( BFX bfx,
BFX_FileIndex index 
)

Start of loop (Grin).

◆ bfx_op_grin_mean()

BFX_Error bfx_op_grin_mean ( BFX bfx,
BFX_FileIndex index 
)

Mean of current cell value and register value (Grin)

◆ bfx_op_grin_mod()

BFX_Error bfx_op_grin_mod ( BFX bfx,
BFX_FileIndex index 
)

Modulo (Grin)

◆ bfx_op_grin_mod2()

BFX_Error bfx_op_grin_mod2 ( BFX bfx,
BFX_FileIndex index 
)

Modulo of current cell value by 2 (Grin)

◆ bfx_op_grin_mul()

BFX_Error bfx_op_grin_mul ( BFX bfx,
BFX_FileIndex index 
)

Multiply current cell by register (Grin)

◆ bfx_op_grin_nand()

BFX_Error bfx_op_grin_nand ( BFX bfx,
BFX_FileIndex index 
)

NAND current cell value with register value (Grin)

◆ bfx_op_grin_negate()

BFX_Error bfx_op_grin_negate ( BFX bfx,
BFX_FileIndex index 
)

Negate current cell value (Grin)

◆ bfx_op_grin_newline()

BFX_Error bfx_op_grin_newline ( BFX bfx,
BFX_FileIndex index 
)

Print a newline (Grin)

◆ bfx_op_grin_not()

BFX_Error bfx_op_grin_not ( BFX bfx,
BFX_FileIndex index 
)

NOT current cell value (Grin)

◆ bfx_op_grin_or()

BFX_Error bfx_op_grin_or ( BFX bfx,
BFX_FileIndex index 
)

OR current cell value with register value (Grin)

◆ bfx_op_grin_pi()

BFX_Error bfx_op_grin_pi ( BFX bfx,
BFX_FileIndex index 
)

Set current cell to Pi (Grin)

◆ bfx_op_grin_print()

BFX_Error bfx_op_grin_print ( BFX bfx,
BFX_FileIndex index 
)

Print from instruction pointer to next ')' (Grin)

◆ bfx_op_grin_putchar_ascii()

BFX_Error bfx_op_grin_putchar_ascii ( BFX bfx,
BFX_FileIndex index 
)

Output current cell as ASCII character (Grin)

◆ bfx_op_grin_putchar_number()

BFX_Error bfx_op_grin_putchar_number ( BFX bfx,
BFX_FileIndex index 
)

Output current cell as a number (Grin)

◆ bfx_op_grin_putchar_register_ascii()

BFX_Error bfx_op_grin_putchar_register_ascii ( BFX bfx,
BFX_FileIndex index 
)

Print register as ASCII character (Grin)

◆ bfx_op_grin_putchar_register_number()

BFX_Error bfx_op_grin_putchar_register_number ( BFX bfx,
BFX_FileIndex index 
)

Print register as number (Grin)

◆ bfx_op_grin_round()

BFX_Error bfx_op_grin_round ( BFX bfx,
BFX_FileIndex index 
)

Round current cell value (Grin)

◆ bfx_op_grin_simplify()

BFX_Error bfx_op_grin_simplify ( BFX bfx,
BFX_FileIndex index 
)

Simplify current cell value (set to -1.0 if < -1.0, 1.0 if > 1.0, 0.0 otherwise) (Grin)

◆ bfx_op_grin_sin()

BFX_Error bfx_op_grin_sin ( BFX bfx,
BFX_FileIndex index 
)

Sine of current cell value (Grin)

◆ bfx_op_grin_sqrt()

BFX_Error bfx_op_grin_sqrt ( BFX bfx,
BFX_FileIndex index 
)

Square root of current cell value (Grin)

◆ bfx_op_grin_store()

BFX_Error bfx_op_grin_store ( BFX bfx,
BFX_FileIndex index 
)

Store current cell value in register (Grin)

◆ bfx_op_grin_sub()

BFX_Error bfx_op_grin_sub ( BFX bfx,
BFX_FileIndex index 
)

Subtract register from current cell (Grin)

◆ bfx_op_grin_swap()

BFX_Error bfx_op_grin_swap ( BFX bfx,
BFX_FileIndex index 
)

Swap current cell value with register value (Grin)

◆ bfx_op_grin_tan()

BFX_Error bfx_op_grin_tan ( BFX bfx,
BFX_FileIndex index 
)

Tangent of current cell value (Grin)

◆ bfx_op_grin_toggle_deg_rad()

BFX_Error bfx_op_grin_toggle_deg_rad ( BFX bfx,
BFX_FileIndex index 
)

Toggle between degrees and radians (Grin)

◆ bfx_op_grin_zero()

BFX_Error bfx_op_grin_zero ( BFX bfx,
BFX_FileIndex index 
)

Zero current cell value (Grin)

◆ bfx_op_grin_zero_ptr()

BFX_Error bfx_op_grin_zero_ptr ( BFX bfx,
BFX_FileIndex index 
)

Zero cell at register value (Grin)