Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.

Overview

Everything here is taken from the slides for the "Compiler Construction" course, i.e. it is directly from Prof. Ronald C. Moore.

Or at least, after all this time, I really don't remember having stolen this code from somewhere else, but if you find an older copy that looks similar, please let me know, so I can give credit where credit is due -- or disavow knowledge of that source (as the case may be).

You are in the following subdirectory

  • interpret++
    This code take mathematical expressions and evaluates them, i.e. it outputs numbers. It is the same as its sister folder interpreter as far as recursive descent parsing goes, but uses more C++ features and is set up so as to support growing up to be a larger project.

See Chapter 1 Front End Construction, Slides 21 and 22 (and please let me know when the inevitable day comes that these slide numbers are no longer correct).

Building and Running

This version requires a C++17 compatible C++ compiler, such as newer versions of g++ or clang.

Build the program by running make.

In case of doubt, use the voodo command make clean and then repeat make.

To test the program, run make tests. This also illustrates how the intepreter is used.

Alternatively, just run the program with no parameters (i.e. simply ./intepret++). It will tell you how it wants to be run (Hint: there are two usages).

Contents (Manifest)

You should find here:

  • lexer.cpp and lexer.h
    Source code for the lexer.

  • parser.cpp and parser.h
    Source code for the recursive descent parser.

  • main.cpp
    Source code for main -- the driver.

  • Makefile
    Used to run make (obviously?).

  • tests
    A directory full of test cases. Run make tests (either in directory tests or the parent directory) to run the tests. Not unit tests, rather acceptance tests, but regression tests all the same.

  • README.md
    This file.

Ronald Moore
https://fbi.h-da.de/personen/ronald-moore/
ronald.moore@h-da.de

1 May 2020