eWagon

From Esolang
Jump to navigation Jump to search

eWagon is a queue- and stack-based language written by User:Orangeyy. 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 1, loop to the previous }, otherwise, continue execution as normal
[ if the condition in the argument stack is 1, 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 and if-statements should be supported.
  • 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'^$.

Tag system (simple 2-tag example)

 "211" Initial
 {
 `'0'~{%!^'0'^`+~%}" "^@,
 Alphabet
 ~% "1"^= ^[`"3321H"]
 ~% "2"^= ^[`"331"]
 ~% "3"^= ^[`"33"]
 ~% "H"^= ^['0']
 
 ~%'0'^_ ^[,,'1'] Tags (commas)
 %'0'^= ^['0']
 ^}
 .

Should output H3333331.

Whitespace removed:

"211"{`'0'~{%!^'0'^`+~%}" "^@,~%"1"^=^[`"3321H"]~%"2"^=^[`"331"]~%"3"^=^[`"33"]~%"H"^= ^['0']~%'0'^_^[,,'1']%'0'^=^['0']^}.

External resources

eWagon on GitHub eWagon2 on GitHub