- Cli
- Basic Concepts
- Opcodes
- Params
- Aliases
- Overview
Robson's cli
The robson cli gives you a lot of commands to helps you create and run your robson projects
Running .rbsn
Compiling and running .robson
For compiling a .robson you specify a .robson file and add the "compile" flag
For running is the same except we use the "run" flag
All the .rbsn files are placed in the out folder inside your project.
The general use for robson's cli is:
--flags
- --version, display the robson installed version
- --generate, input a string and convert it robson's push
- --chars, press a key to get its ascii value
- --boxes, a litlle showcase of box drawing characters
file flags
- compile, will compile a .robson into a .rbsn
- run, will compile then run a .robson
- time, will show the run time of a .rbsn
- print, will print the commands inside a .rbsn
Basic Concepts
Before continue to learn robson, first you need to understand concepts of memory and stack, if you're ok with that skip that section.
Stack
The stack is basically an list of data that you access the top and adds to the top.<br> Exmaple:
We have a 65 on the stack.
If we push 10 to the stack we will have:
We only can add to the top of the stack, not the bottom nor the middle.
If we pop that stack we will remove the top of it getting back only the 65.
Like adding, you can just remove the top of the stack.
Memory
The memory consists of data indexed by numbers like an vector/array
Example:
Unlike the stack, the memory you can read, add, and remove everything (within the scope of your application)
So we can set the address 2 with the number 69, the memory will be as following
If you set more than one time the same address you will replace its value
There's no way that you can remove entirely the value of the memory, so you set it to 0 in order to remove it
The opcodes in robson are the numbers wich represents functions within the language, opcodes are represented as the number of robson in one line.
List of opcodes
- Operations like sum and subtraction
- If lower jump
- Push to stack
- If equal jump
- Verify stack
- User input
- Print ascci
- Print number
- Jump
- Set to memory
- Pop Stack
- Get string buffer
- Time commands
- Flush
- Terminal Commands
- Random float
Every opcode has a different number of params varying between 0 and 3
Params are data that you pass for commands, they can originate for bascially anywhere, from the memory, from the stack or more commonly, hardcoded
comeu 94 \n
In the example above, the "comeu" keyword is saying that the value is hardcoded number, for representing floating points ou signed ints, use a f{number} and i{number}, respectively
Now lets dive in a more complex code
comeu f12.6 \n
robson robson robson robson robson robson robson robson robson robson \n
comeu 0 \n
robson \n
comeu 0 \n
fudeu 0 \n
comeu f1.1 \n
In this example we are settings the value 12.6 into the address 0, then adding the value 1.1 and value from address 0, for the finale printing it to the screen
Now let's go through this bit by bit
In the first command we're adding 12.6 to the stack
In the seccond we're setting setting the top of the stack to the address 0
For the third, we see a "fudeu", fudeu basically is equivalent of the value from the address specified, in that case address 0. In this command we're adding the two last parameters and pushing to stack the result
The last command just print the number to the screen
Worth mention the "chupou" keyword, it is used when you wanna use the stack top as a param, it is only valid as "chupou 0"
Aliases
A lot of times, you wanna jump around in your program, and using the lines as an argument may not be such an effective method, so robson has aliases, aliases are names that you choose for the program to remember certain parts of your program instead of hardcoding its location
Example:
comeu 69 \n
robson robson robson robson robson robson robson robson robson \n
lambeu :alias \n
robson robson robson robson robson robson robson \n
alias: \n
robson robson robson robson robson robson robson robson \n
In this example in the seccond command, we jump to the position of the alias, completely skiping the third command. this could easly be solved without an alias with
comeu 69 \n
robson robson robson robson robson robson robson robson robson \n
comeu 4 \n
robson robson robson robson robson robson robson \n
robson robson robson robson robson robson robson robson \n
On the surface this seems better code, as it has less lines, but this code is not maintainable, couse if you for some reason add more lines of code before that, the code is gonna be on undefined behavior since we dont know what could be at command 6
This is the end of the guide on Robson, if you wanna an overview of the language commands continue
Overview
Operations
Has three params, the first is the operation and the other two are the values, exmaples:
Sum:
robson \n
comeu 0 \n
comeu 2 \n
comeu 4 \nSubtraction:
robson \n
comeu 1 \n
comeu 5 \n
comeu 4 \nMultiplication:
robson \n
comeu 2 \n
comeu 2 \n
comeu 3 \nDivision:
robson \n
comeu 3 \n
comeu 8 \n
comeu 2 \nIf lower jump
Has three params, if the first param is lower than the seccond jump to third param
robson robson \n
comeu 1 \n
comeu 4 \n
lambeu :somealias \nPush to the stack
Has one parameter, push its param to the stack, it has a handy syntax simplification on multiple push, example:
robson robson robson \n
comeu 10 \n
robson robson robson \n
comeu 69 \nCan be written as:
robson robson robson \n
comeu 10 \n
comeu 69 \nIf equal
Has three params, is the first param is equal to the third param, jump to third param, example:
robson robson robson robson \n
comeu 10 \n
comeu 10 \n
lambeu :somealias \nVerify stack and jump
Has one parameter, if the stack is empty jump to the param, example:
robson robson robson robson robson \n
lambeu :somealias \nInput user
Has three parameters, first the location to store the data, seccond its type (0 text, 1 usingned integer, 2 signed integer, 3 float ), third the limit that can be supplied for the user
robson robson robson robson robson robson \n
comeu 0 \n
comeu 0 \n
comeu 100 \nPrint ASCII
Has no parameter, print the top of the stack as ascii, example:
robson robson robson \n
comeu 65 \n
robson robson robson robson robson robson robson \nPrint number
Has no parameter, print the top of the stack as a number, example:
robson robson robson \n
comeu 65 \n
robson robson robson robson robson robson robson robson \nJump
Has one parameter, jump to the command at first param position, example:
robson robson robson robson robson robson robson robson robson robson \n
lambeu :somealias \nSet to memory
Has one parameter, set the top of the stack to the address of its parameter
robson robson robson \n
comeu 69 \n
robson robson robson robson robson robson robson robson robson robson \n
comeu 0 \nPop stack
Has no parameter, as it says, it pop the stack WOW
robson robson robson robson robson robson robson robson robson robson robson \nLoad string
Has one parameter, read the memory values from address of parameter until '\0', and adds it to stack in reverse
robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 0 \nTime
Wraps some time functions supported by robson
count, Will set the global time to start counting from the moment this command is run, if you run again it resets
robson robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 0 \ninterval, Set the global interval based on the stack top, for the time it will use the two values on stack top and put its binary in this order, [first stack top, seccond stack top]
; Setting an inverval of 100ms \n
robson robson robson \n
comeu 100 \n
comeu 0 \n
robson robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 1 \ncmp_interval, Compare the interval with the global time, pushes to stack 0 if lower, 1 if equal and 2 if greater
robson robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 2 \nFlush
Will flush all pending to stdout
robson robson robson robson robson robson robson robson robson robson robson robson robson robson \nTerminal commands
The raw commands that robson supports
enter, Enable or disable the raw mode based on stack top, 0 to disable, 1 to enable
robson robson robson \n
comeu 1 \n
robson robson robson robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 0 \nclear, Will clear the terminal screen in one of two ways, based on stack top, if is 0, will purge the screen otherwise it will clear all
robson robson robson \n
comeu 1 \n
robson robson robson robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 1 \npoll, Will get the input of the user for the time specified on the stack top
robson robson robson \n
comeu 100 \n
comeu 0 \n
robson robson robson robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 2 \ncursor, Show or hide the cursor based on stack top
robson robson robson \n
comeu 0 \n
robson robson robson robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 3 \nmv_cursor, Will move the cursor to the coordinates on the two values of stack top, x, y respectively
robson robson robson \n
comeu 0 \n
comeu 1 \n
robson robson robson robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 4 \ncolor, Will set the color of the text that gets printed to the values of stack top, to reset the color, set the color to any value above 255.Table with color values
robson robson robson \n
comeu 120 \n
robson robson robson robson robson robson robson robson robson robson robson robson robson robson robson \n
comeu 5 \nRandom
Will push to stack a random float number between 0 and 1
robson robson robson robson robson robson robson robson robson robson robson robson robson robson robson \n