Skip to content

Latest commit

 

History

History
65 lines (56 loc) · 1.57 KB

README.md

File metadata and controls

65 lines (56 loc) · 1.57 KB

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