How jallib/jalv2compiler works
JALV2 compiles a Pascal-like JAL program for Microchip PIC devices. The principal workflow is source tokenization and JAL parsing, construction and optimization of compiler state/commands, then PIC-specific code generation and output. The tree and README establish the compiler’s purpose and device-file requirement; sampled excerpts confirm parts of the intermediate representation and backend, but not the complete driver or all output wiring.
Main entry points: pfile.c Compiler state · jal_tokn.c Tokenization · pic.c PIC code generation · jal_main.c Compiler entry
Components 19
JAL frontend
- Compiler entry
src/jal/jal_main.c - Tokenization
src/jal/jal_tokn.c - Expression parsing
src/jal/jal_expr.c - Declarations
src/jal/jal_vdef.c - Procedure parsing
src/jal/jal_proc.c - Control parsing
src/jal/jal_ctrl.c - Includes and pragmas
src/jal/jal_incl.c
Compiler core
- Compiler state
src/libcore/pfile.c - Values and variables
src/libcore/variable.c - Command IR
src/libcore/cmd.c - Command optimization
src/libcore/cmd_optm.c
PIC backend
- PIC code generation
src/libpic12/pic.c - PIC operators
src/libpic12/pic_op.c - PIC built-ins
src/libpic12/pic_opfn.c - PIC device families
src/libpic12/pic12.c
Compiler output
- Assembly output
src/jal/jal_asm.c - COD metadata
src/libutils/cod_file.c
Other components
- Programmer
- JAL source
Connections 22
- Programmer → JAL source: writes
- Programmer → Compiler entry: invokes
- Compiler entry → Tokenization: parses input
- Tokenization → Expression parsing: supplies tokens
- Tokenization → Declarations: supplies tokens
- Tokenization → Procedure parsing: supplies tokens
- Tokenization → Control parsing: supplies tokens
- Tokenization → Includes and pragmas: supplies tokens
- Expression parsing → Compiler state: builds expressions
- Declarations → Compiler state: records declarations
- Procedure parsing → Compiler state: records procedures
- Control parsing → Compiler state: records blocks
- Includes and pragmas → Compiler state: updates settings
- Compiler state → Values and variables: manages values
- Compiler state → Command IR: records commands
- Command IR → Command optimization: optimizes
- PIC code generation → PIC operators: generates operations
- PIC code generation → PIC built-ins: generates built-ins
- PIC code generation → PIC device families: targets families
- Command optimization → PIC code generation: provides commands
- PIC code generation → Assembly output: emits assembly
- PIC code generation → COD metadata: writes metadata