theCompiler 10.0
NHI1 -
theKernel -
theLink -
theConfig -
theSq3Lite -
theCompiler -
theBrain -
theGuard
|
Associate an attribute with an C-object defined in the META-HEADER …
The goal of the parser-extension is to associate an ATTRIBUTE with an existing META-HEADER in order to connect a C-library with a Target-Programming-Language (TPL).
The external-header-file is the source of the API information and the goal of the Programming-Language-Micro-Kernel (PLMK) in conjunction with the All-Language-Compiler (ALC) is to use this file to provide language binding for a variety of languages.
If an external-header-file cannot be changed, it is a good idea to call this file via a wrapper and then add the changes using __parser__global__(...)
.
The meta-parser is a C compliant extension to the C programming language to associate an attribute with an C-object-definition (e.g. function, struct, enum, argument etc.)
The meta-compiler is the tool to generate the meta-file from the meta-header and the meta-parser.
The meta-file is the text-based database with TCL syntax in which all attributes that define a library are stored and which is generated by the All-Language-Compiler (ALC) frontend and used by the All-Language-Compiler (ALC) backend.
The meta-library is created by the meta-compiler and is a meta-code-wrapper of the native-library.
The native-meta-library is the link between the meta-library and the TPL, with the connection being established via the MOT.
meta-code-external-header-file (META-HEADER)
The external-header-file is the source of the API information and the goal of the Programming-Language-Micro-Kernel (PLMK) in conjunction with the All-Language-Compiler (ALC) is to use this file to provide language binding for a variety of languages.
The meta-header is divided into two variants :
meta-code-header-wrapper-file (META-WRAPPER)
If an external-header-file cannot be changed, it is a good idea to call this file via a wrapper and then add the changes using __parser__global__(...)
.
The default-value of a function argument is not defined in C because the C language does not support an argument-default-value.
Two scenarios need to be distinguished:
someLib.h
meta_someLib.h
meta-code-library-definition-file (META-FILE)
The meta-file is the text-based database with TCL syntax in which all attributes that define a library are stored and which is generated by the All-Language-Compiler (ALC) frontend and used by the All-Language-Compiler (ALC) backend.
The meta-file is …
The encoding of the meta-file is defined as :
The syntax of the meta-file is defined as :
namespace eval meta_writer { ## ## ME_(PCANRVE) FIRST: P=pointer, C=class, A=array, N=Native, R=reference, V=vararg, E(NE)=enum ## ## ME_P* The "pointer" data type ## ME_P(VSBLFECA) V=void, S=string, B=binary, L=list, F=format, E=exception, C=constructor, A=callback ## ME_P.(BNX) B=basicType, N=const, X=unrecognized ## array set typeDoc { me-name {short-name definition description} ... } ## ## ME_C* The "class" data type ## ME_C(CX) C=class, X=special ## ME_C.(CN) C=class, N=const ## array set typeDoc { ... } ## ## ME_A* The "array" data type ## ME_A(SCX) S=string, C=class, X=unrecognized ## ME_A.(NX) N=const, X=unrecognized ## array set typeDoc { ... } ## ## ME_N* The "native" data type ## ME_N(BIF) B=bool, I=integer, U=Unsigned, F=float ## ME_N.(#XL) #=#bytes, X=longlong, L=long ## array set typeDoc { ... } ## ## ME_R* The "reference" data type ## ME_R(SCU) S=string, C=class, U=union ## ME_R.(NA~) S=string, A=unrecognized, ~=unrecognized array set typeDoc { ... } ## ## ME_V* The "variable argument list" data type ## ME_V(ACL) A=..., C=string, L=va_list ## ME_V.(NV) N=const, V=unrecognized ## array set typeDoc { ... } ## ## additional modifer definition : ## ## %S = struct, %U = union, %E = enum, %G = unsigned, %N/M = const, %P = ptr ## } # library definition headerDEF library value headerDEF header value headerDEF doc-force value headerDEF doc-db value ... headerDEF §END§ # attribute for function, function pointer, class and enum attributeDEF attribute value ... attributeDEF §END§ # package definition packageDEF default Value packageDEF §END§ # used names definition nameDEF name TYP/DEF definition extra ... nameDEF §END§ # types definition typeDEF type me-name definition extra ... typeDEF §END§ # ignored names definition ignoreDEF name 1 ... ignoreDEF §END§ # enum definition enumDEF enum vals ... enumDEF §END§ # class definition classDEF class me-name short-name ... classDEF §END§ # function pointer definition fupuDEF fupu return args ... fupuDEF §END§ # function definition funcDEF func return args ... funcDEF §END§
The attributeDEF
is part of the META-FILE and is created by the META-COMPILER using the META-PARSER.
The syntax of the attributeDEF
is defined as :
To access the boolean-attribute "myattr" the following workflow is used:
meta-code-compiler (META-COMPILER)
The meta-compiler is the tool to generate the meta-file from the meta-header and the meta-parser.
The default meta-compiler tool is called c_meta.tcl
and read the META-HEADER and the META-WRAPPER to create the META-FILE.
The meta-compiler has three main components:
In addition to the default meta-compiler, there are also a Target-Programming-Language (TPL) specific meta-compiler (LNG_meta.tcl
) whose task is to convert the META-FILE into a language-specific META-FILE (API transformation) in order to simplify the logic in the All-Language-Compiler (ALC) backend tool(s).
meta-code-library (META-LIBRARY)
The meta-library is created by the meta-compiler and is a meta-code-wrapper of the native-library.
The native-meta-library is the link between the meta-library and the TPL, with the connection being established via the MOT.
theConfig/c
:c_Class.tcl
) and used by the All-Language-Compiler (ALC). // Index-Tool .indexignore // files ignored .index.mk // file created .makefile_index.bash // configuration tags // file created // Label-Tool .label.h // template for *.h files .labelignore // files ignored .label_inc.tcl // configration // Shortcut-Tool .shortcut // created "vim" navigation shortcuts .shortcutignore // files ignored // ALC compiler compiler.mk // configuration of the makefile compiler.tcl // configuration of the compiler Makefile.am // makefile // package LcConfig LibLcConfig_lc.c // code … LibLcConfig_lc.h // LcEnum_lc.h // enum definition (part of the package) private_lc.h // private definitions // meta code wrapper config_lc.h // configuration debug_lc.h // debugging LcConfigC_def_lc.h // class LcConfigC LcConfigC_lc.c LcConfigC_lc.h LcSettingC_def_lc.h // class LcSettingC LcSettingC_lc.c LcSettingC_lc.h // libconfig documentation libconfig.texi // texinfo documentation file libconfig_2_docdb.tcl // texinfo documentation parser -> documentation database gen/doc_db.dir // documentation database gen // directory for generated code nat_lcconfig.meta // native-meta-file nat_lcconfig.index c_lcconfig.meta // c-meta-file c_lcconfig.index config_inline_lc.c // c-meta-library inline2function code config_inline_lc.h config_overload_lc.h // c-meta-library function-overload code (default, runtime, error etc) LcConfigC_lc.doc // library documentation LcSettingC_lc.doc LibLcConfig_lc.doc tmpl // directory for "pattern" code lc_misc_check_lng.h // generic class check code lc_type_S_macros.h // generic type check code tests // directory for tests
theConfig/py
:The C makefile : theConfig/c/Makefile.am and the libconfig header : theConfig/c/libconfig.h and the meta-wrapper : theConfig/c/config_lc.h and the meta-compiler : theCompiler/src/c_Meta.tcl → create the nat-meta-file : theConfig/c/gen/nat_lcconfig.meta → create the meta-file : theConfig/c/gen/c_lcconfig.meta The C makefile : theConfig/c/Makefile.am and the native-library : ext/x86_64-suse-linux-gnu/debug/lib64/libconfig.la and the ALC native-backend : theCompiler/src/c_Native*.tcl and the nat-meta-file : theConfig/c/gen/nat_lcconfig.meta and the C source files : theConfig/c/*Lc*_lc.c/h and the gcc compiler : gcc-13 → create the meta-library : build/x86_64-suse-linux-gnu/debug/theConfig/c/liblcconfig.la The python makefile : theConfig/py/Makefile.am and the meta-library : build/x86_64-suse-linux-gnu/debug/theConfig/c/liblcconfig.la and the python-backend : theCompiler/src/py_XYZ.tcl and the meta-file : theConfig/c/gen/c_lcconfig.meta and the python source files : theConfig/py/*Lc*_py.c/h and the gcc compiler : gcc-13 → create the TPL library : build/x86_64-suse-linux-gnu/debug/theConfig/py/pylcconfig.la
meta-code-parser-extension (META-PARSER)
The meta-parser is a C compliant extension to the C programming language to associate an attribute with an C-object-definition (e.g. function, struct, enum, argument etc.)
The meta-parser uses the C-preprocessor-macro to modify a given C-header-file without changing the C syntax.
__parser__
and are inactive during C compilation with #define __parser__xyz(...)
. __has_parser__
has been defined.The technology behind it is simple.
__has_parser__
to compile the C-header-file, with the result then being a simplified form of the original C-header-file. __parser__xyz
being read and processed.The meta-parser-extension is defined as :
The parser-code-extension is …
The c-code-extension is …
The c-preprocessor-extension is …
__parser__???(…)
and evaluate to nothing if the source is compiled without the __has_parser__
compile flag defined. c_meta.tcl
if the c-preprocessor flag __has_parser__
is set.parser: add an local attribute …
The local-code-extension is related to the local-attribute :
The __parser__
feature is defined at : META-PARSER and META-FILE
The following __parser__
definitions are supported :
yes
by default.myfunc( type1 arg1 __parser__(internal), ...)
myfunc( type1 arg1 __parser__(internal=yes), ...)
__parser__global__
if the object is added in front:__parser__(alias=XYZ) myfunc(...)
__parser__global__(myfunc:alias=XYZ);
__parser__global__
definition:__parser__global__define__(pattern2prefix:PATTERN=PREFIX);
";"
character like normal C code._parser__global__(prefix2class:MkRuntime=MkRuntimeC);
","
character as seperator.myfunc( type1 arg1 __parser__(internal=yes,default=NULL), ...)
":"
character to support a path-like depth._parser__global__(prefix2class:MkRuntime=MkRuntimeC);
"@"
character.__parser__(library=Sq3Lite@native@Sq3@SqLite3)
parser: add an global attribute …
The global-code-extension is related to the global-attribute :
The __parser__global__
feature is defined at : META-PARSER and META-FILE
The following __parser__global__
definitions are supported :
__parser__global__(…)
have to end with a ";"
character like normal "C"
code. yes
by default. __parser__global__
definition. ":"
character to support a tree-like depth. "@"
character.The special keywords:
__parser__push__(ATTRIBUTE?=VALUE?, ATTRIBUTE?=VALUE?, …);
and __parser__pop__;
are used to add a ATTRIBUTE to a block-of-code.
__parser__push__
and __parser__pop__
must not be nested__parser__push__
block definition __parser__push__(doc-index=BlaBla); ... some functions __parser__(doc-index=_ignore_) // ignore the 'BlaBla' for function 'my_special_func' void my_special_func(…) ... some functions __parser__pop__;
An ATTRIBUTE is defined with __parser__define__
or __parser__global__define__
theKernel/c/LibMkKernel_mk.h
The following syntay is defined :
":"
character, the "@"
character is used to join multiple VALUES into one string. ":"
character. "="
character. "="
character can be skipped and the default VALUE is yes
. _ignore_
is used to ignore the ATTRIBUTE.This is an example from the theKernel/c/kernel_mk.h
file and define the BufferLog slot of the MkBufferC class.
MkBufferC
MkBuffer
together with the first parameter MK_BUFN
indicate the class MkBufferC
.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.default=VALUE
attribute.