programming languages - What would be the steps needed to add new features to C? -


Suppose that I would like to create a new programming language by adding a new primitive datatype for C,

Boolean What will be needed to do this?

Edit : I'm not making myself very clear. I would like to prepare a new language, with the syntax being similar to C, but with a group of new primitive datatypes. This language needs c code and then I will use GCC to compile executable / object files.

In these comments, you say that your proposed language (I extension it for extended C Say) is a DSL for a narrow audience (your students), then you will need:

  • Type code to parse ExtC, to recognize that Which parts are pure and which parts are ext.
  • Write the C code generator which represents the translation in the ExCC.
  • Gather it in a pre-processor that reads ext-source files and writes C source files.
  • Write a compiler script (or program) that analyzes the logic and is running ext-c

Take a look as a possible source of ideas .

Look at IBM Informs ESQL / C (IBM Informix Client Available from IBM as part of SDK or CSDK); A script is 'SQL' that controls the compilation and pre-processor 'SKC' which actually parses the ASKL / C source and generates the relevant C code. Programmers run the 'esql' script to compile the ESQL / C program; They do not run the 'esqlc' program manually, unless they have an unusually distorted and suspicious streak.

Note that integration with one of the complicated parts of any DSL is Debugger, you can arrange your preprocessor to create ' #line ' instructions. , Which sometimes helps and sometimes interrupts (in my arsenal of scripts, I have one who excludes #line instructions; I use it when I am intermediate C code needs to be debug but then Also manages to refer back to the original source code.) You can see how the Lexus and yacc (and variants) handle it in their output, too. It is also a good idea that preprocessor has cleared the intermediate file (successful compilation) by default, but to provide an option so that the intermediate file can be kept available for inspection. Note that if your preprocessor does not guarantee that all output is valid - because it copies some parts of the input into the production without validating only as a compiler - you need to make sure that the user ( Programmers) can say that where the source error is still in the original file, even if the error is seen by the C-compiler instead of the ext-c compiler.

The IBM Informics 4GL programming language is a complete language that is fully compiled and linked to its primary compiler, which then generates (some more simplified) code, and a preprocessor / compiler i4glc1 To control a script is c4gl , and because I was over-simplifying, i4glc2 , i4glc3 and I4glc4 as well). If the generated C code fails to compile, then it indicates a bug in the I4GL compiler - this is not a user's fault.


Comments