Skip to content

maxhykw/Java-like-language-interpreter

Repository files navigation

Kawa Interpreter

This project implements an interpreter named Kawa for a custom OOP language inspired by Java. The interpreter includes a lexer (created with ocamllex) for tokenizing the source code, a parser (generated by Menhir) for constructing an abstract syntax tree, a type checker to ensure type correctness, and an interpreter that directly executes the code. It covers core Java-like OOP features, such as:

  • Arithmetic operations: Basic operations like addition, subtraction, multiplication, division, modulo, and boolean calculations.
  • Variables: Supports variable declarations (with or without initial values), and manipulation of global, local, and class attribute variables.
  • Control structures: Implements control flow with if-else and while loops.
  • Classes and attributes: Defines classes with mutable or final attributes and manages them in objects.
  • Methods: Supports method calls, including nested calls, with proper handling of parameters, local variables, and this pointers.
  • Inheritance: Implements parent-child class relationships, access to inherited attributes and methods, and type checking for subtypes.

Additionally, several advanced features and extensions have been implemented:

  • Immutable fields (final attributes).
  • Array support (including multidimensional arrays).
  • Equality checks and type tests (e.g., instanceof).
  • Series declarations for multiple variables and initialization with values.

The interpreter allows the execution of custom Java-like code while ensuring proper type checking and semantic correctness.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages