Data Desk is a project utility that parses a simple C-like data description format. Input files in this data description format are parsed to create corresponding abstract syntax trees which represent the information extracted from the files. These abstract syntax trees are then sent to project-specific custom code that is written by the user. This custom code is simply a dynamic library with a few exported functions that are used as callbacks for the parser. Below is a list of the callbacks.
DataDeskCustomInitCallback(void)is called when the parser starts.DataDeskCustomFileCallback(char *filename)is called when the parser starts parsing a new file.DataDeskCustomStructCallback(DataDeskStruct struct_info, char *filename)is called for every structure that is parsed.DataDeskCustomDeclarationCallback(DataDeskDeclaration declaration, char *filename)is called for every declaration that is parsed.DataDeskCustomCleanUpCallback(void)is called before the parser shuts down.
The abstract syntax tree is formed completely by DataDeskASTNode structures. This structure can be found in the data_desk.h file.
Data Desk also offers a number of utility functions for introspecting on abstract syntax trees it passes to your custom code. A list of these is in the data_desk.h file, which can be included into your custom layer.
To use Data Desk, you'll need to do a few things:
- Get Data Desk
- Make or get some Data Desk format files (.ds)
- Make a project-specific custom layer
- Run the command
git clone https://github.com/ryanfleury/data_desk cd data_deskbuildon Windows (Linux builds not yet officially supported, but the build is extremely simple, so if you take a look atbuild.batyou can create a Linux equivalent very easily).
NOTE: The build command on Windows expects to find cl (MSVC). Your environment should know about this. The easiest way to do this is to call vcvarsall.bat in your terminal environemnt, which is packaged with Visual Studio.
Grab an example or make your own.
-
An easy way to write the code for this is to check out the custom layer template, located here. Fill out the functions in your custom layer code however you want to. There are some helper functions available in
data_desk.hthat might be useful for you here. This can be dropped into your code and used. -
To build a custom layer, you just need to build a DLL with the function callbacks you've written as the appropriate exported symbols.
data_desk.houtlines what symbols are used for each callback.
To run Data Desk with your custom layer, you can use the following command template:
data_desk --custom /path/to/custom/layer /file/to/parse/1 /file/to/parse/2 ...