ComenC:Tutorial
From ClearSy Tools
(Redirected from Tutorial ComenC)
Contents |
Introduction
- This section of ComenC project will learn you theoric concept about the source-code organization, fast description of files, and all informations who can be useful for developers who want to work on those files.
- Note this section only shows theoric concept, illustrate & detailed with sources codes. If you want to see application examples of these functions, see examples section.
Source files organization
- In the source file directory ("/comenc/src"), you can see all source files of ComenC project. Programs language are for the most part in "Ada", and a few are written in "C language".
- We can sort the source files organization in those mains categories :
- B0 check
- Errors and checks
- B parser
- Semantic analysis
- Translation
- The others
B0 check
- The B0 check is the step where the program will check if there is some errors in the B program to translate. This step is needed before any B->C translation, in order to be sure the source code to traduce is correct.
Those files are used to make this step functional :
b0check.adb / b0check.ads b.cg / b.pars / b.scan
- "b0check" goal is to make print procedures for error messages, in case of b0 errors.
- "b" is used to verify the syntax of the b source, in function of B language specification.
Errors and checks
- Those files regroup all functions who have for goal to print specific errors message in function of encountered errors, for most part during B0 check step.
Files associated are :
checker_messages.adb / checker_messages.ads erreur.adb / erreur.ads errors.adb / errors.ads main_trad.adb
- "checker_messages" => Contains function, sorted by error number, who print in case of this number an error message for the program user. The function takes the version of the error received (V1, V2, ..., V23 at top), and will run his associated function.
- "erreur" contains variables setting for if certain type of errors were found.
- "errors" contains the list of all possibles errors during verification ("syntax error", "Warning", etc...) who can happen.
- The last file (main_trad.adb) contains some function call, and a verification if the function worked well or not. For case of a problem, an error message is print.
The rest of error messages are situated in the others files.
B parser
- The B parser is a long code, who has for goal to analyze the B source code, build BeTree, and use it in order to get ready to convert the source code into C language.
Files are :
parser.adb / parser.ads
Semantic analysis
- This step will make a semantic analysis of the B source file, and will return the conversion of type into C language. It's the beginning of the B->C conversion.
Source files are :
semantiques.adb / semantiques.ads / semantiques.puma semantiques2.adb / semantiques2.ads
- "semantiques" contains some under-functions who are used when making a semantic analysis. Those functions are regrouped here in order to make the program more organized.
- "semantiques2" contains function to analyze the source code and verify there is no semantic errors.
Translation
- This step, after execute some summary verifications and checks, will translate definitely The B source code into a correct C source code, who make the same function than the B code.
Files :
trad.adb / trad.ads / trad.puma / trad.with ctes.ads
Note that ctes.ads is a file without body, who contain some variables constants declared to be used by many functions
Those long source codes (trad) will only translate into C language the source code set in input. It will create .c and .h file(s), convert type from B to his C equivalent, and make link between functions.
The others
- For the rest, there is many files who are useful in divers functions, some under-function associated to some translation steps, etc...
Those files are :
base.adb / base.ads ctes.ads dependances.adb / dependances.ads eval1.adb / eval1.ads interfsyst.adb / interfsyst.ads pragmas.adb / pragmas.ads predef.adb / predef.ads scanner.adb / scanner.ads scanner_drv.adb source.adb / source.ads symb.adb / symb.ads / symb.cg tree.adb / tree.ads
- Most part of those files (.ads) are used in others function, and shared between them.
- "base" => This code will manage command line and components board of the project.
- "ctes" => This is a package (no body) which contains some variables, declarations & constants, who can be read for all Ada-PSC steps.
- "dependances" => This code manage the components board for future action with semantic/syntax analysis and for the translation, in order to make this in a specific order, depending of dependencies of source files.
This source code will be used with "base", the precedent code source who create this components board.
- "eval1" =>
- "interfsyst" => This contains the interface of system call 'system'. Used with "Pragmas" source files
- "pragmas" => Contains all functions who manage pragmas which are associated with any component.
- "predef" => Manage objects empty & B-PSC objects
- "scanner" => Will scan & stock into a board, sorted by type, all functions/types/variables in order to make the translation into C langage juste after.
- "source" =>
- "symb" => Those files, which don't contain functions, are used to stock in the symbols tables of B component. Those tables are used in order to see all symbol of the B langage, to make the translation.
- "tree" => Those source codes contain only various declarations in order to be used by several others functions in different source codes.