This project is read-only.

Sumary

CS-MIC follows a few basic rules when interpreting user input, but should prove to be fairly straightforward for most developers. While CS-MIC tries to ensure that the order of operations as far as it knows them (parentheses – powers, multiplication, division – addition, subtraction), there may be instances where formatting fails. If this should be noticed, please report it.

Expression Parsing

Operands

  • +
    • Addition
  • -
    • Subtraction
  • *
    • Multiplication
  • /
    • Division
  • ^
    • Raise to a power
  • %
    • Mod

Tokens

  • ::
    • Assign a numeric value to a variable.
  • :=
    • Assign an equation to a variable.
  • ->
    • Assigns a comma delimited array of numbers to an array variable.

Comparison

  • ==
    • Returns ‘True’ if two values are equal to each other.
  • >
    • Returns ‘True’ if a value is greater than another value.
  • <
    • Returns ‘True’ if a value is less than another value.
  • >=
    • Returns ‘True’ if a value is greater than or equal to another value.
  • <=
    • Returns ‘True’ if a value is greater than or equal to another value.

Base Conversion

  • Decimal
    • All numbers are interpreted as decimal by default.
  • Binary
    • Binary numbers are succeeded by a B, non case sensative.
  • Hexadecimal
    • Hexadecimal numbers are preceded by 0x, non case sensative.

Example Input and Output


Input Output
5 + 5 10
5 * 2 10
1 + 2 * 3 7
(1 + 2) * 3 9
5 / 2 2.5
5 / 0 Attempted to divide by zero.
2 ^ 32 4294967296
x :: 4 4
x :: 6 + 4 10
y := 2^x (2^x)
y (with previous input) 1024
x :: 64, y (with previous input) 18446744073709600000
a -> [0,10,20,30] 0,10,20,30
a[2] 20
1 == 1 True
1 < 2 True
1 > 0 True
5 <= 10 True
5 >= 2 True
9 % 3 0
11 % 3 2
1100b 12
0xFF 255


Scripting

Rules

  1. Any valid expression can be computed.
  2. All computation counts towards the script’s history. This means that once a variable is set inside a script, the variable will remain set until execution of the script is complete.
  3. Only one command can be executed per line. No token is required to end the command.
  4. Every code block must be opened and closed with a bracket ( { } ). The only exception is the main code block.

Loops

  • while
    • Executes a code block as long as a given condition evaluates to true.
  • for
    • After executing an initial condition, a code block is executed while a condition is met. A final statement is executed at the end of each iteration.

while(bool expression)
{
CODE BLOCK
}

for(* expression, bool condition, * expression)
{
CODE BLOCK
}

Conditionals

  • if
    • Executes a code block if a given condition evaluates to true. An optional else block can follow the if block for execution if the statement evaluates as false.

if(bool expression)
{
CODE BLOCK
}
else
{
CODE BLOCK
}

Functions

  • echo
    • Displays the output from the proceeding expression.
  • say
    • Displays a string.
  • display
    • Combines strings and expressions to a single line in the output stack.
  • function
    • Creates a new function with a given name, and any number of expected arguments.
echo: expression

say: ”string”

display: ”string”, 12 * 2, ”string”, sin(12)

function(newFunction, anyArgumentName)
{
sin(anyArgumentName) + cos(anyArgumentName)
}

Comments

Block Tokens

Starting token: /*
Ending token: */
Any line falling between block comment tokens will be ignored by the macro builder at execution time.

Line Tokens

//
Any line starting with the line token will be ignored by the macro builder at execution time.

Example Script

Input

say: ”Fibonacci Sequence”
temp :: 1
y :: 1
echo: y
for(x :: 1, x < 11, x :: temp + y)
{
echo: x
temp :: y
y :: x
}
x :: 1
say: ”While Loop”
while(x < 10)
{
if(x == 5)
{
display: ”The condition ‘x == 5′ has been met. x = “, x, ”.”
}
else
{
echo: sin(x)
}
x :: x + 1
}

Output

Fibonacci Sequence
1
1
2
3
5
8
13
21
34
55
89
While Loop
0.841470984807897
0.909297426825682
0.141120008059867
-0.756802495307928
The condition ‘x == 5′ has been met. x = 5.
-0.279415498198926
0.656986598718789
0.989358246623382
0.412118485241757

Last edited Oct 20, 2013 at 5:42 AM by wagesj45, version 1