-
Notifications
You must be signed in to change notification settings - Fork 0
Coding in BCL
The Basic Cythan Language (BCL) is a way to program in Cythan easier. Please not that this programming language doesnt not add code from what you write. Every code written in BCL will be compiled into pure Cythan code.
This programming language does not have pre-made function. It only give you tools to simplified remembering position.
BCL is composed of a sequence of element splitted by the ;
character (can be configurable throt the compiler configure
command).
A element can either be some cythan code like 5,-9
or a BCL functionnality.
Compiler isn't affected by linebreak or space. You can put space everywhere, whitout constraint.
Variable definition is a way of remembering a value and/or modifying multiple value at the same time.
Function definition is a way to copy/paste code with small modifications.
Note that you can't interact with defined value. This is because, -once again- variable isn't compiled. It is just a way to remembering value/code easier. It will not be in the final code.
You define a varibale by using the equal sign. variable=5;
is a valid variable creation.
You define a function by using the equal sign and a {
after it. function={3,8;9,7}
is a valid function creation. You should not place a ;
at the end of a function definition. If so, the returning error will be unexpected EOF while parsing (<string>, line 0)
You can also specified argument for a function: foo(arg1,arg2,arg3)={9,arg1;arg2,-1;arg3,arg3}
is a valid function creation.
A great tool in BCL is the ability to get a line without counting in whitch line you are. For this, I made the ~
and the :
tool.
:
is called a marker. It allow you to define a variable whitch will not countain a specific value, but the instruction number where the marker is define. If we put Hello:-1,8
as the 9th instruction, the variable Hello will be equal to 9
.
~
is the variable name for the actual position. If we put ~,-9
as the 15th instruction, once compiled it will get 15,-9
A great tool with BCL is the ability to do math before compile. For exemple, if you want to acces 3 instruction after the actual one, you can do using ~+3
.
The supported instruction are all python basic suported instructions (we eval the integer then int it): *, +, -, /, %(modulo), // (euclidian division).
There are tools to get your code more accesible to everyone. Commentatry is a great help, try commenting at your best your code !
You define commentary by using '#
' before and after the text. This will be ignore by the compiler and allow you to comment your code.
# A OR logic door. #
# Putting the pointer at the Start variable position (define after) #
Start,1;
# Definition of the OR logic function #
OR(bit1,bit2) = {
# Reseting use negative value #
-1,-2;
-1,-4;
~+10,~+6;
~+9,~+6;
# The actual code #
~+11,1;
~+8,-3;
-2,~+3;
-1,-2;
-3,~+2;
# The test. If the pointer pass both, then the third instruction will be executed. #
~+2,~+2;
~+1,~+1;
~+5,0;
# Data needed by the logic door #
~-1,~-1;
bit1,bit2;
0,~+1;
~+3,1; # Reussi #
~+1,1 # Rate #
}
# The 2 bytse we test #
PremierBit = -1;
SecondBit = -1;
# We make a OR use. You can put multiple to make a logic circuit. #
Start:OR(PremierBit, SecondBit);
100,-1; # We finish by 100 if the answer is 0 #
999,-1; # We finish by 999 if the answer is 1 #
For more exemple, see the Exemple page of the wiki.