Skip to content

Latest commit

 

History

History
211 lines (159 loc) · 6.7 KB

File metadata and controls

211 lines (159 loc) · 6.7 KB

LATIN Programming Language - Implementation Summary

Completed Features ✅

Core Language

  • Roman Numeral I/O - All numbers input/output as Roman numerals
  • No-space parsing - Programs have no whitespace between words
  • Latin grammar - Proper noun declensions (all 6 cases: nominative, accusative, dative, ablative, genitive, vocative)
  • Comments - Semicolon (;) comments

Keywords (18 total)

  • ✅ SIT - Variable declaration
  • ✅ EST - Assignment
  • ✅ SI - Conditional
  • ✅ ALITER - Else clause
  • ✅ DUM - While loop
  • ✅ FINIS - End block
  • ✅ SCRIBE - Print output
  • ✅ LEGE - Read user input
  • ✅ FAC - Function declaration
  • ✅ REDDO - Return value
  • ✅ VOCA - Call function
  • ✅ AVDI - Log to stderr
  • ✅ NOTA - Debug log to stderr
  • ✅ IACE - Throw exception
  • ✅ CAPE - Catch exception

Operations (12 total)

Arithmetic

  • ✅ ADDE - Addition
  • ✅ DEME - Subtraction
  • ✅ MVLTIPLICA - Multiplication
  • ✅ DVCE - Integer division

String Operations

  • ✅ IVNGE - String concatenation
  • ✅ INCIPITCVM - Starts with
  • ✅ FINITVRCVM - Ends with
  • ✅ CONTINET - Contains
  • ✅ INDICEDE - Index of

Comparison

  • ✅ AEQUAT - Equals comparison (numbers and strings)
  • ✅ MAIVS - Greater than
  • ✅ MINOR - Less than

Data Types

  • ✅ Integers (represented as Roman numerals)
  • ✅ Strings (double-quoted text)
  • ✅ NIHIL (zero - "nothing")

Control Flow

  • ✅ Conditionals with SI/ALITER/FINIS
  • ✅ Loops with DUM/FINIS
  • ✅ Functions with FAC/REDDO/VOCA
  • ✅ Exception handling with IACE/CAPE (using vocative case)
  • ✅ Multiple comparison operators

Advanced Features

  • Structs/Objects - Field access using genitive case (NOMENSERVII = "name of servant")
  • Logging - AVDI and NOTA write to stderr
  • Exception handling - IACE throws, CAPE catches (uses vocative case)

Latin Nouns (32+ in declension table)

  • ✅ Second declension masculine: NUMERUS, PRIMUS, SECUNDUS, TERTIUS, QUARTUS, QUINTUS, AMICUS, SERVUS, DOMINUS, FILIUS, ANNUS, LIBER, VENTER
  • ✅ Second declension neuter: BELLVM, VERBVM, DONVM, RESULTAT
  • ✅ First declension feminine: PUELLA, ROSA, AQUA, VITA, TERRA, SUMMA
  • ✅ Third declension: REX, CIVIS, CORPVS, TEMPVS, ITER, NOMEN, INDEX
  • ✅ Fourth declension: MANVS, GRADVS
  • ✅ Fifth declension: RES, DIES

Tools & Features

  • Interactive REPL - Type python3 latin.py --repl
  • Bilingual errors - Latin (default) or English (--english flag)
  • File execution - Run .lat files
  • Comprehensive error messages - In both languages

Examples Provided

  • ✅ hello.lat - Basic output
  • ✅ addition.lat - Addition with proper cases
  • ✅ conditional.lat - If statement
  • ✅ else.lat - If/else statement
  • ✅ multiply.lat - Multiplication
  • ✅ comparison.lat - Greater/less than
  • ✅ loop.lat - While loop
  • ✅ countdown.lat - Countdown loop
  • ✅ strings.lat - String literals and concatenation
  • ✅ string_ops.lat - String comparison operations
  • ✅ input.lat - User input with LEGE
  • ✅ calculator.lat - Interactive calculator
  • ✅ greeting.lat - User greeting program
  • ✅ function.lat - Function definition and calls
  • ✅ logging.lat - Stderr logging with AVDI/NOTA
  • ✅ exception_simple.lat - Basic exception handling
  • ✅ exceptions.lat - Advanced exception handling
  • ✅ division_by_zero.lat - Exception handling example
  • ✅ struct.lat - Object-oriented programming with genitive
  • ✅ eliza.lat - ELIZA chatbot implementation
  • ✅ comprehensive_test.lat - All features
  • ✅ test_two_vars.lat - Variable testing

Documentation

  • ✅ README.md - Complete user guide
  • ✅ MINIMAL_SPEC.md - Language specification
  • ✅ QUICK_REFERENCE.md - Quick command reference

Architecture

Interpreter Structure

latin.py
├── RomanNumeralParser - Bidirectional Roman/decimal conversion
├── LatinDeclension - Noun declension lookup table
├── Tokenizer - Lexical analysis, handles no-space parsing
└── LatinInterpreter - Execution engine
    ├── Variable management (symbol table)
    ├── Control flow (loops, conditionals)
    ├── Arithmetic operations
    └── Error handling (bilingual)

Parsing Strategy

  1. Line-based - Each statement on separate line
  2. Greedy keyword matching - Keywords parsed first
  3. Roman numeral recognition - MDCLXVI patterns
  4. Variable lookup - Longest match across all cases
  5. Special tokens - NIHIL (zero)

Execution Model

  • Direct interpretation - No compilation step
  • Line-by-line execution - With jump capability for loops/conditionals
  • Symbol table - Stores variables by nominative form
  • Loop stack - Tracks nested loop start positions

What Makes LATIN Evil 😈

  1. No spaces - Word boundaries determined by Latin morphology
  2. Grammar required - Must know Latin noun declensions
  3. Case matters - NUMERUS ≠ NUMERUM ≠ NUMERO
  4. Roman numerals only - Mental arithmetic required
  5. Classical spelling - V not U, I not J
  6. Latin errors (default) - "ERRATUM: non intellegitur"
  7. Ambiguous programs - Documented as a "feature"

A programming language that requires proper Latin declensions to compile is definitely a unique concept. The fact that you have to know whether to use nominative, accusative, dative, or ablative case just to write a loop is pretty unique.

Plus, the genitive case for struct field access (NOMENSERVII = "name of servant") and vocative case for exception handling are genuinely creative uses of Latin grammar in a programming context. It's both educational and hilarious.

Future Possibilities

Not Yet Implemented

  • ❌ Arrays/lists
  • ❌ File I/O (beyond user input/output)
  • ❌ Adjectives
  • ❌ Verb conjugations (beyond existing keywords)
  • ❌ Additional declensions beyond the 6 cases

Extension Ideas

  • Boolean operations (ET, AVT, NON)
  • Modulo operation
  • More Latin vocabulary
  • Macros/metaprogramming
  • Static type checking (with cases!)
  • Package manager (BIBLIOTHECA)
  • Debugger (DEPVRATOR)

Testing

All features tested with:

  • Unit examples (hello, addition, etc.)
  • Comprehensive test suite
  • REPL interactive testing
  • Both error modes (Latin/English)

Performance

  • Minimal overhead - Direct interpretation
  • No optimization - Deliberately slow for authenticity
  • Educational focus - Not production-ready (obviously!)

Conclusion

LATIN successfully combines:

  • Real programming language capabilities
  • Authentic Latin grammar requirements
  • Educational/entertainment value
  • Complete tooling (REPL, errors, docs)

Result: A fully functional prank programming language that genuinely requires Latin knowledge to use!

Latin Ain't This Insufferable Normally