-
Notifications
You must be signed in to change notification settings - Fork 0
Data structuring & Syntax
A Piège code is intended to be read from start to finish, through each and every character. It’s important for an interpreter to keep track of character indices.
At any main character index, if a structure, a function, or an operator (collectively called “function” for now) is detected from that index to the index a distance equal to the length of that function away, a temporary character index is created to read the content of the function.
Certain functions allow setting the main character index to a specific location in the code or moving the index a certain distance away from those functions.
The program should end when the main character index reaches the end of the code, or when an end function is called.
There are two fundamental structures of any Piège code: an input-output instructor, and a math operator.
The input-output instructor tells the interpreter from which source to import data and to which destination to export. Usually, an input source is not necessary if the input values are hardcoded into the program. An output source, however, is required and can go to the interpreter itself or an external file. This instructor must be called first using the syntax io{ ... };.
The math operator handles all mathematical operations. It is called using the syntax op{ ... }; and can be called multiple times.
Curly braces are reserved for the input-output instructor and math operator.
Square brackets are reserved for every other function that is not the IO instructor and the math operator. You cannot nest functions using these brackets inside each other.
Semicolons denote the end of a function or a series of related data. Without it, the interpreter may continue to read values of other functions or data series while not closing the previous one.
Parentheses groups mathematical entities inside a math operation. Depending on the functions using square brackets, you may or may not be able to nest functions with parentheses.
Commas denote a separation between mathematical entities in a multi-value math operation.
Call for the input-output instructor.
Call for input at directory. Not required if input values are hardcoded.
-
directoryis required, in double quotes, can be relative
input["constant.txt"];Input files have to follow a specific syntax for each line:
variable=value
pi = 3.1415926
e = 2.7182818
Call for output of type type. Depending on this type, directory may or may not be called.
-
typeis required, can be:-
interpreterto output value to interpreter -
directoryto output to specified file
-
-
directoryis optional, in double quotes, can be relative
output[interpreter];
output[directory; "output.txt"];Call for the math operator.
Calculate the operation inside the brackets. This is used for basic calculation and assignment, and the output is a single value assigned to a new or preexisting variable.
-
operationis required. The following syntaxes can be used inside:- Data types:
-
float: number -
string: variable (doesn't include0123456789.-)
-
- Arithmetic operators:
-
sum(val1, val2, ...): sum -
dif(val1, val2): difference (non-negative) -
sub(val1, val2, ...): sum of val[1] and -val[>1] -
pro(val1, val2, ...): product -
rat(val1, val2): ratio -
quo(val1, val2, ...): product of val[1] and 1/val[>1] -
pow(val1, val2): power -
exp(val1): exponential -
mod(val1, val2): modulo -
fact(value): factorial -
abs(value): absolute value -
sign(value): sign of value (+/–/0) -
log(base, value): logarithm -
ln(value): natural logarithm -
sqrt(value): square root -
root(root, value): any nth root
-
- Rounding operators:
-
floor(value): floor/ round down -
ceil(value): ceiling/ round up -
round(value, decimal): round to the nth decimal place (can be negative) -
floorRat(val1, val2): floor division -
ceilRat(val1, val2): ceiling division
-
- Trigonometric operators (radian):
-
sin(value): sine -
cos(value): cosine -
tan(value): tangent -
cot(value): cotangent -
sec(value): secant -
csc(value): cosecant -
asin(value): arcsine/ inverse of sine -
acos(value): arccosine/ inverse of cosine -
atan(value): arctangent/ inverse of tangent -
acot(value): arccotangent/ inverse of cotangent -
asec(value): arcsecant/ inverse of secant -
acsc(value): arccosecant/ inverse of cosecant
-
- Hyperbolic operators (radian):
-
sinh(value): hyperbolic sine -
cosh(value): hyperbolic cosine -
tanh(value): hyperbolic tangent -
coth(value): hyperbolic cotangent -
sech(value): hyperbolic secant -
csch(value): hyperbolic cosecant -
asinh(value): inverse of hyperbolic sine -
acosh(value): inverse of hyperbolic cosine -
atanh(value): inverse of hyperbolic tangent -
acoth(value): inverse of hyperbolic cotangent -
asech(value): inverse of hyperbolic secant -
acsch(value): inverse of hyperbolic cosecant
-
- Matrix operators:
-
detMtrx(rows, cols, val1, val2, ...): determinant of matrixrowsxcols
-
- Vector operators:
-
lenVect(dim, val1, val2, ...): vector length -
dotVect(dim, vect1.val1, vect1.val2, ..., vect2.val1, vect2.val2, ...): dot product of two vectors
-
- Randomiser operators (based on fractions of a second since the epoch):
-
rand(val1, val2): return a real number between two values -
randInt(val1, val2): return an integer between two values
-
- Data types:
-
outputis required. Enter a variable name to assign output to.
Input values for math operators don’t need to be strictly numerical values. They can be variables or math operators.
do[mod(pro(sum(9, 10), fact(2)), 4); a];
# ((9 + 10) * 2!) % 4 -> aIf no math operator is used and only a single value or variable name takes place, the function is treated as an assign function.
do[4; a]; # 4 -> a
do[m; n]; # m -> nSolve for unknowns inside the brackets. The output can be multiple values assigned to multiple variables.
-
typeis required. The following syntaxes can be used inside:- One unknown:
-
constant: x = constant -
linear: ax + b = 0 -
quadratic: ax2 + bx + c = 0 -
cubic: ax3 + bx2 + cx + d = 0 -
ratioNum: a/b = x/d -
ratioDenom: a/b = c/x
-
- Two unknowns:
-
linearSys2: ax + by = c, dx + ey = f
-
- Three unknowns:
-
linearSys3: ax + by + cz = d, ex + fy + gz = h, ix + jy + kz = l
-
- One unknown:
-
val1, val2, ...are required. Can be values or variables. -
var1, var2, ...are required. Enter one or more variable names to assign output values to.
In the case that an operation returns less output values than input variables, this function will only use one input variable per solution it can find, and ignore the rest.
solve[quadratic; 1, 2, 1; x1, x2];
# x^2 + 2x + 1 = 0 -> 1 solution (-1)
# only x1 will be assigned the value -1, x2 will be skippedReturn a numerical value or the value of an assigned variable to the selected output destination.
Return format on output: variable = value
-
variableis required. Enter an assigned variable name to return to output.
Print a string or the value of an assigned variable to the selected output.
-
obj1, obj2, ...are required. The following parameters can be used inside:- variable : reference without quotes
- strings : put in double quotes
Delete variable along with its value.
-
variableis required. Enter an assigned variable name to remove from memory.
Get the starting character index of the next function and store it as variable.
-
variableis required. Enter any variable name to assign output to.
Set interpreter's cursor to a specific character index or line at index in the code if condition is True.
-
typeis required, can be:-
charfor individual characters -
linefor line of code
-
-
indexis required, is an integer -
conditionis required.setCursor[]executes whenconditionis True, can be:- Comparison operators:
- `less(val1, val2, ...) : val1 < val2 < ... → True
-
more(val1, val2, ...): val1 > val2 > ... → True -
equal(val1, val2, ...): val1 = val2 = ... → True -
notless(val1, val2, ...): val1 ≥ val2 ≥ ... → True -
notmore(val1, val2, ...): val1 ≤ val2 ≤ ... → True -
notequal(val1, val2, ...): val1 ≠ val2 ≠ ... → True
- Comparison operators:
setCursor[charIndex; 100; less(i, 5)] # set cursor at character index 100 if i < 5
setCursor[line; 8; notequal(i, j, 3)] # set cursor at line 8 if i != j and j != 3When using
charIndex, to avoid index shifting, usegetIndex[].
getIndex[index1];
do[sum(i, 1); i];
setCursor[charIndex; index1; less(i, 5)]Move interpreter's cursor back or forth a number of character indices or lines in the code in relation to the start of the moveCursor[] function if condition is True.
-
typeis required, can be:-
charfor individual characters -
linefor line of code
-
-
amountis required, is an integer. Positive value to move forwards, negative value to move backwards -
conditionis required.moveCursor[]executes whenconditionis True. Can be one of 6 comparison operators
Ignore part of the code from index1 to index2.
-
index1is required, is an integer, must be in range 0 to end of code -
index2is required, is an integer, must be in range index1 to end of code
Abruptly stop the program at the current character index.
The wiki references version 1.2 of the Piège programming language.
Latest version of Piège: v1.2 (09 January, 2026)