rao

From Esolang
Jump to navigation Jump to search

rao is a weird programming language that compiles to Python. It mainly uses the keyword "rao" with symbols but also allows other named functions as external library methods. There are no spaces within a command and all commands are separated by a newline character. rao currently only compiles to Python 3.x. The program file is passed to the parser written in Python that outputs a Python version of the program and then executes it.

Keywords

These are the main keywords.

Code Comment
rao:) [version] All rao programs begin with this command.
rao? Comment Begins a comment
rao# [variable] Prints the value of the variable.
rao$ rao$ precedes every variable name.
rao@ [var] Tells the parser that the following combination of commas, periods, and exclamation marks need to be converted to a char value.
rao" Translates to quotation marks.
rao= Translates to equal sign.
rao~ [var] Tells the parser that the following combination of commas, periods, and exclamation marks need to be converted to numerical value.
rao+ Translates to + sign.
rao- Translates to - sign.
rao* Translates to * sign.
rao/ Translates to / sign
[var] rao^ [var2] Raises [var] to the power [var2].
raoo All commands that follow this one are to be indented right once.
raooo Mark the end of indented code.
rao\ [name] Translates to the def command in Python: beginning of a function definition.
rao( Translates to (.
rao) Translates to ).
rao! Translates to !.
rao& [expression] Defines the beginning of a while loop.
rao: [expression] Defines an if statement.
rao:: Defines an else statement.
rao::: [expression] Defines an else if statement.
rao>> Beginning of native code. Commands after this code are to by only to be converted into readable strings and are not to be evaluated as rao code.
rao<< End of native code section.
rao:( End of program.

ASCII Characterization

All code, including literal strings and numbers, is a combination of 'rao' and generic symbols. To specify a character, the decimal value of that character in the ASCII table is coded instead. A direct association is created between this ordinal value and three symbols, punctuation mark (!), comma (,), and period (.). The punctuation mark denotes the hundredth place of the decimal value, the comma denotes the tens place, and the period denotes the units place.

As an example, the letter s with ASCII ordinal value 115 will be converted into !,...... Combining that with the character command in rao gives rao@!,..... which when parsed, gives back the letter s. This way, characters can be construed together to form variable and function names, literal string values, and numbers.

To distinguish between characters and numbers, numerical values are prefixed with rao~. So the number 6 with ASCII value 54 becomes rao~rao@,,,,,.....

For defining a variable name, the character combination is prefixed with rao$. So v3 = 4 becomes rao$rao@!,........rao@,,,,,.rao=rao~rao@,,,,,... This notion of adding prefixes to character combinations allows for easier recognition of variable and types in code.

Functions

The rao\ command translates to the def command in Python. To define a function in rao, the rao\ command is followed by a function name that is constructed the same way as a variable name. Then on the same line, parameters can be passed within "rao(" and "rao)", separated by "rao,".

For example, a sum function that takes two parameters, a and b, and prints their sum, is defined as:

rao\rao$rao@!,.....rao@!,.......rao@!.........rao(rao$rao@,,,,,,,,,.......rao,rao$rao@,,,,,,,,,........rao)
raoo
rao#rao$rao@,,,,,,,,,.......rao+rao$rao@,,,,,,,,,........
raooo

Which becomes:

def sum(a,b):
	print(a+b)

The raoo and raooo commands specify the range for commands that need to be indented when generating the Python version of the program. The defined function can then be invoked by calling its name and passing parameters, such as rao$rao@!,.....rao@!,.......rao@!.........rao(rao~rao@,,,,,rao,rao~rao@,,,,,.rao) or sum(1,2)

Examples

Hello World

This program generates an output.py file and executes it, which prints "Hello World" to the standard output.

rao:)
rao#rao"rao@,,,,,,,..rao@!.rao@!........rao@!........rao@!,.rao@,,,..rao@,,,,,,,,.......rao@!,.rao@!,....rao@!........rao@!rao"
rao:(

The output.py file looks like this:

print("Hello World")

External resources