R++

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.

R++ is an esoteric programming language created by User:Cleverxia.

Syntax

defined in BNF: (... is any string)

code := statement | statement code
ichar := "A"|"B"|"C"|"D"|"E"|"F"|"G"|"H"|"I"|"J"|"K"|"L"|"M"|"N"|"O"|"P"|"Q"|"R"|"S"|"T"|"U"|"V"|"W"|"X"|"Y"|"Z"|"_"|"a"|"b"|"c"|"d"|"e"|"f"|"g"|"h"|"i"|"j"|"k"|"l"|"m"|"n"|"o"|"p"|"q"|"r"|"s"|"t"|"u"|"v"|"w"|"x"|"y"|"z"|"!"|"$"|"#"
nchar := "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
identifier := nchar | identifier (ichar | nchar)
label_ := ";" identifier
var := "@" identifier
string := "'" ... "'"
statement := (definition | assignment | label | goto | if | input | output | while) ":"
if := "if " expression " then " ("{" code "}" | " do " statement)
while := "while " expression ("{" code "}" | " do " statement)
goto := "goto " label_
label := "define " label_
voalist := (var|assignment) | (var|assignment) "," voalist
definition := "define" voalist
assignment := var "=" expression
op := "<"|">"|"/"|"+"
expression := string | var | "(" expression ")" | expression op expression | "%" expression
input := "input " var
output := "output " expression|"print " expression

the '<' operator: a < b means "1" if a is lexical...ic smaller than b else "0".

the '%' operator: %a means "1" if a is an empty string else "".

the '/' operator: a / b means:

  • split a with seperator "&". call the resulting array c.
  • replace all c[0]'s in b with c[1] and return it.

the '+' operator: a + b means a concated with b.

the '>' operator: a > b take a splitted by b and returns the last result.

if and while loops/dos the block inside if/while the provided string isn't empty.

Examples

Hello, World!

print 'Hello, World!':

Cat

define @a:while '1'{input @1:print @1:}:

Truth-machine

define @a,@b:input @a:@b=@a:
while @b>'0'{print @a:}:print @a: