My first attempt at building a compiler. With the help of Immo Landwerth's tutorial series on building a compiler
You can find the documentation here(WIP NOT HOSTED YET)
+
Addition-
Subtraction*
Multiplication/
Division(
and)
Parentheses&&
Logical AND||
Logical OR!
Logical NOT&
Bitwise AND|
Bitwise OR^
Bitwise XOR~
Bitwise NOT<<
Bitwise Left Shift>>
Bitwise Right Shift==
Equality!=
Inequality<
Less than<=
Less than or equal to>
Greater than>=
Greater than or equal to=
Assignment%
Modulus
var <identifier>(: <optional type>) = <value>
creates a mutable variablelet <identifier>(: <optional type>) = <value>
crates an immutable variable
(1 + 2) * 3
function <identifier>(<parameter 1>: <type>, ... <parameterN>: type) { ... }
{ ... }
if <condition> { ... } (optional) else { ... }
for <identifier> = <lowerBound> to <upperBound>
while <condition>
print(<expression>)
prints the expression to the consoleprintln(<expression>)
prints the expression to the console in a new lineinput()
reads a line from the consolerandom(<min>: int, <max>: int)
generates a random numbercos(<value>: double)
get the cosinus for the given valuesin(<value>: double)
get the sinus for the given valueacos(<value>: double)
get the arc cosinus for the given valuefloor(<value>: double)
get the floor pf the given value
string(<expression>)
converts the expression to a stringint(<expression>)
converts the expression to an integerbool(<expression>)
converts the expression to a booleanfloat(<expression>)
converts the expression to a floatdouble(<expression>)
converts the expression to a float
- String
var myString = "myString"
- Bool
var myBool = true
- Int
var myInt = 1
- Float
var myFloat = 0.2f
- Double
var myDouble = 0.2
#showTree
Shows parse tree#showProgram
Shows bound tree#cls
Clears the console#reset
Resets the current compilation
The following code
Generates the following diagram
- Install .NET >= 8.0
- Clone the project
git clone [email protected]:Lxdovic/rhino.git
- Go to the project directory
cd rhino
- Run the project
dotnet run --project ./rc/rc.csproj
To run tests, use the following commands
cd rhino/
dotnet test