GithubHelp home page GithubHelp logo

compiler's Introduction

The project directory is structured as follows:

        ./bin       Compiled executables
        ./build     Temporary directory for object files and the like
        ./include   Headers
        ./lib       Object archives for easier dependency management
                    and library modularity
        ./src       Library source code
        ./test      Contains test input files and scripts for testing
                    component-drivers against those files

The available make targets are:

        all               Builds all library and driver binaries
        clean             Removes binary and object files

        mcc               Builds the main executable

        text_processing   Builds the text processing library
        tokenizer         Builds the tokenization library (depends
                          on the text processing library)
        ast               Builds the abstract syntax tree library

        testall           Runs all available top-level tests
        test-scanner      Runs the test script for the scanner
        test-parser       Runs the test script for the parser
        test-semantic     Runs the test script for the semantic
                          analyser

Additional arguments may be passed to the compiler by setting the
CXXFLAGS environment variable.

The main executable takes as its first argument the name of the file
to be compiled; '-' may be given as the first argument to indicate
that input should be read from STDIN. Additionally, '-Tscanner' may
be passed as the second argument to print output from the scanner
stage, terminating before the parsing stage.

The grammar matched by this program is slightly modified, allowing
lists to be represented as true lists, rather than recursively along
the tree. The grammar also adds support for declaring undefined
functions for linking against C, as well as the '...' notation for
variable arguments This grammar is specified in the file 'GRAMMAR'.
The parser does do minimal semantic checking, as it constructs the
symbol tables during parsing. Passing the '-Tparser' argument causes
the program to output the syntax tree as a tree of nested
s-expressions of the form:

        (production-rule &rest components)

The semantic analysis component of the program, which may be tested
by passing the '-Tsemantic' argument, performs the following checks:

        - Type checking in assignments
        - Conditional expressions of type 'void'
        - Return types (including 'return;' in non-void functions)
        - Undefined variables and functions
        - Multiple declarations of variables and functions (defining
          a forward-declared function is a multiple declaration)
        - Array bounds access (single-factor literals only; 'int' and
          'char' literals both allowed)
        - Array subscript type checking
        - Arithmetic comparison of non-integral types
        - General type promotion from 'char' to 'int'
        - Function argument checking: both number and type (no type
          promotion)

The code generator performs constant folding. Recursion is supported,
Global variables, arrays, and functions with more than four arguments
are as of yet only partially implemented. Both int and char datatypes
are supported, as are all relational operators. Variable arguments are
supported in function declarations, but no facility is provided to
access the extra arguments. Using the GNU toolchain, the assembly
produced by the compiler may be linked with C, provided the
appropriate forward declarations are made. The following function is
predeclared in the compiler source, and implemented in C:

        int output (int n);

It prints the provided integer to stdout, followed by a newline. To
use this function, code must be linked against output.o in bin/lib.
The compiler outputs generated assembly to stdout. This assembly is
compatible, and intended to be used, with GCC on Linux-MIPS. The code
generated by the compiler is PIC-safe.

Testing may be performed through make, or
'test/[component]/run_tests.bash' may be invoked directly The test
script may be run in verbose mode (via -v), displaying the
component's output as normal.

Building this project requires a mostly C++11-compliant compiler and
standard library. At this point, no third-party libraries are in use.
The project compiles successfully under GCC/libstdc++ 4.6.3,
accessible at athena.cs.txstate.edu.

The source tree is described in 'ABOUT'.

compiler's People

Watchers

James Cloos avatar Stuart Olsen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.