ParaCL is a simple interpreter for the Parasyl programming language, whose syntax resembles C.
The interpreter reads a program from standard input and outputs the results to standard output.
-
All variables are of type
int. -
A program consists of a sequence of statements.
-
Supported control structures:
ifandelsewhile
-
Assignment and arithmetic expressions.
-
Postfix increment and decrement operators:
x++,x--. -
Input from keyboard:
x = ?;. -
Output to screen:
print x;. -
Comments:
- Single-line:
// comment - Multi-line:
/* comment */
- Single-line:
-
Operator precedence (from highest to lowest):
- Postfix increment/decrement:
++,-- - Unary minus:
- - Multiplication and division:
*,/ - Addition and subtraction:
+,- - Comparisons:
>,<,>=,<=,==,!=
- Postfix increment/decrement:
if (expression) {
// if body
} else
// else body (optional)while (expression) {
// loop body
}x = 1;
x = ?; // input from keyboard
x++;
x--;
print x;Variables are valid within the block delimited by { ... }.
Accessing a variable outside its scope causes an error.
{
y = 1;
}
print y; // Error: variable y is not definedUsing undeclared variables or accessing variables out of scope results in a detailed error message indicating the line and position.
To finish input in the terminal, press Ctrl + C
fst = 0;
snd = 1;
iters = ?;
while (iters-- > 0)
{
tmp = fst;
snd += tmp;
}
print snd;
y = 1;
x = ?;
while (((++x))++ > y)
{
print /* comment */ (y == x);
x -= 100;
}mkdir build && cd build
cmake ..
cmake --build .
ctest