Inhalt
Topic:.readme_CheaderParsing.
pStyle=std tableStyle=stdTable
Why CheaderParsing is used:
Headerfiles of the C or C++ programming language contain structural informations about data and maybe about calling possibilities (function prototypes, methods).
The data structures may be able to use in other contexts, at example:
Access to data from other tools, a description of data structures where need.
UML-representation of data
Access to the data from Java, contained in byte[]-arrays
Simple descriptions of data interface, able to generate from struct-infos.
The usage of that possibilities is shown in other examples of ZBNF too. This example is proper only for a simple test of the parser and the Header syntax.
The syntax of a header file:
It is contained in the file zbnfjax/zbnf/Cheader.zbnf. The syntax is checked with some headerfiles in praxis, but it may be considered not all variants yet.
There is a principal problem: A C-or C++-compiler runs at first the preprocessor, which includes some other files, regards conditional compiling and replaces macros with its defined values. This is a formal textual process, not a parsing process. That result is read from the compiler to parse. The here used ZBNF-parser takes the content of the header file immediately without preprocessing.
In the practice there were less problems with a lot of variants of headerfiles, at example generated from an UML-tool. But, if a user writes a complexly content, which uses special defines, a parsing process isn't able. Than a preprocessor of a C/C++-compiler should prepare the headerfile before parsing.
At the other hand the comment may contain some informations:
Documentation
Structuring of classes: combination of struct-definitions and function prototypes, which uses this structures, to build a class context in C-language.
Special Annotations in the comment.
The ZBNF-Parser is able to read informations from commentation. If a preprocessor runs, the comment is removed mostly. Therefore it isn't practical to use a standard preprocessor. But a special preprocessor, which preserves the comments, may be proper to use.
The example contains:
readme.html del_results.bat testCheader.bat example.h Object_Jc.h example.reference.xml Object_Jc.reference.xml
del_results.bat: helper to clean.
testCheader.bat: Windows-batch file to call both parsings only using ZBNF.
example.h: A test header file.
Object_Jc.h: A header file from practical use (see CRuntimeJavalike).
*.reference.xml: The results of the parsing process to compare: Test results with changed conditions should be compared with it.
If testCheader.bat is invoked, the following files should be created:
example.h.rpt example.xml Object_Jc.h.rpt Object_Jc.xml