User:PythonshellDebugwindow/(Unnamed language)

From Esolang
Jump to navigation Jump to search


++**p is a C-like esolang by User:PythonshellDebugwindow based around pointers.

Basic syntax

++**p; programs generally adhere to this basic syntax:

int() main = (int){
  //Code here;
  (int)main = *NT;

int() main denotes a function declaration. Here, main is a function from an integer to an integer. The code between the curly brackets is in an anonymous int-to-int function. The // represents a comment; comments are terminated by ;. Finally, the (int)main = *NT; returns the result of dereferencing NT (nothing), a pointer to a const int (constant integer): more specifically, NT always points to 0. This uses the syntax of casting and assignment.



Comments are to be denoted by a // double slash, and to last until the end of their line. Multiline comments are to be written between ` backquotes.

Data types

There are two basic data types in ++**p: int, which is a 13-bit integer ranging from -4096 to 4095, inclusive on both ends; and bird, which is a floating-point number with a 1-bit sign bit (with 1 representing positive and 0 negative), an 8-bit mantissa, and a 4-bit exponent, taking up 13 bits in total. ++**p also features pointers, denoted by a * asterisk followed by the type of data it points to. Pointers can point to pointers; there is no limit to this. Ints match the regular expression [0-9]+[Nn], and birds match [0-9]+\.[0-9]+[Bb], where a capital letter denotes a positive value and a lowercase value denotes a negative one.


Variables are declared by writing a data type, optionally preceded by a $ dollars sign (representing const/constant), followed by at least one variable name and optional initializations.


Macros are defined using the # character. Constant macros (i.e., macros which take no arguments) can be declared with #NAME() RESULT, and variable macros (i.e., macros which take arguments) can be declared with #NAME(ARG[ ARG[ ARG[ ...]]]) RESULT where square brackets indicate optional arguments.


Function are declared by writing their return type followed by their name and an optional list of arguments, then their code. Argument lists are located between parentheses and consist of space-separated identifiers.


Hello, world!



//Might fail on -1;
int() incr = (int){
  int n = 1;
  int r = $;
  while(r & n) ignore ((int){
    r = r ^ n;
    n = n << 1;
  $ = r | n;
int() main = (int){
  *int s = (*int)requestMemory(14);
  int addr1 = incr((int)s); int addr2 = incr(addr1); int addr3 = incr(addr2);
  (*s) = 72; (*addr1) = 101; (*addr2) = ((*addr3) = 108);
  ignore freeMemory(putv(s));
  $ = *NT;


 Hello, world!