GitHunt
LU

LuisFernandoBenatto/Simple-Compiler

Implementation: A simple expression interpreter

Simple Interpreter

license
CSharp

Implementation: A simple expression interpreter


Create New Project in

Install .NET on Windows

Create the app:
  $ dotnet new console

Run the application:

  $ dotnet run

Example

static void Main(string[] args)
{
  Lexer lexer = new Lexer("$x = 2 + 2 * 3; "
                        + "$y = 1 + 10 / 2; "
                        + "$z = $x + $y; "
                        + "print($z);");
  Parser parser = new Parser(lexer);
  parser.Prog();
}  

Input

$x = 2 + 2 * 3;
$y = 1 + 10 / 2;
$z = $x + $y;
print($z);
$c = 942 + 371 * 46; 
print($c);
print(314);

Output

14
18008
314

Reference 🤩

Code used with reference: wellingtondellamura/compiler-from-scratch

Languages

C#100.0%

Contributors

MIT License
Created July 29, 2021
Updated October 26, 2021