Debian Codegraph @

tools/rlparser/README.md

raw symbols SCIP
1 # rlparser - raylib parser
2
3 This parser scans [`raylib.h`](../src/raylib.h) to get information about `defines`, `structs`, `enums` and `functions`.
4 All data is separated into parts, usually as strings. The following types are used for data:
5
6 - `struct DefineInfo`
7 - `struct FunctionInfo`
8 - `struct StructInfo`
9 - `struct EnumInfo`
10
11 Check `rlparser.c` for details about those structs.
12
13 ## Command Line
14
15 ```
16 //////////////////////////////////////////////////////////////////////////////////
17 // //
18 // rlparser - raylib header API parser //
19 // //
20 // more info and bugs-report: github.com/raysan5/raylib/tools/rlparser //
21 // //
22 // Copyright (c) 2021-2026 Ramon Santamaria (@raysan5) //
23 // //
24 //////////////////////////////////////////////////////////////////////////////////
25
26 USAGE:
27
28 > rlparser [--help] [--input <filename.h>] [--output <filename.ext>] [--format <type>]
29
30 OPTIONS:
31
32 -h, --help : Show tool version and command line usage help
33
34 -i, --input <filename.h> : Define input header file to parse.
35 NOTE: If not specified, defaults to: raylib.h
36
37 -o, --output <filename.ext> : Define output file and format.
38 Supported extensions: .txt, .json, .xml, .h
39 NOTE: If not specified, defaults to: raylib_api.txt
40
41 -f, --format <type> : Define output format for parser data.
42 Supported types: DEFAULT, JSON, XML, LUA
43
44 -d, --define <DEF> : Define functions specifiers (i.e. RLAPI for raylib.h, RMAPI for raymath.h, etc.)
45 NOTE: If no specifier defined, defaults to: RLAPI
46
47 -t, --truncate <after> : Define string to truncate input after (i.e. "RLGL IMPLEMENTATION" for rlgl.h)
48 NOTE: If not specified, the full input file is parsed.
49
50
51 EXAMPLES:
52
53 > rlparser --input raylib.h --output api.json
54 Process <raylib.h> to generate <api.json>
55
56 > rlparser --output raylib_data.info --format XML
57 Process <raylib.h> to generate <raylib_data.info> as XML text data
58
59 > rlparser --input raymath.h --output raymath_data.info --format XML --define RMAPI
60 Process <raymath.h> to generate <raymath_data.info> as XML text data
61 ```
62
63 ## Constraints
64
65 `rlparser` is specifically designed to work with `raylib.h`, so, it has some constraints:
66
67 - Functions are expected as a single line with the following structure:
68 ```
69 <retType> <name>(<paramType[0]> <paramName[0]>, <paramType[1]> <paramName[1]>); <desc>
70 ```
71 Be careful with functions broken into several lines, it breaks the process!
72
73 - Structures are expected as several lines with the following form:
74 ```
75 <desc>
76 typedef struct <name> {
77 <fieldType[0]> <fieldName[0]>; <fieldDesc[0]>
78 <fieldType[1]> <fieldName[1]>; <fieldDesc[1]>
79 <fieldType[2]> <fieldName[2]>; <fieldDesc[2]>
80 } <name>;
81 ```
82 - Enums are expected as several lines with the following form:
83 ```
84 <desc>
85 typedef enum {
86 <valueName[0]> = <valueInteger[0]>, <valueDesc[0]>
87 <valueName[1]>,
88 <valueName[2]>, <valueDesc[2]>
89 <valueName[3]> <valueDesc[3]>
90 } <name>;
91 ```
92
93 _NOTE: For enums, multiple options are supported:_
94
95 - If value is not provided, (<valueInteger[i -1]> + 1) is assigned
96 - Value description can be provided or not
97
98 ## Additional notes
99
100 This parser _could_ work with other C header files if mentioned constraints are followed.
101
102 This parser **does not require `<string.h>` library**, all data is parsed directly from char buffers.
103
104 ### LICENSE: zlib/libpng
105
106 raylib-parser is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software.
107
108 Check [LICENSE](LICENSE) for further details.
109