Skip to content

Defines a sort of macro like language that can run any language in a text file and output the expanded result.

Notifications You must be signed in to change notification settings

loosiegoosey/expander

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Expander

## Overview

The Expander project is designed to expand "macros" given a file or directory using a specified language. It provides a mechanism to define and call macros, streamlining repetitive tasks and simplifying complex code interactions across different programming languages.

## Features

- **Multi-language Support:** Define and expand macros in various programming languages.
- **Macro Definition:** Easily create macros with a specified language, name, and arguments.
- **Macro Call:** Invoke macros within your code seamlessly.
- **Directory and File Handling:** Expand macros within an entire directory or a specific file.
- **Efficient Processing:** Utilizes Python subprocess and tempfile modules to handle macro expansion efficiently.

## Installation Instructions

1. **Clone the repository:**
   ```sh
   git clone https://github.com/username/expander.git
   cd expander
  1. Setup your environment: Ensure you have Python installed. You can check by running:

    python --version
  2. Install dependencies: The project does not specify external dependencies beyond the Python standard library, so no additional installation steps are needed.

Usage Examples

Defining a Macro

In your code (e.g., a Python or Ruby file), define a macro using the following syntax:

??defm:hello:python(arg1, arg2){{
print "puts 'Hello, %s!!!' \n%s" % (arg1, arg2)
}}

Calling a Macro

Use the defined macro within your code as follows:

??hello??'Joe'??'puts "Why, dude?"'??

Running the Expander

To expand macros within a file or directory, use the command line to run the expander script:

python expander.py path/to/your_file_or_directory

Code Summary

expander.py

This is the main script for the project. It includes the logic for reading files or directories, parsing macros, expanding them using the specified language, and outputting the results. Key parts of the script include:

  • Imports: Standard libraries for file handling, regular expressions, temporary files, and subprocess management.
  • Macro Definition Parsing: Regular expressions are used to identify and parse macro definitions and calls.
  • Macro Expansion: Processed using Python's subprocess module to execute code snippets in the specified language.

This script features constants and utility functions to facilitate macro expansion across different programming environments.

Contributing Guidelines

We welcome contributions to the Expander project. Here’s how you can contribute:

  1. Fork the repository: Click the "Fork" button at the top right corner of the repository page.

  2. Clone your fork:

    git clone https://github.com/your_username/expander.git
    cd expander
  3. Create a branch:

    git checkout -b feature/your_feature
  4. Make your changes and commit them:

    git add .
    git commit -m "Add your feature"
  5. Push to your fork:

    git push origin feature/your_feature
  6. Submit a pull request: Go to the original repository and open a pull request describing your changes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.


About

Defines a sort of macro like language that can run any language in a text file and output the expanded result.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.0%
  • Ruby 4.0%