Pxem

From Esolang
Jump to: navigation, search
Pxem
Paradigm(s)
Designed by ぬこ
Appeared in 2008
Computational class
Reference implementation
File extension(s) .pxe, .pxem


Pxem is a programming language designed by "ぬこ"(Romanization:Nuko). It is said that its name "Pxem" does not have any meanings. It was named because "it's easy to type its name with keyboard."

History

Pxem was designed by "ぬこ" in 2008, which used to be published in his/her own website before. According to his/her blog[1], (s)he used to compete in coding-golf held on anarchy golf using Perl, PHP, and brainfuck. One day, shinh, the host of the site, introduced GolfScript, which is designed for coding-golf. In some courses, the script enables you to code with only one-byte files. This inspired him/her to make the language for coding-golf, which you can compete with zero-byte files. This is how Pxem got designed.

Specifications

This language recognizes not only the contents of file, but also filename as a code. This enables you to make any programs having 0 bytes. Pxem has a stack and a temporary region, which both them store int values.

The interpreter cannot see the directory name where the file is.

Word Definition

In order to explain the commands below, I define the words.

Pop the stack
Removes the most recently added element that was not yet removed as a int value. Popped value will be gone.
Push the stack
Adds an element to the stack.

Commands

Command Description
.p Pops the entire of stack as a string. This makes the stack empty.
.o Pops the stack to output as a character code. If the stack is empty, nothing happens.
.n Pops the stack to output as a numeral value. If the stack is empty, nothing happens. It stands for printf("%d") in C.
.i Gets an input from STDIN as one-byte data to push. When it reaches to EOF, it returns -1. It stands for getchar().
._ Gets an input from STDIN as a signed-integer number to push. It stands for scanf("%d").
.c Pops the stack, then copy the value, then pushes them. If the stack is empty, nothing happens.
.s Pops the stack to throw the value away. If the stack is empty, nothing happens.
.v Reverses the stack. This command should not be done frequently.
.f Pushes the content of the file as a string.
.e Executes the content of the file as a Pxem code on another process. The new stack will be created and original one's content will be copied to it. When the new process ends, the content of new stack will be stacked to the original one. You can command as many .e command on the file content as possible.
.r Pops the stack and generates a random number that is 0 or bigger and smaller than the popped value, then pushes the generated value. For example, if popped value is 10, a random number out of from 0 to 9 will be generated.
.w Pops the stack. If popped value is 0 or the stack is empty, skips to the next .a.
.x Pops the stack twice. If first-popped value is equal to or bigger than second-popped one, or the stack has less than two elements, skips to the next .a.
.y Pops the stack twice. If first-popped value is equal to or smaller than second-popped one, or the stack has less than two elements, skips to the next .a.
.z Pops the stack twice. If first-popped value is equal to second-popped one, or the stack has less than two elements, skips to the next .a.
.a Goes back to previous .w, .x, .y, or .z.
.t Pops the stack to substitute the value to the temporal int region (that is different from stack). Previously-registered value will be lost.
.m Pushes the value on temporal region to the stack. If the region is not used, nothing happens.
.d Ends execution.
.+ Pops twice and push back the sum of two popped values. If stack has less than two values, nothing happens.
.- Pops twice and push back the difference of two popped values. The value to be pushed will be larger than 0. If stack has less than two values, nothing happens.
.! Pops twice and push back the product of two popped values. If stack has less than two values, nothing happens.
.$ Pops twice and push back the quotient when you divide the smaller popped value by larger one. If stack has less than two values, nothing happens.
.% Pops twice and push back the remainder when you divide the smaller popped value by larger one. If stack has less than two values, nothing happens.

Strings

When the interpreter recognizes non-command parts, they will be recognized as string. When the interpreter reaches to command, formerly recognized string will be pushed to stack reversely. For example, if you execute the file called Hello, world!.pxe, there are a command.p and a string Hello, world!. When interpreter reaches to .p, the string will be stored to stack in following order:!dlrow ,olleH.

Detailed Specifications

On author's new blog, these terms got specified[1].

  • The filename will be read at first.
  • Three outputting commands, .p, .o, and .n does not output newline unless the \n character is stored to the stack.
  • If the stack has only a data while the interpreter finds conditional commands .x, .y, and .z, the data on the stack will NOT be lost.
  • When .e command gets executed, new temporary variable will be created. When its execution ends, the variable will be deleted.
  • If there's no .e command on filename, the content of file will be ignored.
  • The interpreter does not tell from capitalized commands from lowercase ones.
    • As a result, two files named Hello, world!.f.pxe and Hello, world!.F.pxe will work in the same way.
  • The number of .w, .x, .y, and .z must be equal to .a.
  • Due to not having the command to swap two top values of the stack, this language is not Turing-complete.

Examples

Hello, world!

To output Hello, world!, the filename should be:

Hello, world!.pxe

while the contents of file is empty.

Echo

Filename
1.w.o.i.c12.-.+.a.s.pxe
File Contents
(none)

Ultimate problem

Filename
42.pxe
File Contents
(none)

delete last line

Filename
1.w.i.c12.-.+.a1.zak.-.a.v.pxe
File Contents
(none)

FizzBuzz

Filename
ak.-akbuzz.-ak4.-akfizz.-ak2.-1.p05.-.tab.z01.-.c.m.+.c.t05.-.%.w.s01.-.m03.-.%.W.s.m.nak.-.p00.-.c.c.c.a.wak.-fizz.p00.-.c.c.a.a.w01.-.m03.-.%.w.sak.-buzz.p00.-.c.c.a.wak.-fizzbuzz.p00.-.c.a.a.md2.-02.-.!.a.d.pxe
File Contents
(none)

Interpreter Development

Original author used to publish its interpreter named "pxemi.exe", which was developed in C++ and would work on Windows only. As on September 2018, there are three repositories for interpreter-development. Links are in next section.

After ten years, its original interpreter got published again on original author's blog[1].

External Links

References