Skip to content

Interpreter for RPAL, developed by Team Atlantis. Includes lexical analysis, syntax parsing, and semantic evaluation.

License

Notifications You must be signed in to change notification settings

SGeesan/rpal-lang-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

RPAL Language Interpreter

A comprehensive interpreter for the RPAL programming language, featuring lexical analysis, syntax parsing, AST/ST visualization, and semantic evaluation.

Developed by Team Atlantis ๐ŸŒŠ

๐Ÿ“‹ Table of Contents

๐Ÿ” Overview

This RPAL interpreter is a complete implementation that processes RPAL (Right-reference Pedagogical Algorithmic Language) source code through multiple phases:

  • Lexical Analysis - Tokenizes the input source code
  • Syntax Parsing - Builds Abstract Syntax Trees (AST)
  • Tree Standardization - Converts AST to Standardized Trees (ST)
  • Semantic Evaluation - Executes the program and produces results

โœจ Features

  • ๐Ÿ”ง Modular Architecture - Clean separation of lexer, parser, and evaluator components
  • ๐ŸŒณ Tree Visualization - Optional AST and ST output for debugging and learning
  • ๐Ÿš€ Multiple Build Options - Support for both Maven and Makefile builds
  • ๐Ÿ“Š Comprehensive Testing - Includes test cases for validation
  • ๐ŸŽฏ Standards Compliant - Full RPAL language specification support

๐Ÿ“‹ Prerequisites

  • Java JDK 8+ (tested with Java 21)
  • Maven 3.6+ (for Maven build method)
  • Make utility (for Makefile build method)

๐Ÿš€ Installation

Method 1: Maven Build (Recommended)

# Clone the repository
git clone <repository-url>
cd rpal-lang-interpreter

# Clean and build the project
mvn clean install

This creates a JAR file in the target/ directory.

Method 2: Makefile Build

# Navigate to source directory
cd rpal/src/main/java

# Compile using make
make

This generates .class files in the same directory structure.

๐ŸŽฎ Usage

Basic Execution

java myrpal <input_file>

With Output Redirection

java myrpal test/test1 > output.txt

Debug Options

Use optional switches to visualize internal tree structures:

Switch Description
-ast Print Abstract Syntax Tree
-st Print Standardized Tree

Examples

# Run basic interpretation
java myrpal test/test1

# View AST structure
java myrpal -ast test/test1

# View both AST and ST
java myrpal -ast -st test/test1

# Save output to file
java myrpal -ast test/test1 > debug_output.txt

๐Ÿ“ Project Structure

rpal-lang-interpreter/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ main/
โ”‚       โ””โ”€โ”€ java/
โ”‚           โ”œโ”€โ”€ lexer/          # Lexical analysis components
โ”‚           โ”œโ”€โ”€ parser/         # Syntax parsing and AST generation
โ”‚           โ”œโ”€โ”€ evaluator/      # Semantic evaluation engine
โ”‚           โ””โ”€โ”€ myrpal.java     # Main entry point
โ”œโ”€โ”€ test/                       # Test cases and examples
โ”œโ”€โ”€ target/                     # Maven build output
โ”œโ”€โ”€ pom.xml                     # Maven configuration
โ”œโ”€โ”€ Makefile                    # Alternative build configuration
โ””โ”€โ”€ README.md                   # This file

๐Ÿ”จ Build Methods

Maven (Preferred)

Maven provides dependency management, testing integration, and packaging:

# Clean previous builds
mvn clean

# Compile and package
mvn compile package

# Run tests
mvn test

# Complete build with tests
mvn clean install

Makefile (Alternative)

For environments where Maven isn't available or for submission requirements:

cd rpal/src/main/java
make clean  # Remove previous .class files
make        # Compile all source files

๐Ÿ“ Examples

Sample RPAL Program

let add x y = x + y
in add 5 3

Running the Example

# Assuming the above code is saved as 'sample.rpal'
java myrpal sample.rpal
# Output: 8

# View the AST structure
java myrpal -ast sample.rpal

๐Ÿงช Testing

The project includes comprehensive test cases in the test/ directory:

# Run all test cases using Makefile
make test

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is developed as part of an academic assignment. Please respect academic integrity guidelines when using this code.


๐Ÿ†˜ Troubleshooting

Common Issues

Java version compatibility: Ensure you're using JDK 8 or higher

java -version

Maven not found: Install Maven or use the Makefile alternative

mvn --version

Class not found errors: Ensure you're running from the correct directory after building


Made by Team Atlantis

Building bridges between theory and practice, one parse tree at a time.

About

Interpreter for RPAL, developed by Team Atlantis. Includes lexical analysis, syntax parsing, and semantic evaluation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •