Skip to content

Latest commit

 

History

History
206 lines (164 loc) · 4.5 KB

File metadata and controls

206 lines (164 loc) · 4.5 KB

LATIN Language Implementation Summary

Completed Features

Core Language Features

✅ Variables with Latin declensions (nominative, accusative, dative, ablative, vocative, genitive) ✅ Roman numeral support (I-MMMM) ✅ String handling with 5 operations (startswith, endswith, contains, indexof, equals) ✅ Automatic declension based on word endings (-US, -A, -VM/-UM, -OR, -IO) ✅ No-whitespace parsing with Latin morphology ✅ Structs/Objects with genitive case for field access

Control Flow

✅ Conditional statements (SI, ALITER, FINIS) ✅ Loops (DUM, FINIS) ✅ Proper block depth tracking for nested structures

Object-Oriented Features

✅ Struct/object creation using genitive case ✅ Field assignment (FIELDGENITIVE EST VALUE) ✅ Field access for reading (SCRIBEFIELDGENITIVE) ✅ Automatic object initialization as dictionary/struct

Arithmetic Operations

✅ Addition (ADDE - with accusative + dative) ✅ Subtraction (DEME - with accusative + ablative) ✅ Multiplication (MVLTIPLICA) ✅ Division (DVCE - with automatic division by zero exception) ✅ Comparison operators (AEQUAT, MAIVS, MINOR)

Functions

✅ Function definition (FAC - with nominative + dative parameters) ✅ Function calls (VOCA - with accusative arguments) ✅ Return values (REDDO - with accusative) ✅ Proper scope and call stack management

Input/Output

✅ Output (SCRIBE - with accusative) ✅ User input (LEGO - with automatic type detection) ✅ Debug output (AVDI - with [DEBUG] prefix) ✅ Log output (NOTA - with [LOG] prefix)

Exception Handling

✅ Manual exceptions (IACE - with vocative case) ✅ Exception handlers (CAPE - with vocative case) ✅ Automatic exceptions (division by zero throws ERROR) ✅ Stack-based handler mechanism ✅ Proper cleanup and program termination after handling

Example Programs

1. Hello World

SCRIBE"Salve Munde!"

2. Variables and Arithmetic

SITNUMERUS
SITPRIMUS
NUMERUSESTX
PRIMUSESTV
NUMERUSESTADDEPRIMUMNUMERO
SCRIBENUMERUM

3. Conditionals

SITNUMERUS
NUMERUSESTX
SINUMERUSMAIVSI
SCRIBE"Magnus!"
FINIS

4. Loops

SITNUMERUS
NUMERUSESTX
DUMNUMERUSMAIVSI
SCRIBENUMERUM
NUMERUSESTDEMENUMERUM
FINIS

5. Functions

SITX
SITY
SITSUMMA
FACADDITORXYDATIVOYADDEDATIVOYSUMMAE
REDDOSUMMAM
FINIS
XESTX
YESTV
SUMMAESTVOCAADDITOREMXY
SCRIBESUMMA

6. Exception Handling

SITERROR
CAPEERROR
NOTA"Caught error!"
FINIS
IACEERROR"Something wrong"

7. Structs/Objects

SITSERVUS
SITNOMEN
SITAETAS
NOMENSERVIIEST"Marcus"
NUMERUSESTXXX
AETASSERVIIESTNUMERUS
SCRIBENOMENSERVII
SCRIBEAETASSERVII

8. ELIZA Chatbot

Working psychotherapy chatbot using string operations and loops!

File Structure

  • latin.py - Main interpreter (1246 lines)
  • README.md - Complete documentation
  • examples/ - 19 example programs:
    • hello.lat
    • addition.lat
    • conditional.lat
    • else.lat
    • multiply.lat
    • comparison.lat
    • loop.lat
    • countdown.lat
    • strings.lat
    • string_ops.lat
    • input.lat
    • calculator.lat
    • greeting.lat
    • eliza.lat
    • function.lat
    • logging.lat
    • exception_simple.lat
    • exceptions.lat
    • division_by_zero.lat
    • struct.lat

Language Statistics

  • 27 keywords
  • 6 Latin cases fully implemented (including genitive for struct field access)
  • 5 string operations
  • 5 string operations
  • 5 arithmetic operations
  • 3 comparison operators
  • 2 debug/logging keywords
  • 2 exception handling keywords
  • Automatic declension for -US, -A, -VM/-UM, -OR, -IO endings

Testing Status

✅ All basic features tested ✅ All control flow tested
✅ All arithmetic operations tested ✅ Function definition and calling tested ✅ Exception handling tested (manual and automatic) ✅ Debug/logging tested ✅ String operations tested ✅ User input tested ✅ ELIZA chatbot working ✅ Struct/object field access tested

Known Limitations

  • Program execution stops after exception handling (no try/catch/finally pattern)
  • Exception handlers only catch one exception before terminating
  • No nested exception handling
  • No custom exception types beyond those declared with SIT
  • Field access with direct Roman numerals can have parsing ambiguities (use intermediate variables)
  • Division by zero only throws exception if CAPEERROR handler exists

Future Enhancements

  • Multiple exception handlers in sequence
  • Resume execution after exception handling
  • Try/catch/finally pattern
  • More exception types
  • Exception re-throwing
  • Custom exception messages accessible in handlers