Section D) rtfm-coore compiler

This section we cover
D.1) the -coore compiler options
D.2) an overview of the -coore compiler design
D.3) compiler implementation.

D.1) Compiler options:

The -coore compiler has the following options:

The RTFM-coore compiler v1.0, Per Lindgren (c) 2014

Usage rtfm-coore [-v] [-D] [-d_ast] [-o outfile.core] [-i] infile.coore

Options summary:
  -i            : infile.coore
  -o            : outfile (default <infile>.core)
  -gv_obj       : graphviz file (default none)
  -v            : verbose mode
  -D            : debug mode
  -d_ast        : dump AST
  -help         Display this list of options
  --help        Display this list of options

Recognized source file:
.coore           RTFM-core source infile (root)

Output C file:
-o outfile.core  Compiler output (defaults to <infile>.core)

General options:
-v               Enable : Verbose compiltion (default disbaled)
-D               Enable : Generate output for debugging (default disbaled)

Additional options:
-gv_obj file.gv  Enable : Object structure in gv format (default disabled)
-d_ast           Enable : Dump internal AST (default disabled)

All file paths are relative to the current directory
For further documentation see

All file paths are relative to the current directory.

See section E) for compiling C-code output for run-time execution.

D.2) Compiler design

The rtfm-coore compiler performs the following steps:
  1. Lexing and parsing of the input program to an internal AST representation. Single line and nested comments are taken care of in the lexer. (Much of the lexing is the same as for the -core compiler and will in the future be refactored into the common directory.)
  2. Static object instantiation and specialisation to -core constructs.
  3. (Optional for Graphviz output) gv_obj gives a simple view over the object instances

D.3) Compiler implementation:

File by file:
    • defines the AST for parsing -core programs
    • provides pretty printing for the AST constructs
    • defines some common (to -core and -coore) data structures and functions
    • specialization and code generation to -core
    • parsing of command line input
    • provides .gv output for object instances (will be renamed to
    • defines lookup functions
    • defines error handling for the lexer (and parser)
  • Lexer.mll
    • ocamllex lexer used in combination with Menhir
    • the main file
    • defines the compiler options and default values
  • Parser.mly
    • grammar for parser generation using Menhir

Word form the author:

The -coore compiler together with supporting tools have been designed and implemented from scratch during a 3 month period (June,-August 2014).

The intention was to demonstrate the basic design and principles for an OO language allowing for full specialisation. Expressions and statements are kept to a bare minimum to serve this purpose. Students in Compiler COnstruction at LTU will during the fall of 2014 be given the -coore (and -core) compiler as an outset and study material. The intention is for them to add:
  • type checking/well formedness checking
  • operations for primtive types and arrays
  • conditional statements
  • passing of task and object references as actual parameters
  • single inhertiance with circualr dependency rejection

With this in place, and the addition of binding to external functions, should make -cOOre a useful language, not only to as a proof of concept but also capable to demonstrate real applications developed in RTFM.

/Per Lindgren, founder of RTFM-lang August 2014.

Last edited Aug 31, 2014 at 11:01 PM by RTFMPerLindgren, version 4