MetaC - Embedded Software specific extensions for the C programming language

More Info
expand_more

Abstract

Embedded Software appears in a variaty of systems and products. The software for these systems have special requirements. Firstly, embedded software needs to be very robust as it is usually deeply tucked away and not very visible to the user. Secondly, embedded systems have dedicated hardware the software has to work on, and finally embedded systems can have real-time contraints. The C programming language is the most popular programming language for these kinds of systems and meets the requirements. Two disadvantages of C are that it is hard to create higher-level abstractions to solve the problem at hand of the programmer, and it is easier to create bugs compared to more modern languages. To solve these disadvantages we propose the MetaC language, which extends the C language with domain specific extensions tailored for embedded systems. The MetaC compiler compiles MetaC code, including the C language and the extensions, to C code. What extensions can be designed to be helpful for embedded software developers? MetaC implements the C language and adds the following extensions: 1) A bit-fields extension for declaring a bit-fields layout with names and use those names to manipulate the bits instead of using logical operators. 2) State machines to encode the state behavior of a system with new syntax and semantics. That makes it possible to generate state machine diagrams. 3) A concurrency extension for communication between concurrent processes with channels using CSP-style semantics. The extension can generate a model for the PAT model checker. 4) An error handling extension adding error handling constructs that are missing in the C language. Functions can return a new type that indicates the function can return an error. The type system forces programmers to handle the errors of those functions. The MetaC compiler is implemented using the Spoofax Language Workbench, which also provides an Integrated Development Environment (IDE) with common IDE features. The design goals are to implement the extensions in a modular way, to allow separate development of extensions, and to integrate into C as much as possible to give a C feel to the extensions. A BaseC module implements the C compiler while separate modules implement the extensions. The modules are composed into the final MetaC compiler. What are problems implementing MetaC with Spoofax? To reach the design goals several issues had to be solved implementing MetaC with Spoofax. These issues include determining the precedence of new expression operators, composition of scoping rules for new language constructs, and reusing existing name binding rules for new extensions.

Files

Thesis-arian-stolwijk.pdf
(pdf | 0.59 Mb)
License info not available