Skip to content

dilenpt/SceneDSL-Renderer-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SceneDSL Renderer (CMSC 330 Project 1)

This project is a Java-based graphics scene renderer that parses a domain-specific language (DSL) defined in a scene file and displays the specified graphical elements using Java's AWT graphics library.

πŸ“š Project Overview

This project was developed for CMSC 330 - Organization of Programming Languages. It extends a provided Java skeleton to support parsing and rendering of graphical scenes based on an expanded EBNF grammar.

Supported Shapes:

  • Right Triangle
  • Rectangle
  • Isosceles Triangle
  • Parallelogram
  • Regular Polygon
  • Text

The program reads a scene definition file, parses its contents, creates shape objects, and renders the full scene graphically.


πŸ“„ Grammar Specification

scene β†’ SCENE IDENTIFIER number_list images END '.' images β†’ image images | image image β†’ right_triangle | rectangle | parallelogram | regular_polygon | isosceles | text

(Terminals, non-terminals, and formatting follow the original EBNF syntax provided.)


πŸ“‚ Project Structure

/src β”œβ”€β”€ Parser.java # Modified to support new grammar rules β”œβ”€β”€ Lexer.java # Updated to tokenize new keywords and string literals β”œβ”€β”€ Tokens.java # Extended with new tokens β”œβ”€β”€ Text.java # New class for rendering text β”œβ”€β”€ SolidPolygon.java # New class for regular polygons β”œβ”€β”€ IsoscelesTriangle.java # New class for isosceles triangles β”œβ”€β”€ Parallelogram.java # New class for parallelograms β”œβ”€β”€ RegularPolygon.java # New class for regular polygons └── ... # Other provided and updated skeleton files

πŸ› οΈ How to Run

  1. Compile all .java files:

    javac *.java
    
    
  2. Run the main class (usually Main or similar):

    java Main scene.txt

    Replace scene.txt with your scene definition file.

βœ… Test Plan

The program was tested using a variety of scene files that include:

  • Single and multiple shapes
  • Edge cases for color values and dimensions
  • Valid and invalid syntax
  • Mixed shape types

Example test file:

Scene Test (500, 500) RightTriangle Color (255, 0, 0) at (50, 30) Height 100 Width 300; Rectangle Color (0, 128, 255) at (100, 100) Height 200 Width 100; Text Color (0, 0, 0) at (400, 200) "Hello World"; End.


🧠 Lessons Learned

  • How to extend a recursive-descent parser
  • Working with abstract classes and Java's graphics API
  • Designing and implementing new grammar rules
  • Handling custom tokens and string parsing

✍️ Author

Dilen Patel
Project 1: Scene Renderer


Let me know if you want to include example output images or add GitHub Pages support for a demo!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages