## oop-syntax-parser-transform.api
# Compiled by:
#
src/lib/compiler/front/parser/parser.sublib# Mythryl treats OOP (object-oriented programming) constructs
# as "derived forms", expanding them into vanilla non-OOP
# syntax at the raw syntax stage of code compilation.
#
# Logically, the Mythryl compiler has four phases dealing with
# raw syntax:
#
# 1) Parse phase, during which all source files in a library
# are read from disk source files and converted into
# raw syntax parsetrees.
#
# 2) Dependency extraction phase, during which the parsetrees
# are analysed to extract inter-file dependencies, such as
# a function in one file calling a function in another.
#
# 3) Sort phase, during which the source files in the library
# are topologically sorted according to dependencies, so
# that we can compile each file only after all files it
# depends upon have been compiled, thus making full type
# information from them available.
#
# 4) Compile phase, during which raw syntax parsetrees from
# phase (1) are compiled in topological sort order to produce
# actual native code.
#
# The majority of our OOP syntax expansion is done in phase (4)
# during typechecking, because it requires access to type information
# from superclasses. The code for this may be found in
#
#
src/lib/compiler/front/typer/main/expand-oop-syntax.pkg#
# However, the above code synthesis generates references to two
# OOP support libraries:
#
#
src/lib/src/oop.pkg#
src/lib/src/object.pkg#
# It is essential that these dependencies be made known to phases (2)
# and (3) above, so that these libraries will be compiled and available
# during code synthesis in phase (4).
#
# That is our job here: We get called from the 'named_classes' rule in
#
# src/lib/compiler/front/parser/yacc/mythryl.grammar
#
# and we add statements like "package dummy__oop__ref = oop;"
# to the raw syntax for the class to establish the required
# dependencies.
api Oop_Syntax_Parser_Transform {
prepend_dummy_package_references_to_declaration
:
raw_syntax::Declaration -> raw_syntax::Declaration;
};