Skip to content

This repository contains the implementation of a macro processor, lexical analyzer, and shift-reduce parser, with focus on intermediate code generation and code optimization. It includes code examples and notes for building a simple compiler or interpreter system

Notifications You must be signed in to change notification settings

YashChavanWeb/spcc

Repository files navigation

YashChavanWeb - Compiler Construction Tools

This repository showcases a collection of scripts and resources designed to implement basic components of a compiler. The focus is on macro processing, lexical analysis, parsing, intermediate code generation, and code optimization.

Each script in this repository implements a core part of the compilation process, offering examples, explanations, and code snippets. These tools are ideal for anyone looking to learn about or implement foundational concepts in compiler construction.

Contents

  • 01_pass1_macro_processor.py: Implements the first pass of a macro processor.
  • 02_pass2_macro_processor.py: Implements the second pass of a macro processor.
  • 03_lexical_analyzer.py: Implements a lexical analyzer to tokenize source code.
  • 04_shift_reduce_parser.py: Implements a shift-reduce parser for syntax analysis.
  • 05_intermediate_code.py: Generates intermediate code representation of the source program.
  • 06_code_optimization.py: Implements basic code optimization techniques.
  • notes.txt: Contains additional explanations, theory, and examples for understanding the implemented tools.
  • viva_prep.txt: A compilation of notes for viva preparation.

Usage

Run each script sequentially to simulate different stages of the compilation process: bash python 01_pass1_macro_processor.py python 02_pass2_macro_processor.py python 03_lexical_analyzer.py python 04_shift_reduce_parser.py python 05_intermediate_code.py python 06_code_optimization.py

Review notes.txt and viva_prep.txt for more theoretical background and additional examples.

Contributing

Feel free to fork the repository, make modifications, and submit pull requests if you have improvements or enhancements.

License

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


Get in touch

For questions or suggestions, feel free to open an issue or contact me at [[email protected]].

About

This repository contains the implementation of a macro processor, lexical analyzer, and shift-reduce parser, with focus on intermediate code generation and code optimization. It includes code examples and notes for building a simple compiler or interpreter system

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages