BetterCookie961 Interpreter written in c++
k
- move the pointer righti
- move the pointer leftK
- move the pointer right and copy the value of the left cookieI
- move the pointer left and copy the value of the right cookiec
- increment the current cookie valueC
- Adds 10 to current cookie valueo
- decrement the current cookie valueO
- decreases the current cookie value by 10L
- erase current cookie value9
- output the value of the current cookie (Outputs only chars)a
- debug(ASCII) output. Output the current cookie valuee
- replace the value of the current cookie with input6
- jump to the matching1
instruction if the current cookie value is zero1
- jump to the matching6
instruction if the current cookie value is not zero(
- IF construction starts)
- IF construction endsN
- Return to the initial cookien
- print current cookie value>
- Go to next line(in output)R
- Write a random value in the range 0-100 to a cookie{
- Beginning of an arithmetic expression}
- End of arithmetic expressionr
- Run file from user inputB[filename]
- Run fileS[milliseconds]
- Sleep functionM[WhereToMove(int)]
- Move current cookie value to another cookie-
- Stop executing programg
- output in which cookie we are locatedX[Offset(int)]
- Copy current cookie value to another cookie/* {your comment here} */
- CommentP
- Move to the cookie whose number corresponds to the value of the current cookie and transfer the number of the current cookie to the one to which we move (for example, in order to go back).J
- Move to the cookie whose number corresponds to the value of the current cookie. (without transferring the number of the current cookie to the one to which we move).
M[3]
- Moves the value of this cookie 3 steps to the right.M[-1]
- Moves the value of this cookie 1 step to the left.
IF construction operators:
>
- bigger<
- less=
- equal~
- not equal
-
IF always starts with an expression. (k > i ! cca)
-
Always after the expression comes !, after which the body is written. {k > i - expression} {! - delimiter} {cca - body}
-
IF has no variables, so numeric values are passed like this:
i
- left cookie valuek
- right cookie valuet
- current cookie value Example: (k > i ! cca) = {if (k > i): do cca}
ATTENTION! Before calling the IF, "create" all the cookies you need (move to them)! Example: cc(k > i ! cca) - ERROR, because right cookie does not exist. kkki(k > i ! cca) - SUCCESS, right and left cookies exist. More examples:
kkk(k > i ! cca)
- ERROR, right cookie does not exist.ki(k < i ! cca)
- ERROR, left cookie does not exist.
You can also write IF inside the BODY of another IF. Examples:
cckccckcccci(k > i ! kkcckccckcci(i > k ! cca))
- SUCCESS.cckccckcccci(k > i ! (i < k ! cca))
- SUCCESS.cckccckcccci(k > (i < k ! cca))
- ERROR, no body.
IF constructs ALWAYS have !, otherwise you will get an error.
Arithmetic expressions have 4 operators:
+
- addition-
- subtraction*
- multiplication%
- division
Numeric values are passed through:
k
- right cookie valuet
- current cookie valuei
- left cookie value
After executing an arithmetic expression, the result is written to the current cookie
Examples:
{t + k}
- current cookie value + right cookie value
{t - i}
- current cookie value - left cookie value
ATTENTION! The arithmetic expression only uses 2 values and 1 operator!
{t + k - i}
= {t + k}
{i * k - t + k}
= {i * k}
Program Examples:
ekei{t + k}n
- Calculates the sum of two numbers
ekekei{t + k}{t + i}n
- Calculates the sum of three numbers