|
File Structure.html
Author McKeeman
Copyright © 2007
index
Structure of the xcom Compiler
Components
Compilers, generally speaking, divide into a front-end, back-end and
runtime.
An intermediate representation (IR) is passed from the front-end
to the back-end. In xcom all these algorithms are
imbedded in objects.
Each object, once constructed, holds the information it has gathered.
Each such object is passed to any other object needing the contained
information.
Each object provides its information either by public fields or a public
access methods.
Analysis
- Cfg object -- read the context-free grammar
for the input language and build tables.
- Lexer object -- build a lexeme sequence
from the source program.
- Parser object -- select the meaningful lexemes and
construct a shift/reduce sequence.
- Tree object -- build tree
from the shift/reduce sequence.
- Symbols object -- walk the tree to build
a symbol table pairing names to attributes.
Synthesis
- Generator object --
pass information from one part of the IR to another
and detemine the execution sequence.
- Emitter object -- choose the instructions.
- Assembler object --
assemble, format the executable, and launch the user program.
Runtime
- getCfun.c -- implement builtin functions, link X-to-X calls.
- runX86.c -- execute compiled user programs,
report runtime errors.
| |