GithubHelp home page GithubHelp logo

harsath / prism-interpreter Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 3.41 MB

Interpreter for the Prism programming language

License: MIT License

ANTLR 1.37% Java 98.50% Shell 0.13%
antlr4 interpreter programming-language

prism-interpreter's People

Contributors

aiafrat8 avatar harsath avatar kaazii avatar rsuwary avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

prism-interpreter's Issues

Support operations over classes

Requires modification to variable_decl and expr. In variable_decl, we should add ID to support the CLASS type (classes are custom type), and initialization of the object of the class.

Support ELIF statement

Currently, we nest multiple IFs inside an ELSE block. But support ELIF for alternative branches.

Scope

There's an issue where you can access variables in functions that were declared in main. For example:

`FUNCTION INT foo(INT a1, INT a2) {
RETURN a * b;
}

FUNCTION INT main() {
INT a = 15;
INT b = 15;
a = foo(a, b);
RETURN a;
}`

Create the language syntax and specification

Create a language specification for ANTLR

Basic language features for milestone 1:

  • Class declaration
  • Function declaration
  • Variable declaration
  • Expression parsing (addition, subtraction, multiplication and division)
  • Logical expression parsing (less than, equals, greater than, and, or, not)
  • Conditional statement

Code Coverage - Statement Coverage

The output of our "coverage" will be:
(number of lines covered by test / total number of lines in the source file) * 100

EXAMPLE:
(3 / 5) * 100 = 60, so our test covers 60% of the source file.

Access specifiers for classes

Supporting private and public access specifiers for classes (private methods and attributes cannot be called from an instance of the object). But can be called within the class (by helper subroutines).

Support arrays in grammar

It requires some modification to our grammar file. For array reference, assignment and usage, we will add a new rule,
ID '[' expr ']' to expr parser rule. But we also have to add additional syntax for arrays under variable_decl to support the declaration and initialization of arrays.

Add hashmap data structure support

Support Map data type for internal hashmap. Syntax can be similar to:

Hashmap<KEY_TYPE, VALUE_TYPE> variable = {OPTIONAL_KEY_VALUE_PAIR};

OPTIONAL_KEY_VALUE_PAIR := (KEY, VALUE)*

Support operations over class methods and attributes

Currently, we only allow the declaration of classes. But we should also have syntax support for invoking methods and accessing attributes. Requires changes in grammar to support creating new objects and accessing members.

Raise an exception when a user tries to define an in-built function

If someone tries to define an in-built function in their source program, raise an exception saying that Cannot define in-built function FUNCTION_NAME. We should store a hash table of in-built functions and check if the declaration function's name .contains() in the hash table, if so, raise an exception. Work should be done in DeclarationExecutor.java.

Import statement

Support import facility to import Prism sources files.

Example, we can have function-implementations.prism where various functions recides (without main()) and another test Prism file, ex test-function-implementation.prism will import function-implementation.prism and use variables, functions, and classes from that source file.

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.