Preprocessor

From Esolang
Jump to navigation Jump to search

This esolang is made by User:A, inspired by the C preprocessor.

Syntax

Conditions

The if-else directives if and end(End the if) can be used for conditional compilation.

if VERBOSE >= 2
  /*Trace...*/
end

The example code tests if the macro VERBOSE is greater than or equal to 2.

Macros

There are two types of macros, object-like and function-like. Object-like macros do not take parameters; function-like macros do (although the list of parameters may be empty). The generic syntax for declaring an identifier as a macro of each type is, respectively:

<identifier>=<replacement token list>                    // object-like macro.
<identifier>(<parameter list>)=<replacement token list>  //Function-like macro.

Note that a function defenition can take more than 1 lines, as long as it ends with end. There are, of course, operators(math,logic,comparison)which are not listed here.(They are exactly the same as in C) Oh, just forgot to tell you how to call the function: function() To use a marco value: macro

Computational Class

This is an attempt to compile Home Row into Preprocessor, using only 2(2 is enough, as said here) variable-macros.

Well, if that is wrong, you can define 8.

Define 2 variables:

a=0
b=0

a:

a=a+1

Just note that a can be both a and b.

s:

a=a-1

d and f

This does not produce direct code(Just switch the variables).

k and ;

This also doesn't produce any code, but(I think) this woultn't affect TC-ness.

j

Well, that is easy:

if n!=0
    //1st command
end
//second command

l

more complicated...

loop()=if a != 0
   //Stuff all your loop commands HERE
   loop()
end
if a == 0
    end
end