cyagen

C code based Yet Another GENerator

File generator to reduce the manual effort to prepare another scripting files which contain C code information derived by a C source file.

Better use jinja2 format in template files

Available identifiers in a template file

All the available identifiers can be found on docs.rs

Notice: all the new identifiers are not supported on the old style of template (not jinja2 format).

Example

``` let sourcename = "source"; let code = "\

include

static int var = 1; static int func1(void) { return 0; } int func2(char c) { return func1(); } "; let temp = "\ // include {%- for inc in incs %} {{ inc.captured | safe }} {%- endfor %}

// local variables {%- for var in static_vars %} {{ var.dtype }} {{ var.name }}; {%- endfor %}

// functions {%- for fnc in fncs %} {{ fnc.rtype }} {{ fnc.name }}({{ fnc.args }}); {%- endfor %} "; let parser = cyagen::Parser::parse(code); let gen = cyagen::generateusingtera(&parser, temp, sourcename); println!("{}", gen); ```

Result

``` // include

include

// local variables int var;

// functions int func1(); int func2(char c);

```

Default application command line usage

``` $ cyagen --help cyagen 0.1.10 Text file generator based on C file and templates

USAGE: cyagen [OPTIONS] --source

OPTIONS: -s, --source source file path -t, --temp-dir template directory -o, --output-dir output directory -j, --json-filepath output json file path -h, --help Print help -V, --version Print version $ ```