nya~rgs
Jump to navigation
Jump to search
nya~rgs is an esoteric programming language that uses singular commands for each instruction. Each line can contain multiple commands or just a singular one. It also handles memory and variables with an array of any object type but the only types that can be achieved are strings, characters, and integers.
The interpreter as well as some example code can be found here
Guide
- Each command must start with a command character and end with a .
- Arguments are split by colons
- Everything after a full stop that isnt a command is ignored allowing for comments easily
Example:
'0:Hello World. Store "Hello World" in address 0 @0._ Print address 0 and halt
Command Modifiers
- Command modifiers may be used to change the way commands behave
- For example using +> instead of +
Example:
^0:0. Load int 0 into address 0 ^1:2. Load int 2 into address 1 +0:1. Add value 1 to address 0 +>0:1. add memory address 0 and memory address 1
Jumps / Goto
- There are two types of goto one conditional and one unconditional
- The conditional jump compares two memory addresses to see if they are equal
- One note that the string 5 and the int 5 will be seen as equal
Example:
^1:1. Input value 1 into address 1 ;0. Input into address 0 @0. Print 0 ?1:0:0:1. go to the second line at the first character if memory address 1 and 0 are equal
A further example:
^0:0. Load value 0 into address 0 @0. Print address 0 +0:1. add 1 to address 0 |1:0. Go to the second line and the first character
An additional note for jumps:
- the command > checks two memory addresses and if the first is bigger it stores 1 in the third memory address otherwise it stores 0
Example:
^0:1. ^1:2. >1:0:2. @2. This should print 1 as the result from the previous command is 1 since 2 is greater than 1 and 2 is stored in address 1 and 1 is stored in address 0
Examples
Cat Program
;0.@0.'1:\n.@1.|0:0.
Hello World
'0:Hello World.@0.
Truth Machine
'0:Enter Number/; .'1:\n.^2:1.@0.;0.@0.@1.?0:36:0:2.
99 Bottles of beer on the wall
^0:99.^5:0.'1: Bottles of beer on the wall\n.'2: Bottles of beer\n.'3:Take one down pass it around\n.>0:5:6.'4:.=4:0.=4:1.@4.'4:.=4:0.=4:2.@4.@3.-0:1.'4:.=4:0.=4:1.@4.<500.?1:0:6:0.|0:100.
Input mod 2
'3:Input/; .@3.;0.&0.^1:0.+>1:0./1:2.*1:2.->0:1.@0._ Note that strings cant contain the argument separator so /; is used and replaced by the interpreter