Compiler for a Set Theory language, written in C#
ANTLR4: The grammar of this project is defined inside the SetTheory.g4
Assigns a set
to a variable
, or a variable
to a variable
.
a = [6,2]
→ assign the set[6,2]
toa
c = a
→ assigns the value of the variablea
to the variablec
(a
must be defined)
Prints the value of a variable
.
a = [2]
show a
→ prints[2]
Creates a set
based on three parameter:
from
: The number where the set will start fromto
: The number where the set will end - thejump
jump
: Steps
b = set(10,50,2)
→ create aset
from 10 to 50 with a jump of 2:[10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48]
Returns the max
value from a set
.
a = [1,9]
max a
→ returns[9]
Returns the min
value from a set
.
a = [1,9]
min a
→ returns[1]
Returns the avg
value from a set
.
a = [1,9]
avg a
→ returns[5]
Returns the intersection
between two sets
.
a = [1,9]
b = [2,9]
int a,b
→ returns[9]
Returns the union
between two sets
.
a = [1,9]
b = [2,9]
uni a,b
→ returns[1,9,2]
Removes a value from a set
, based on the following parameters:
variable
: The variable containing theset
index
: The index number of theset
that will be removed. Consider theset
as an array where the index0
is the first element
a = [1,5,9]
ext a,0
→ removes the first element from theset
, so, the result will be theset
without that element →[5,9]
Returns the length
(number of elements) of a set
.
a = [1,2,3]
len a
→ returns[3]
Adds
an element to a set
.
a = [1,9]
add a,4
→ returns[1,9,4]
Deletes
an element from a set
.
a = [1,9]
del a,9
→ returns[1]
Inside the SetTheoryCompiler Project, there is a Program.cs file that contains many examples of how the different operations work.