-
Notifications
You must be signed in to change notification settings - Fork 0
Liberty compiler design notes
This document is by no means an exhaustive “detailed design document”. I don’t believe in those; they are bound not to be up-to-date.
On the other hand one needs a few architecture and general design notes to understand how the Liberty compiler is built. For details… read the code.
The Liberty parser uses a general parsing library. Note that the LIberty Eiffel grammar belongs to the library, so anyone may build parsers using the exact Liberty language definition.
The nodes produced by the parser are “AST” nodes (Abstract Syntactic Tree). Those nodes may be found in the src/tools/syntax/tree cluster.
The root node of an AST is a class.
It is the most important tree. The root node of a semantics tree is LIBERTY_TYPE
, which represents a type of the system.
Note the difference between “syntax” and “semantics”:
- the “syntax” trees represent classes, i.e. a syntactic representation of one or more types (think generics here)
- the “semantics” tree represent types, with actual generic parameters, and a set of features correctly (re)named, (re)exported, and (re/un)defined.
The semantics nodes are in the src/tools/semantics cluster and sub-clusters:
- contract contains the pre- and post-conditions, invariants, and so on
-
entities contains all the kinds of named entities which conform to
LIBERTY_ENTITY
-
expressions contains all the kinds of expressions which conform to
LIBERTY_EXPRESSION
-
features contains all the kinds of features which conform to
LIBERTY_FEATURE
: attributes, constants, deferred, do-, and once-functions -
instructions contains all the kinds of instructions which conform to
LIBERTY_INSTRUCTION
The class LIBERTY_TYPE_BUILDER
is in charge of building a LIBERTY_TYPE
from a LIBERTY_AST_CLASS
and a set of LIBERTY_TYPE
representing the actual generic parameters.
The class LIBERTY_UNIVERSE
is in charge of holding all the instances of LIBERTY_TYPE
.