Skip to content

Frazi1/SharpCompiler

Repository files navigation

SharpCompiler

Simple C# parser and compiler developed for university classes.

Overview

  • Custom ANTLR grammar is used to parse C# (only subset of features, not actual C#) and generate a syntax tree.
  • ANTLR syntax tree is converted into an Abstract Syntax Tree, semantic analysis is executed
  • If semantic analysis passed, bytecode is generated for the target backend platform
    • IL for .NET (using in-built .NET's IL generator)
    • Java bytecode for Java (using Jasmin - Java assembler)

Supported features

  1. Static classes, static fields and static methods
  2. For, while, if
  3. int, bool, char and arrays.

See Input.cs example file to find examples and supported features. For instance, you can implement a quick-sort alghoritm using this compiler.

Usage example

  1. Checkout latest release: https://github.com/Frazi1/SharpCompiler/releases
  2. Create a .cs file with program source code
  3. NJC.exe <fileName>.cs --target=net //To generate a native Windows executable that runs under .NET
    NJC.exe <fileName>.cs --target=jasmin //To generate a Java bytecode file that runs under JVM
    

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages