Introduction
Brainstract, a newly created dialect of Brainfuck adds a bit more elements to the syntax. In addition to the normal Brainfuck syntax, there are macros. To define a macro:
{macro_name ++++}
Then use it:
{macro_name} Adds 4 to the current cell
Challenge
Your challenge is to take a valid Brainstract program as input (command-line-arguments, function arguments, STDIN or file), and output a valid Brainfuck program that is equivalent to the Brainstract program (non-brainfuck characters are allowed in output). You may assume all input will be valid Brainstract.
Brainstract Spec
Whitespace counts as ANY whitespace (tabs, spaces, etc.)
A macro is defined by an opening brace character ({
) followed by a macro name which must be made up of any characters except whitespace, brainfuck, and Brainstract characters (anything except whitespace and {}[]<>+-.,
)
Then, it is followed by any amount of whitespace and a macro definition, made up of macro calls and non-brace characters and finally the macro is closed off with a closing brace (}
)
A macro call is of the form {macro_name}
where macro name is the same as above.
Examples
Format: Input -> Output
{cat ,.} {cat}{cat}{cat} -> ,.,.,.
{add [>+<-]} ++++>+<{add} -> ++++>+<[>+<-]
{recursive ,.{recursive}} -> (undefined behavior)
++++ {decrement -} ++++ {decrement} -> ++++++++-
{a >>>---<<<} {b {a}{a}} {b} -> >>>---<<<>>>---<<<
{cat ,.} {cat3 {cat}{cat}{cat}} {cat3}
a valid input? \$\endgroup\$