eWagon

From Esolang
Jump to: navigation, search

eWagon is a queue- and stack-based language written by User:Timtomtoaster. Its name stands for Esolang Without A Good Name. What makes it unique is that you can switch between a Queue Mode and a Stack Mode. It's also got a few features I "borrowed" from Befunge, especially using quotes to push the ASCII values of strings.

Command list

Note: All commands will push their results to the stack/queue (depending on mode) and take their arguments from the argument queue, except %, , and ^.

Instruction Description
'number' put the number between the single quotes into the queue/stack
"text" put the ASCII values of every character between the quotes into the queue/stack
^ pop/dequeue from the main stack/queue and put it into the argument queue
% peek from the main stack/queue and put it into the argument queue
, discard the front value of the stack/queue
+ add two numbers
- subtract two numbers
* multiply two numbers
/ divide two numbers
| perform modulo on two numbers
= test if two numbers are equal, and push a 1 or 0 accordingly
_ test if two numbers are unequal, and push a 1 or 0 accordingly
> test if one number is greater than the other, and push a 1 or 0 accordingly
< test if one number is less than the other, and push a 1 or 0 accordingly
$ print an number with a linebreak
# print an number without a linebreak
@ print an ASCII character with a linebreak
! print an ASCII character without a linebreak
& get numerical input
? get text input
{ begin a loop
} if the condition in the argument stack is truthy, loop to the previous }, otherwise, continue execution as normal
[ if the condition in the argument stack is truthy, execute the code between the []'s, otherwise, skip over it
] end if-statement
~ queue mode
` stack mode
. stop the program

Some important info:

  • Nested loops are supported, nested if-statements are not.
  • Multi-line comments are supported.
  • All whitespace (spaces, tabs, and linebreaks) are supported.
  • Any character that's not listed above is treated as a comment.

eWagon2

eWagon2 is mostly the same as eWagon, but it uses a double-ended queue (deque) for storage. The ~ command switches to "front mode", and ` "back mode" (enabled by default). Front mode will enqueue, dequeue, and peek from the front of the deque, and vice versa for back mode. It doesn't include any performance enhancements, though the interpreter is 21 lines shorter than eWagon1.

Sample programs (both versions)

It seems that there isn't much of a difference in length or the actual code between the eWagon1 and 2 example programs, even though they store things rather differently. Weird.

eWagon1

Hello world

`"!dlrow ,olleH"{%!"!"^^_^}'0'^@.

Cat (numerical input only)

{&^$'1'^}

Fibonacci sequence

'0''1'{~%$^%+`'1'^}

Truth-machine

&^[{%$'1'^}]'0'^$. 

eWagon2

Hello world

`"Hello, world!"'0'~{%!^}'0'^@.

Cat (string input)

{`?'0'~{%!^}'0'^@'1'^}

Fibonacci sequence

'0''1'{~%$^%`+'1'^}

Truth-machine

&%[{%$%}]'0'^$.

Using the interpreter (both versions)

As of writing this page, only one interpreter exists for eWagon. To use it, either execute git clone https://github.com/tatersmaters/eWagon in the terminal or go to the GitHub page below and download the .zip file, then extract it. Then, execute python eWagon.py [filename].ewx from the terminal. The extension for eWagon files is .ew1 or .ew2, depending on which version of eWagon you're using.

Evil plans (again, both versions)

What I plan to implement (feel free to help!):

  • Modules & Add-ons
    • Modules will be .ewm (eWagon Module) files, containing pieces of eWagon code. You can call these pieces from within the main program.
    • Add-ons will be .py files, and the interpreter will probably have to be modified to allow new modules to be supported.
  • Subroutines

THESE CHANGES AREN'T GUARANTEED!

External resources

eWagon on GitHub eWagon2 on GitHub