Skip to content

jacobalmon/Lexer-Parser-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Lexer & Parser for TinyPie

Introduction

This project is a Lexer and Parser built for a custom language called TinyPie. It provides a graphical interface using tkinter to tokenize and parse input code, displaying the results and parse trees in real-time. The system follows a simplified grammar and uses anytree to visualize parse trees.

Table of Contents

Features

  • Lexical Analysis: Tokenizes input code into keywords, identifiers, operators, separators, and literals.
  • Syntax Parsing: Builds and visualizes parse trees based on predefined grammar.
  • Real-time Processing: Processes input line-by-line with on-screen updates.
  • Tree Visualization: Displays the generated parse tree for each line of code.

Grammar Rules

The project supports the following simplified grammar:

  • Mathematical Expressions:
    math_exp -> key id = math
    math -> multi + multi
    multi -> float * multi | int * multi | float | int
    
  • Conditional Statements:
    if_exp -> if(comparison_exp):
    comparison_exp -> id > id
    
  • Print Statements:
    print_exp -> print("str_literal")
    

Installation

  1. Clone the repository:
    git clone https://github.com/jacobalmon/Lexer-Parser-Project.git
  2. Install the required Python packages:
    pip install tkinter anytree

Usage

  1. Run the application:
    python source.py
  2. Enter source code in the Source Code text box.
  3. Click Next Line to process each line and view tokens.
  4. View the generated parse tree in the Tree Visualization section.
  5. Click EXIT to close the application.

Dependencies

  • Python 3.x
  • tkinter: For the GUI interface.
  • anytree: For parse tree visualization.
  • re: For regular expression-based tokenization.

Configuration

No special configuration is needed. You can modify the grammar or tokenization logic by editing the cutOneLineTokens function and parser methods.

Contributors

Hannah Gonzalez

Natalie Pedroza

About

Lexer & Parser for language TinyPie that does math for int's and floats, conditional statements, and print statements.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages