Skip to content

Conversation

Copy link

Copilot AI commented Sep 21, 2025

This PR implements a new enhanced output module that provides colored parentheses and compact mode functionality for the Lambda Calculus Interpreter. The module can be activated via compiler directives without modifying any existing source files.

Features

🎨 Colored Parentheses

  • Each nesting level uses a different color from a palette of 12 colors (Red, Green, Yellow, Blue, Magenta, Cyan + bright variants)
  • Uses ANSI escape codes for terminal compatibility
  • Greatly improves readability of deeply nested lambda expressions

📦 Compact Mode

  • Removes unnecessary parentheses while maintaining mathematical correctness
  • Significantly reduces visual clutter in complex expressions
  • Example: (λx.(x)) y becomes (λx.x) y

🔧 Drop-in Replacement

The module acts as a complete drop-in replacement that can be enabled entirely through compiler flags:

# Enable colored parentheses only
gcc -DENABLE_ENHANCED_OUTPUT -DENHANCED_OUTPUT_MODE=1 ...

# Enable compact mode only  
gcc -DENABLE_ENHANCED_OUTPUT -DENHANCED_OUTPUT_MODE=2 ...

# Enable both features
gcc -DENABLE_ENHANCED_OUTPUT -DENHANCED_OUTPUT_MODE=3 ...

# Default behavior (no flags needed)
gcc ...

Implementation

The module provides four operation modes:

  • Mode 0: Normal (default behavior)
  • Mode 1: Colored parentheses only
  • Mode 2: Compact formatting only
  • Mode 3: Both colored and compact

When enabled, existing expr_to_buffer() calls are automatically replaced with enhanced versions through preprocessor macros, requiring zero code changes.

Files Added

  • include/enhanced_output.h - Core interface definitions
  • src/enhanced_output.c - Implementation of colored and compact formatting
  • include/enhanced_wrapper.h - Drop-in replacement wrapper with macros
  • test/test_enhanced_simple.c - Comprehensive test suite
  • ENHANCED_OUTPUT_README.md - Complete usage documentation
  • Makefile.enhanced - Additional build targets

Example Output

Before (standard):

(λx.(x)) y
(λf.λx.f (f x))

After (colored + compact):

(λx.x) y                    # Red parentheses
λf.λx.f (f x)              # Nested colors: red, green, blue

The module maintains complete backward compatibility and has zero performance impact when disabled.

Fixes #11.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Author

Copilot AI commented Sep 21, 2025

@dhodgson615 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 2 commits September 21, 2025 01:18
Co-authored-by: dhodgson615 <133537428+dhodgson615@users.noreply.github.com>
Co-authored-by: dhodgson615 <133537428+dhodgson615@users.noreply.github.com>
Copilot AI changed the title [WIP] Need colored parentheses and compact mode Add colored parentheses and compact mode module with compiler directive activation Sep 21, 2025
Copilot AI requested a review from dhodgson615 September 21, 2025 01:24
Copilot finished work on behalf of dhodgson615 September 21, 2025 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need colored parentheses and compact mode

2 participants