Looking for a way to build a similar tree structure for a .Rs script of about 2000 lines
⚓ Rust 📅 2026-01-04 👤 surdeus 👁️ 4m6502.asm (BASIC M6502 8K VER 1.1)
│
├── 1. Feature Switches
│ │ ├── INTPRC = Integer array support
│ │ ├── ADDPRC = Additional precision support
│ │ ├── LNGERR = Long error messages
│ │ ├── TIME = Clock functionality
│ │ ├── EXTIO = External I/O
│ │ ├── DISKO = SAVE/LOAD commands
│ │ ├── NULCMD = "NULL" command
│ │ └── GETCMD = "GET" command
│ │
│ └── Memory Configuration
│ ├── CLMWID = Column width
│ ├── CLMWIDTH = Column width parameter
│ └── STRSIZ = String descriptor size
├── 2. Language Structure
│ ├── 2.1 Keyword Table (Crunch Table)
│ │ ├── Statement Keywords
│ │ │ ├── Basic Statements: DIM, READ, LET, GOTO, RUN
│ │ │ ├── Control Structures: IF, FOR, NEXT, GOSUB, RETURN
│ │ │ ├── Program Management: REM, STOP, ON, RESTORE
│ │ │ └── Conditional Compilation Statements: NULL, LOAD, SAVE, VERIFY
│ │ │
│ │ ├── Function Keywords
│ │ │ ├── DEF, FN, PRINT, INPUT
│ │ │ └── Conditional Compilation Functions: CMD, SYS, OPEN, CLOSE, GET
│ │ │
│ │ └── Special Markers
│ │ ├── TO, SPC, TAB, "(", "+"
│ │ └── Reserved Word Markers (MSB=1)
│ │
│ ├── 2.2 Statement Dispatch Table (STMDSP)
│ │ ├── END, FOR, NEXT, DATA
│ │ ├── INPUT, DIM, READ, LET
│ │ ├── GOTO, RUN, IF, RESTORE
│ │ ├── GOSUB, RETURN, REM, STOP
│ │ └── ON GOTO, NULL, WAIT, LOAD/SAVE/VERIFY
│ │
│ └── 2.3 Function Dispatch Table (FUNDSP)
│ ├── Single-Parameter Functions: SIN, COS, TAN, ATN, EXP, LOG
│ ├── Dual-Parameter Functions: ATN2
│ └── Constant Functions: PI
├── 3. Runtime Environment
│ ├── 3.1 Variable Management
│ │ ├── PTRGET - Variable pointer acquisition
│ │ ├── PTRGT1 - Variable pointer acquisition (internal)
│ │ ├── DIM - Array allocation
│ │ └── Variable storage structure (6 bytes/variable)
│ │ ├── Simple variables: 2-byte name, 4-byte value
│ │ └── Array variables: 2-byte name, 2-byte length, dimension information
│ │
│ ├── 3.2 Expression Evaluation (FRMEVL)
│ │ ├── Lexical Analysis (EVAL)
│ │ │ ├── Numeric constant parsing
│ │ │ ├── Variable identification
│ │ │ ├── Function calls
│ │ │ └── Operator recognition
│ │ │
│ │ ├── Operator Precedence Handling
│ │ │ ├── 0: Parentheses
│ │ │ ├── 10: Unary operators
│ │ │ ├── 20: Multiplication/division
│ │ │ └── 30: Addition/subtraction
│ │ │
│ │ └── Recursive Evaluation Algorithm
│ │ ├── Step 0: Stack initialization
│ │ ├── Step 1: Token reading
│ │ ├── Step 2: Operator precedence comparison
│ │ └── Step 3: Calculation and result return
│ │
│ ├── 3.3 Program Control
│ │ ├── GOTO/GOSUB/RETURN
│ │ │ ├── Stack structure: TOKEN(1B), variable pointer(2B), text pointer(2B)
│ │ │ └── RETURN: Restore execution point from stack
│ │ │
│ │ ├── FOR/NEXT Loops
│ │ │ ├── Stack structure: FORTK(1B), variable pointer(2B), end value(5B), step value(5B), text pointer(2B)
│ │ │ └── NEXT: Check loop variable and jump
│ │ │
│ │ └── IF Statements
│ │ ├── Condition expression evaluation
│ │ └── Jump when condition satisfied
│ │
│ └── 3.4 Data Processing
│ ├── DATA Statements - Data storage
│ ├── READ Statements - Data retrieval
│ └── RESTORE Statements - Data pointer reset
├── 4. Math Engine
│ ├── 4.1 Floating-Point Format
│ │ ├── Sign bit: FACSGN
│ │ ├── Exponent: FACEXP (offset 128)
│ │ └── Mantissa: 3/4 byte (FACMO, FACLO, [FACMOH])
│ │
│ ├── 4.2 Basic Operations
│ │ ├── FADD - Floating-point addition
│ │ ├── FSUB - Floating-point subtraction
│ │ ├── FMULT - Floating-point multiplication
│ │ └── FDIV - Floating-point division
│ │ ├── Condition checks: Division by zero error
│ │ └── Exponent adjustment and mantissa calculation
│ │
│ ├── 4.3 Exponential Function (EXP)
│ │ ├── Constant Table (EXPCON)
│ │ │ ├── 11th-order polynomial coefficients
│ │ │ └── Additional precision coefficients (ADDPRC)
│ │ │
│ │ └── Algorithm Flow
│ │ ├── Conversion to base-2 logarithm
│ │ ├── Exponent scaling
│ │ └── Polynomial approximation calculation
│ │
│ ├── 4.4 Logarithmic Function (LOG)
│ │ ├── Constant Table (LOGCN2)
│ │ │ ├── 12th-order polynomial coefficients
│ │ │ └── Additional precision coefficients (ADDPRC)
│ │ │
│ │ └── Algorithm Flow
│ │ ├── Decomposition to LN(2)×LOG₂(F×2ᴺ)
│ │ └── Polynomial approximation calculation
│ │
│ ├── 4.5 Trigonometric Functions
│ │ ├── SIN/COS (SINCON)
│ │ │ ├── Constant Table (SINCON)
│ │ │ └── Polynomial approximation
│ │ │
│ │ ├── TAN - Calculated via SIN/COS
│ │ └── ATN - Arctangent function
│ │
│ └── 4.6 Other Mathematical Functions
│ ├── SQR - Square root (X^0.5)
│ └── FPWRT - Power operation (X^Y)
│ ├── Special case handling (Y=0, X=0)
│ └── EXP and LOG-based calculation
├── 5. String & Memory Management
│ ├── 5.1 String Storage
│ │ ├── String descriptor (3 bytes)
│ │ │ ├── Length (1 byte)
│ │ │ └── Pointer (2 bytes)
│ │ │
│ │ └── String space management
│ │ ├── String space at top of memory
│ │ ├── Grows downward
│ │ └── [FRETOP] tracks usage
│ │
│ ├── 5.2 String Processing
│ │ ├── GETSPA - Acquire string space
│ │ │ ├── Check sufficient space
│ │ │ └── Trigger garbage collection if needed
│ │ │
│ │ ├── GARBAG - Garbage collection
│ │ │ ├── Mark active strings
│ │ │ └── Compact string space
│ │ │
│ │ └── String operations
│ │ ├── String concatenation (+)
│ │ ├── CHR$ - Create single-character string
│ │ └── STR$ - Numeric to string conversion
│ │
│ ├── 5.3 String Temporary Variables
│ │ ├── DSCTMP - Temporary descriptor
│ │ ├── PUTNEW - Create new temporary variable
│ │ └── FRETMP - Release temporary variable
│ │ └── FIFO order management
│ │
│ └── 5.4 Memory Management Principles
│ ├── Variable storage: Low address → High address
│ ├── String space: High address → Low address
│ ├── Free space between them
│ └── Garbage collection triggers
│ ├── GETSPA space insufficient
│ └── String operations require space
├── 6. I/O & Error Handling
├── 6.1 I/O System
│ ├── INCHR - Character input
│ │ ├── Platform-specific implementation
│ │ └── Conditional compilation adaptation
│ │
│ ├── OUTDO - Character output
│ │ ├── Platform-specific implementation
│ │ └── Conditional compilation adaptation
│ │
│ ├── CRDO - Carriage return/line feed
│ └── STROUT - String output
│
├── 6.2 Output Formatting
│ ├── FOUT - Floating-point formatting
│ │ ├── Decimal point handling
│ │ ├── Exponential notation
│ │ └── Rounding
│ │
│ └── PRINT Statement Processing
│ ├── Expression evaluation
│ ├── Formatted output
│ └── Column alignment (TAB, SPC)
│
└── 6.3 Error Handling
├── Error Messages
│ ├── ERROM: "OUT OF MEMORY"
│ ├── ERRUS: "UNDEF'D STATEMENT"
│ ├── ERRBS: "BAD SUBSCRIPT"
│ ├── ERRDD: "REDIM'D ARRAY"
│ ├── ERRDV0: "DIVISION BY ZERO"
│ ├── ERRID: "ILLEGAL DIRECT"
│ ├── ERRTM: "TYPE MISMATCH"
│ ├── ERRLS: "STRING TOO LONG"
│ ├── ERRST: "FORMULA TOO COMPLEX"
│ ├── ERRCN: "CAN'T CONTINUE"
│ └── ERRUF: "UNDEF'D FUNCTION"
│
└── Error Handling Flow
├── Error detection
├── Error message selection
├── Current line number display
└── Execution halt or continuation
I'm looking for a way to build a similar tree structure for a .Rs script of about 2000 lines. Syn's ASH has 370,000 lines, and RustC's Hir-tree has nearly more then 60,000 lines, which seems impractical. Do you have any suggestions?
1 post - 1 participant
🏷️ Rust_feed