Skip to content

The project implements a complete compilation pipeline including tokenization, syntax analysis based on formal grammar, and assembly code generation. Perfect for those interested in compiler design and implementation or looking to understand the transformation from high-level Lua code to low-level assembly language.

License

Notifications You must be signed in to change notification settings

AntonioAEMartins/LuaDart-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Lua Compiler - Computational Logic

git status

📝 Overview

This repository contains a Lua to Assembly compiler implemented in Dart. The compiler follows the principles of computational logic to transform Lua source code into executable assembly code. The project showcases the evolution of the compiler through three main versions, each adding new features and improvements.

🔄 Compiler Versions

🏗️ V2.4 - Initial Implementation

  • Basic tokenization of Lua code
  • Syntax analysis based on provided syntax diagram
  • Expression parsing and evaluation
  • Initial operand handling

🛠️ V3.0 - Assembly Generation

  • Extended tokenization capabilities
  • Implementation of assembly code generation
  • Addition of header and footer templates for assembly output
  • Complete compilation pipeline from Lua to ASM

⚡ V3.1 - Optimizations and Improvements

  • Enhanced expression handling
  • More efficient code generation
  • Support for additional Lua language features
  • Improved error handling and reporting

🧩 Project Structure

Each version of the compiler follows a similar structure:

  • main.dart - Entry point and core compiler logic
  • tokenizer.dart - Lexical analysis of Lua source code
  • operands.dart - Handling of operands and operations
  • filters.dart - Additional filtering and preprocessing
  • header.asm/footer.asm - Templates for assembly output
  • Sample input/output files (.lua and .asm)

🔍 Compilation Process

  1. Lexical Analysis: Tokenization of Lua source code
  2. Syntax Analysis: Parsing according to the syntax diagram
  3. Semantic Analysis: Verification of program meaning
  4. Code Generation: Translation to assembly language

📊 Syntax Diagram

The compiler follows a formal syntax diagram (see diagrama_sintatico.jpg) that defines the grammar rules for the subset of Lua language supported by this compiler.

🚦 Getting Started

Prerequisites

  • Dart SDK (version 2.x or higher)

Running the Compiler

# Navigate to the desired version
cd compiler-V3.1

# Run the compiler with a Lua input file
dart main.dart program.lua

📚 Supported Features

  • Variable declarations and assignments
  • Arithmetic operations
  • Conditional statements
  • Basic loops
  • Function calls
  • String operations
  • Logical expressions

🔧 Future Improvements

  • Support for more Lua language features
  • Enhanced optimization techniques
  • Better error recovery mechanisms
  • Expanded standard library support

📄 License

This project is open-source and available under the MIT License.

👥 Contributors


�� Happy Compiling!

About

The project implements a complete compilation pipeline including tokenization, syntax analysis based on formal grammar, and assembly code generation. Perfect for those interested in compiler design and implementation or looking to understand the transformation from high-level Lua code to low-level assembly language.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy