Version: 0.2 (Feature-Complete Edition)
This document defines the absolute minimum feature set for a working LATIN interpreter. The goal is to have the smallest possible language that can still perform basic computation while maintaining the prank spirit of requiring Latin grammar knowledge.
- Only uppercase Roman letters: A-Z (excluding J, U, W as per classical Latin)
- No whitespace: Programs are continuous strings
- Newlines: Used only to separate statements
Roman Numerals Only:
- I = 1
- V = 5
- X = 10
- L = 50
- C = 100
- D = 500
- M = 1000
Standard Roman numeral rules apply:
- Additive: VI = 6, XV = 15
- Subtractive: IV = 4, IX = 9, XL = 40, XC = 90, CD = 400, CM = 900
Comments begin with a semicolon (;) and extend to the end of the line.
- Comments are completely ignored by the parser
- They do not affect tokenization or execution
- Useful for explaining Latin grammar choices and variable meanings
Example:
SITNUMERUS ; declare NUMERUS (number)
NUMERUSESTX ; assign 10 to NUMERUS
Core keywords:
- SIT - Variable declaration ("let it be")
- EST - Assignment/comparison ("is")
- SI - Conditional ("if")
- FINIS - End block ("end")
- SCRIBE - Output ("write")
Additional keywords: 6. DUM - While loop ("while") 7. ALITER - Else clause ("otherwise") 8. FAC - Function declaration ("do/make") 9. REDDO - Return value ("give back") 10. AVDI - Log to stderr ("listen/hear") 11. NOTA - Debug log to stderr ("note/mark") 12. LEGE - Read input ("read") 13. IACE - Throw exception ("throw") 14. CAPE - Catch exception ("catch")
Arithmetic operations:
- ADDE - Addition ("add")
- Usage:
ADDE[accusative][dative]- "add [accusative] to [dative]"
- Usage:
- DEME - Subtraction ("subtract")
- Usage:
DEME[accusative][ablative]- "subtract [accusative] from [ablative]"
- Usage:
- DUC - Multiplication ("lead/multiply")
- Usage:
DUC[accusative][ablative]- "multiply [accusative] by [ablative]"
- Usage:
- DIVIDE - Division ("divide")
- Usage:
DIVIDE[accusative][ablative]- "divide [accusative] by [ablative]"
- Usage:
Comparison operations: 5. AEQUAT - Equals comparison ("equals") 6. MAIOR - Greater than ("greater") 7. MINOR - Less than ("lesser")
String operations (on string variables): 8. INCIPIT - Starts with ("begins") 9. DESINIT - Ends with ("ends") 10. CONTINET - Contains ("contains") 11. INDEX - Find position ("index")
Note: String operations use the genitive case for the search pattern
- Must be valid Latin nouns
- Must be from the five Latin declensions
- Must decline properly by case:
- Nominative: subject, left side of assignment
- Accusative: direct object, the thing being acted upon
- Dative: indirect object, "to" or "for" (used with ADDE)
- Ablative: "from" or "by means of" (used with DEME, DUC, DIVIDE)
- Genitive: possession, "of" (used for struct field access)
- Vocative: direct address (used in exception handling with CAPE)
For simplicity, stick to second declension masculine (-US, -UM, -O endings):
- NUMERUS (number) - nominative singular
- NUMERUM - accusative singular
- NUMERO - dative/ablative singular (same form in 2nd declension!)
SIT[nominative-noun]
Example:
SITNUMERUS
[nominative]EST[value]
Example:
NUMERUSESTX
Assigns value X (10) to NUMERUS.
[nominative]ESTADDE[accusative][dative]
[nominative]ESTDEME[accusative][ablative]
Examples:
NUMERUSESTADDEXV ; add X (acc) to V (dat) = 15
NUMERUSESTDEMEXLNUMERO ; subtract XL (acc) from NUMERO (abl)
SCRIBE[accusative]
Example:
SCRIBENUMERUM
SI[nominative]AEQUAT[accusative]
[statements]
FINIS
Example:
SINUMERUSAEQUATX
SCRIBENUMERUM
FINIS
SITNUMERUS
NUMERUSESTXLII
SCRIBENUMERUM
Output: 42
SITNUMERUS
NUMERUSESTADDEXXX
SCRIBENUMERUM
Output: 60
SITNUMERUS
NUMERUSESTX
SINUMERUSAEQUATX
SCRIBENUMERUM
FINIS
Output: 10
SITPRIMUS
SITSECUNDUS
SITTERTIUS
PRIMUSESTXX
SECUNDUSESTXXII
TERTIUSESTADDEPRIMUMSECUNDO ; add PRIMUM (acc) to SECONDO (dat)
SCRIBETERTIUM
Output: 42
- Newline-separated statements: Each statement is on its own line
- Keyword matching: Greedily match known keywords (SIT, EST, SI, FINIS, SCRIBE, ADDE, DEME, AEQUAT)
- Roman numeral matching: Match valid Roman numeral patterns
- Variable matching: Match declared variable names with proper case endings
- Remaining text: Should resolve to a valid Latin noun form
The parser needs a dictionary of valid Latin nouns with their declined forms:
- NUMERUS (nominative) → NUMERUM (accusative), NUMERO (dative/ablative)
- PRIMUS (nominative) → PRIMUM (accusative), PRIMO (dative/ablative)
- SECUNDUS (nominative) → SECUNDUM (accusative), SECUNDO (dative/ablative)
- TERTIUS (nominative) → TERTIUM (accusative), TERTIO (dative/ablative)
Note: In 2nd declension masculine, dative and ablative singular have the same form (-o).
Input: NUMERUSESTX
- Try to match keyword from start: No match
- Try to match variable: Check if NUMERUS is declared → Yes
- Consume NUMERUS
- Try to match keyword: EST → Match
- Consume EST
- Try to match Roman numeral: X → Match
- Consume X
- End of statement
Result: [VAR:NUMERUS, KW:EST, NUM:10]
- Symbol table: Maps variable names (nominative form) to integer values
- Declension table: Maps nominative forms to accusative/ablative forms
- Token stream: List of parsed tokens
- Program counter: For executing statements
tokenize(line)→ list of tokensparse_statement(tokens)→ AST nodeexecute_statement(ast_node)→ side effectsmain_loop()→ read lines, parse, execute
For the minimal implementation, errors should be simple:
- Unknown word: "ERRATUM: '[word]' non intellegitur" (word not understood)
- Undeclared variable: "ERRATUM: '[var]' non declaratur" (variable not declared)
- Invalid syntax: "ERRATUM: Syntax incorrecta" (incorrect syntax)
- Case mismatch: "ERRATUM: Casus grammaticus incorrectus" (wrong grammatical case)
The language has grown beyond the minimal spec and now includes:
- ✅ While loops (DUM)
- ✅ Functions with parameters and return values (FAC/REDDO)
- ✅ String literals and text output (using quotes)
- ✅ User input (LEGE)
- ✅ Multiplication and division (DUC/DIVIDE)
- ✅ String comparison operations
- ✅ ELSE clauses (ALITER)
- ✅ Comments (semicolons)
- ✅ Logging to stderr (AVDI/NOTA)
- ✅ Exception handling (IACE/CAPE with vocative case)
- ✅ Struct/object field access using genitive case
- ✅ String operations (starts with, ends with, contains, index)
- ✅ Automatic declension generation for new variables
For complete feature documentation, see README.md and FEATURES.md
- Write a lexer/tokenizer
- Build declension dictionary for common nouns
- Implement parser with AST generation
- Create interpreter that executes AST
- Add REPL (if feeling ambitious)