How openttd/nml works
Main Components
a) Input Processing Layer:
• NML Source Files (.nml)
• Language Files (.lng)
• Graphics Files (.pcx)
• Sound Files (.wav)
• Custom Tags Files
b) Compiler Core:
• Parser Module
• Abstract Syntax Tree (AST)
• Expression Evaluator
• Action Generator
c) Output Generation Layer:
• GRF Encoder
• NFO Generator
• Optimization Engine
• Cache Manager
Component Relationships
[Input Files] → [Parser/Lexer] → [AST] → [Action Generator] → [Output Encoders] → [Final Output]
Specific Implementation Details
• nml/parser.py (Input parsing)
• nml/ast/* (Abstract Syntax Tree components)
• nml/actions/* (Game-specific action generation)
• nml/expression/* (Expression handling)
• nml/output_* (Different output formats)
Key Features to Highlight
a) Input Processing:
• Multiple file type support (nml, lng, pcx, wav)
• Custom tag processing
• Language file handling
b) Compilation Pipeline:
• Lexical analysis and parsing
• AST generation and manipulation
• Expression evaluation
• Action generation
c) Output Generation:
• GRF encoding with compression (lz77)
• NFO file generation
• Caching mechanism
• Multiple palette support
Additional Elements
Supporting components:
• Sprite cache system
• Language processing
• Error handling
• Optimization pipeline
Use the following symbols:
• Rectangles: Main processing modules
• Double lines: Primary data flow
Remember to show:
• Clear separation between compilation phases
• Data transformation flow
• Cache interaction points
• Optional processing paths (like optimization)
• Error handling paths
This will create a comprehensive visualization of NML's architecture that accurately represents its compiler nature while maintaining readability and technical accuracy.