Free Hero Mesh

Update of "Preprocessor"
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview

Artifact ID: 87b3bc62d12dce74d0470d54322e85de0d5f3831
Page Name:Preprocessor
Date: 2018-06-24 03:02:18
Original User: zzo38
Parent: a51408f9ca7152f8ea21fdd8db64cdf1cd8716f1 (diff)
Content

Preprocessor commands are put in braces. Put a left brace, and then the macro name, and then the arguments (if any), and then a right brace.

Macros are expanded (sometimes with side-effects) outside of any braces, as well as inside braces where a number or string is expected, but are not expanded as part of the definition or arguments to a user-defined macro.

Other tokens used in the preprocessor are a macro separator token, which is written by a vertical bar, and a macro argument token, which is written as one or more backslashes followed by a number from 1 to 255. The purpose of these are explained below.

Built-in macros include:

User-defined macros

Use the {define} command to define your own macros. The first argument is a string that specifies the macro name; the rest is the definition of the macro that it will expand to.

Inside of the definition, a macro argument token with a single backslash is replaced by the corresponding macro argument, and a macro argument token with multiple backslashes is replaced by the same one but with one less backslash (this way, a macro can define another macro).

When calling a user-defined macro, the arguments are given in the following way: Any group inside of braces/parentheses is treated as a single argument (including the braces/parentheses in the argument). A macro separator token outside of braces/parentheses means that this is the last argument consisting of everything up to the matching right brace, possibly including other macro separator tokens (but not the one that introduced this long argument).

Computational class

It is believed to be Turing-complete, because a tag system can be implemented, for example:
{define "skip" {call \2}}
{define "1" {skip \1|"3"|"3"|"2"|"1"|"H"}}
{define "2" {skip \1|"3"|"3"|"1"}}
{define "3" {skip \1|"3"|"3"}}
{define "H" \1}
{call "2"|"1"|"1"}