Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Phyton 🌱

CI/CD Pipeline Coverage

Phyton (Greek Ξ¦Ο…Ο„ΟŒΞ½ for "plant") is a Python interpreter that accepts multiple spellings of keywords, designed to confuse bad spellers!

Inspired by a suggestion from Michael A. Covington, author of Natural Language Processing for Prolog Programmers πŸ™Œ

Phyton

Features

  • Accepts common misspellings of Python keywords
  • Interactive REPL mode
  • File execution mode
  • Friendly error messages
  • Fuzzy matching for unknown misspellings (optional)
  • Supports creative variations like prin for print, deff for def, etc.

Supported Misspellings

Keywords

  • def β†’ deff, define, defin
  • if β†’ iff, iif
  • elif β†’ elsif, elseif, else_if
  • else β†’ els, elze
  • for β†’ fore, four, fr
  • while β†’ wile, whyle, whil
  • in β†’ inn, iin
  • return β†’ retrun, retrn, ret
  • import β†’ imprt, imort, importt
  • from β†’ frm, fom
  • as β†’ az, ass
  • class β†’ clas, clss, klass
  • try β†’ tri, tyr
  • except β†’ exept, excpt, catch
  • finally β†’ finaly, finale
  • with β†’ wth, wit
  • and β†’ andd, adn, &
  • or β†’ orr, |
  • not β†’ nott, no, !

Built-ins

  • True β†’ true, TRUE, tru
  • False β†’ false, FALSE, fals
  • None β†’ none, NONE, null, nil
  • print β†’ prin, prnt, pritn

Usage

Interactive Mode

# Using Python directly
python3 phyton.py

# Using the launcher script
./phyton

File Execution

# Using Python directly (fuzzy matching disabled by default)
python3 phyton.py examples/quick_start.phy

# Using the launcher script (recommended)
./phyton examples/quick_start.phy

# Enable fuzzy matching for unknown misspellings
python3 phyton.py --fuzzy examples/quick_start.phy
./phyton --fuzzy examples/quick_start.phy

Command Line Options

Phyton accepts misspelled command line options too! Try these:

# These all work thanks to option misspelling correction:
./phyton --halp                    # β†’ --help
./phyton --fuzy file.phy           # β†’ --fuzzy  
./phyton --interactiv              # β†’ --interactive

Fuzzy Matching

Phyton includes fuzzy matching that can correct unknown misspellings not in the predefined dictionary:

# Default behavior - fuzzy matching disabled
python3 phyton.py your_file.phy

# Enable fuzzy matching for unknown misspellings
python3 phyton.py --fuzzy your_file.phy

# Interactive mode (fuzzy disabled by default)
python3 phyton.py --interactive

Examples of fuzzy corrections:

  • defff β†’ def
  • printt β†’ print
  • prrint β†’ print

⚑ Note: Fuzzy matching is disabled by default for predictable behavior. Use --fuzzy to enable advanced spelling correction.

Examples

All example files are located in the examples/ folder with memorable names:

  • quick_start.phy - Perfect first Phyton program
  • hello_world.phy - Classic programming with misspellings
  • spelling_game.phy - Interactive spelling game
  • advanced_features.phy - Complex programming constructs
  • bad_spellers_paradise.phy - Maximum misspelling density
  • spelling_nightmare.phy - Ultimate stress test

See examples/README.md for detailed descriptions and learning path.

Examples

Quick Start Example

# This is valid Phyton code!
deff greet(name):
    prin(f"Hello, {name}!")

iff name == "World":
    greet("Phyton")
els:
    greet("Python")

Advanced Example

klass Plant:
    deff __init__(self, species):
        self.species = species
    
    deff grow(self):
        retrun f"{self.species} is growing! 🌿"

fore i inn range(3):
    plant = Plant(f"Plant {i}")
    prin(plant.grow())

For more examples, see the examples/ folder!

Quick Start

  1. Try the demo: ./demo.sh - Runs all 6 examples
  2. Start simple: ./phyton examples/quick_start.phy
  3. Go interactive: ./phyton for REPL mode
  4. Explore: Check examples/README.md for learning path

Testing

Phyton includes a comprehensive test suite to ensure all functionality works correctly.

Running Tests

# Install test dependencies
pip install -r requirements.txt

# Run all tests with pytest
python -m pytest test_phyton.py -v

# Run tests with coverage
python -m pytest test_phyton.py --cov=phyton --cov-report=term

# Check code quality with pylint
pylint phyton.py
pylint test_phyton.py

Test Coverage

The test suite includes 130 tests covering:

  • All keyword mappings (33 tests)
  • Fuzzy matching functionality (15 tests)
  • Command-line argument parsing (20 tests)
  • File execution and error handling (25 tests)
  • Interactive mode (10 tests)
  • Edge cases and comprehensive coverage (27 tests)

Current coverage: 79% with perfect pylint score (10/10)

Continuous Integration

GitHub Actions automatically runs all tests on:

  • Python 3.8, 3.9, 3.10, 3.11, and 3.12
  • Code quality checks with pylint
  • Coverage reporting

File Extensions

While Phyton can execute any .py file, we recommend using .phy extension for Phyton files to distinguish them from regular Python files.

Contributing

Feel free to add more creative misspellings! The goal is to accept as many common typos and variations as possible while still being functional.

When contributing:

  1. Add tests for new functionality
  2. Ensure all tests pass: python -m pytest test_phyton.py
  3. Check code quality: pylint phyton.py test_phyton.py
  4. Update documentation as needed

Why?

Because everyone deserves to code, even if they can't spell "def" correctly! 🌱

About

A Python interpreter that accepts misspelled keywords - because everyone deserves to code, even bad spellers! 🌱

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages