Skip to content

NiharaDeSilva/Delphi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Delphi

Implementation of a customized version of Delphi programming language which is an Object Oriented Extension of Pascal in antlr4 + java using abstract syntax trees

About:

In this project we use a java-based "visitor pattern" (visitor for short) to traverse the abstract syntax tree generated by our ANTLR grammar.

Running:

  1. Generate the proper java files from ANTLR grammar. Run the following command with the -visitor flag, to generate a visitor in addition to the rest of the files:
antlr4 Delphi.g4 -visitor
  1. Compile generated java files:
javac -cp ".:$HOME/antlr4-4.13.2-complete.jar" Delphi*.java
  1. Run the Test Cases:
java -cp ".:$HOME/antlr4-4.13.2-complete.jar" DelphiInterpreter

Notes

What is a visitor?

A visitor is simply the action implementer for our parse tree. It has a method for each branch, containing what actions to perform for that branch.

Our base visitor, generated by the command -visitor above, is an interface; it is generated with empty methods for handling each branch. It's up to us to implement what actions they do in our ASTVisitor file.

Special Notes

  1. Note that instead of procedure we have used procd and func instead of function keyword.
  2. For each test case we have included a .txt file specifying what is expected to be printed by the program.
  3. Each test case will print the program and print statements showcasing the functionality developed.
  4. Test cases 1-12 cover part 1 scope and 13-24 cover part 2 scope.
  5. Please Enter only integers when entering values.

Following features have been implemented - Part 1:

  • Identifying Program name, End
  • Variable declarations
  • Procedure, Function declarations
  • Readln
  • Writeln
  • User defined functions
  • User defined procedures
  • classes
  • constructor declaration
  • constructor definition
  • destructor declaration
  • destructor definition
  • object creation
  • Encapsulation
  • Inheritance: parent classes (bonus)
  • Interfaces (bonus)

Following features have been implemented - Part 2:

  • for-do Loop
  • while-do Loop
  • Arithmetic Operations
  • If-Else statements
  • Break
  • Continue
  • User Defined Procedures
  • User Defined Functions
  • Scoping
  • Constant propagation (bonus)
  • formal parameter passing in procedures (bonus)

Project Group 110 - Suhashi Nihara De Silva - 2129-5237

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published