Giter VIP home page Giter VIP logo

calang's Introduction

SonarCloud Bugs

calang

calang is a Simple Programming language which is compiled into Java. This language contains simple arithmetic operations..

Sample Code

calang

int a = 5;
int b = 10;
check(a > b) {
    a = 10;
    b = 5;
}otherwise{
    a = a - 1;
    b = b - 1;
}
show(a);

java

public class Main{
	public static void main(String... args){
		a = 5;
		b = 10;
		if(a > b){
			a = 10;
			b = 5;
		}else{
			a = a - 1;
			b = b - 1;
		}
                System.out.println(a);
	}
}

Features

  • Initialize variables
  • Assign values to variables
  • Arithmetic operations
    • Multiplication (*)
    • Division (/)
    • Subtraction (-)
    • Addition (+)
  • Comparison operations
    • Equal (==)
    • Not Equal (!=)
    • Greater Than (>)
    • Less Than (<)
  • If condition (check)
  • Print (show)

About

I have antlr4 parser generator to create the parser. Currently, code is get compiled into Java in parse tree tier. I hope to develop the AST, which allows some semantic analysis as well. Currently, there is mock model for AST, but not fully implemented yet.

Here, I have used the visitor to traverse the parse-tree.

Project Structure

src

src folder contains all dev packages.

  • antlr
  • app
  • ast
    • gen
antlr

Antlr generated parser, lexer, visitor and listener.

app

Entry point of the compiler

ast

Mock model of the AST

gen

Antlr2Java.java file contains the implementation for compiling calang into Java in parse tree tier.

calang's People

Contributors

buddhikac96 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.