main 9.0
No Matches
alc parser

Add an attribute to the function defined in the header-file


The __parser__ is an important part of the alc-compiler and is an extension to the c-programming-language.

‍The goal of parser-technology is to add one or more attribute to the global or function definition.

The parser-technology is a part of the alc-compiler.

‍The goal of the alc-compiler is to create a open compiler-tool easy to extend with an additional feature.

simple example

This is an example from the kernel_mk.h file and define the BufferLog slot of the MkBufferC class.

MK_EXTERN void MK_DECL MkBufferLog (
MK_BUFN const buf,
MK_OBJN fmtobj __parser__(default=NULL),
MK_DBG const debug __parser__(default=0),
MK_STRN const callfunc __parser__(default=F#FUNC),
MK_INT const lvl __parser__(default=0)
signed int MK_INT
int MK_DBG
#define __parser__(...)
1. map to class MkBufferC
The prefix MkBuffer together with the first parameter MK_BUFN indicate the class MkBufferC.
If the indication is not possible the __parser__ attribute "class=MkBufferC" force the indication
2. analyse the function-attribute
The function-attributes const,flags=new define two attributes separated by ",". The first attribute const is a boolean-attribute and the second attribute flags=new is a value-attribute.
3. analyse the arguments-attribute(s)
The first argument buf is the class-hdl. All other arguments have a default-value defined with the default=VALUE attribute.
4. __parser__ and attribute documentation
The usage of the __parser__ extension und the already defined parser-attribute are documented at the PARSER API

meta file

The meta-file is the result of alc-compiler-parser using the c-meta-file as input.

The syntax of the meta-file

The meta file is text file with # as comment-character and multiple sections like:
  • somethingDEF arg1 arg2 arg3 ...
section documentation
headerDEF global definition like input-library, api-header etc
attributeDEF attribute database, result of the __parser__ extension
packageDEF definition of the package
nameDEF definition of all names used in the meta-file
typeDEF detail definition of all types used in the meta-file
ignoreDEF definition of all names not used in the meta-file
enumDEF detail definition of all enum used in the meta-file
classDEF detail definition of all class used in the meta-file
fupuDEF detail definition of all function-pointer used in the meta-file
funcDEF detail definition of all functions used in the meta-file


The attributeDEF is modified by the __parser__ extension and is defined at

The syntax of the attributeDEF
attributeDEF function,attribute yes // boolean attribute
attributeDEF function,attribute value // value attribute
attributeDEF function,argument,attribute value // function argument value attribute
attributeDEF attribute,arg1,arg2 value // global value attribute with 2 additional args

To access the boolean-attribute "myattr" the following workflow is used:

1. add the "myattr" attribute to a function
__parser__(myattr) // add the "myattr" attribute to function "someFunc"
void someFunc (void) {
2. in the meta-file the attributeDEF is created
attributeDEF someFunc,myattr yes
3. in the backend-meta-file-loader (tcl) the attributeDEF is mapped to ATTRIBUTES
set ATTRIBUTES(someFunc,myattr) yes
4. in the backed-tool-library (tcl) the attribute-access-proc is defined
proc tcl::mathfunc::myattrExists { func } {
info exists ::ATTRIBUTES($func,myattr)
5. in the backed-tool (tcl) the loop over all functions can act on the "myattr" attribute
# pseudo code
foreach name $allfunctions {
if {myattrExists($name)} {
... do something