Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Subset of C++

EAIWatchdogEAIWatchdog Member Posts: 1
[color=Black]
My company is developing a "C" based microcontroller system using an ARM for a specific application, as well as a general purpose embedded controller. We are using the Windows XP based Keil tools and we have an embedded expert using Keil tools to develop the architecture and API's within the ARM space.

Here is the issue:
We plan to to sell the general purpose controller system to the general public. We could do so with the Keil compiler if we could trust customers to program the controller's I/O's, A/D's and serial ports using the API's only. One could get into much trouble with pointers and built-in timer calls etc.. as they could crash the system. We are using an RTOS.

A potential solution:
What I need is a Mini-C pre compiler that will restrict the user to the API, logical, and arithmetic functions only in "C". I still need debugging features. Output of the compiler would be a .c file or equivalent to be compiled in the background using the Keil compiler. Where could I find such a pre-compiler or developer? Could the GNU compiler be modified? We do not want to develop a compiler from scratch. Am I crazy? Russ[/color]

Comments

  • JonathanJonathan Member Posts: 2,914
    : [color=Black]
    : ...
    :
    : A potential solution:
    : What I need is a Mini-C pre compiler that will restrict the user to
    : the API, logical, and arithmetic functions only in "C". I still need
    : debugging features. Output of the compiler would be a .c file or
    : equivalent to be compiled in the background using the Keil compiler.
    : Where could I find such a pre-compiler or developer? Could the GNU
    : compiler be modified? We do not want to develop a compiler from
    : scratch. Am I crazy?[/color]
    :
    No, I don't think you're crazy - this sounds like quite a sane solution. It's quite easy to get a parser defined and working using, say, lex and yacc. You could even take the C grammar and use that as a starting point, but remove the pointer syntax you do not want to allow. After parsing it, you can build some very basic tree like data structure, do any analysis on it you need to, then code-generate...apart from you generate C. In the generated C file you can use #line and #file directives to point to the original source file. Then you use the C compiler to generate the code.

    Note that if you're not going to have pointers you might want to consider how you're going to allow people to build data structures, since that's basically how it's done in C. So you'd need to have some kind of safe references perhaps. You could even bolt on a garbage collector, but that's getting you some way from C.

    Sounds like a good, fun project!

    Hope this helps,

    Jonathan
    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
Sign In or Register to comment.