SmoothBrain is a programing language aiming to be easy to use, even when your brain don't want to work. This snapshot contain all the syntax of the language :

.example: { print("hello!") def_state(10) } .example_2: { print("world!") number(5) pop() } .main! { >example;10;example_2; example() check* }

output: hello! world!

SmoothBrain is a concatenative programming language. To program in it, you need to know that you have access to two stacks, a magical number defining the current state and a bunch of function who allow you to input,transform and output data. The list of the function can be found in the list of core function section. I will now explain the syntax briefly, if you need more explanation about why things are like they are, refer to the detailled section below. The convention of calling a function is standard :

name_of_the_function(optional_argument) Example: print("hello!"), number(5),pop()

No function in SmoothBrain take more than 1 argument. SmoothBrain allow you to define custom function with the following syntax :

.example:{...}

Then you will be able to call "example" by following the previous convention : example() To define the entry point of your program, you replace the ":" with "!"

.main!{...}

The last two syntax elements are related to control flow. if you check the output of the above example, you see that "world!" is here, even when the only explicitly called function is "example" That's because of the following :

>example;10;example_2;

It should be read as : If the last function called is "example" and that the current state is 10 then call function "example_2". By itself, the syntax just define the rule. Check() is a function that will trigger the rule if the conditions are satisfy Check* is a special syntax that say : "check rule until you can't anymore" So in this case, after calling "example_2" as no rule is defined saying something should be done if "example_2" is called, the check stop and the program continue, as nothing else is called, the program end. Please note the * only work with check. With this syntax explaination and by checking the list of the function, you should be able to program with SmoothBrain Currently, SmoothBrain do not have a specific compiler, the code is transcribe to C and it expected that you use a C compiler to produce the executable. Example of a command :

sm input.sm output.c && cc output.c -o output

sm is a executable compiled from sm.c

Detail about stacks and the overall structures assumed by the language

As already mentioned, SmoothBrain is stack based. It provide you 2 stacks, Stack_1 and Stack_2, who are just two arrays with defined size under the hood. The fact these are array is important as most function will not just refer to the top element, but will refer to the "actual position" you are pointing in the stack. If you are just using the typical stack function, this will be the top of the stack. But if you start using iterate(n), then you can change where you point to. You can think of that as changing where the top of the stack is. The main goal of letting this type of operation possible is to use one of the stack as a tape. With that, the second main element that SmoothBrain will provide and will assume you use is a structure that keep track of the rule you define. If you look at the source code after generating a file, you will see that it's not a "struct". You will just find a bunch of array and constant to keep track of how many element are in these arrays. The whole stuff is a little bit experimental, I'm not so sure about how to store these informations and what would be the best way to do it. So I keep it simple to allow me to iterate in the question when I will want to dig this specific point. So the consequence is that I don't have any specific way to find if one of the rule should be trigger, check() will just iterate the arrays containing the info and see if one match the current situation. The last thing is the fact that you have a magic number that represent the state. That's litteraly just a int name "current_state". It's deeply linked to how the language do control flow. I feel it's nice to have a number that you can use to say " we are in this situation, and in this situation we can do this set of action and nothing else " and a really want to explore this and break from the usual for/while loops, if/else and other switch.

Function list

This section describe function you can use in SmoothBrain Actual position = The position pointed to in the current stack used. next position = position just after the actual position previous position = position just before the actual position

function to interact with stack

number(n) => push the number n in the actual position, change the actual position to the next position pop() => reset the actual position, change the actual position to the previous position inc() => increase the actual position by 1 dup() => take the value of the actual position and push it in the next position. change the actual position to the next position push() => take the value from the actual position in Stack_1 and push it to Stack_2 back() => take the value from the actual position in Stack_2 and push it to Stack_1

function to interact with state

push_state => push the value in actual position and make it the value of the current state copy_state => the current state become egal to the value in actual position def_state(n) => the current state become n

function to interact with iterator

set_iterator(nth) => the actual position become the nth position in the stack. iterate(n) = > change the actual position by n get_iterator() => push the value of the actual position to Stack_2.

math

add() => add the actual position with the previous position sub() => sub the actual position with the previous position mul() => multiply the actual position by the previous position div() => divise previous position by the actual position iadd(n) => add the actual position with n isub(n) => sub the actual position with n imul(n) => mul the actual position by n idiv(n) => divide the actual position by n

logic

equal() => push 1 if the Actual position is egal to the previous position. If not, push 0

io function

print("...") => output the string between the "" to standard output. Automatically add a newline. input() => prompt user input for keyboard input and put the value in the stack. print_stack() => print the value in the stack from 0 to 254 print_stack_ascii => print the value in the stack from 0 to 254, but assume they are ascii character and print them as such.

Detail about the syntax

This section is here to explain my mind about why the syntax of the language look like this. One of the main reason for the whole shape of the language is that I was looking for a sort of simplicity at every level. I'm looking for something that is simple to write, simple to read, simple to remember, simple to implement. The last point is probably one of the most important. I don't like the idea of thinking of a programing language and not be able to write stuff in it. But I also don't like the idea of having to program (or use) a lexer/parser. More precisily, I don't like the idea of being obligated to do that to use my language. The way of dodging this issue is to abuse the fact that a lot of peoples already did the work for you, for a lot of language. So if I'm able to take my SmoothBrain and transform it to one of these language, I also got access to their interpreter/compiler and so I can use that as a starting point. As a linux user ( not arch btw ), I know i will always have a C compiler being here with me without me even asking for it, so it was a good starting point. From that, it mean I needed a syntax that I could easily transform to C, without having to write a proper parser. To define a function, in C you write : [type] [name] (argument...){body} What I'm defining in the language is not proper new function, it's just function that will be filled with other function. So I don't care about the type of these function. I also don't care about the argument, as they should not have argument. From that, I just replace the multiple type by a simple "." and the whole (argument...) by a simple ":" Giving you the actual syntax : .name : {body} sandwiching the name between "." and ":" also allow me to keep track of the name function, which i need for the control flow. When needed, I can just replace the "." by "void" and the ":" by () and I got back a perfectly fine C function. For main, I just put "!" as I thought it was funny to be able to write ".here!" to signal the entry point of the program was here. Keeping the convention of calling your function by using () allow me for less work in the processes of transcription. I just paste the call and add ";" after every ")" and it become a C function call. the syntax for the rule is the only "extravagant" syntax I allow myself to handle. But even that was not that hard as soon as you know that the following : >function;0;function_2; Will be transform to : condition(function,0,function_2); So here ">" is replace by "condition(" then the first ";" is replace by ",", the second too, and the last is replace by ");" and tada you have just another function call in C. the * is even more stupid as it's just ignore and put a pre defined while loop in place of it and the previous characters. With all that, it appear that you can transform a SmoothBrain program to C with just pasting into the C file all the definition of the function coming with the program and then iterate on all the character with a switch who will describe what character need to be replace by with. It's really simple, so let's say I'm happy.