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.
- Basic tokenization of Lua code
- Syntax analysis based on provided syntax diagram
- Expression parsing and evaluation
- Initial operand handling
- Extended tokenization capabilities
- Implementation of assembly code generation
- Addition of header and footer templates for assembly output
- Complete compilation pipeline from Lua to ASM
- Enhanced expression handling
- More efficient code generation
- Support for additional Lua language features
- Improved error handling and reporting
Each version of the compiler follows a similar structure:
main.dart
- Entry point and core compiler logictokenizer.dart
- Lexical analysis of Lua source codeoperands.dart
- Handling of operands and operationsfilters.dart
- Additional filtering and preprocessingheader.asm
/footer.asm
- Templates for assembly output- Sample input/output files (
.lua
and.asm
)
- Lexical Analysis: Tokenization of Lua source code
- Syntax Analysis: Parsing according to the syntax diagram
- Semantic Analysis: Verification of program meaning
- Code Generation: Translation to assembly language
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.
- Dart SDK (version 2.x or higher)
# Navigate to the desired version
cd compiler-V3.1
# Run the compiler with a Lua input file
dart main.dart program.lua
- Variable declarations and assignments
- Arithmetic operations
- Conditional statements
- Basic loops
- Function calls
- String operations
- Logical expressions
- Support for more Lua language features
- Enhanced optimization techniques
- Better error recovery mechanisms
- Expanded standard library support
This project is open-source and available under the MIT License.
�� Happy Compiling!