1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
{
use util;
}
idl: cpp_prefix(s?) module_header interface
{ [$item{module_header}, $item{interface}] }
| <error>
module_header: '[' <commit> module_param(s /,/) ']'
{{
"TYPE" => "MODULEHEADER",
"DATA" => util::FlattenHash($item[3])
}}
| <error?>
module_param: identifier '(' text ')'
{{ "$item{identifier}" => "$item{text}" }}
| <error>
interface: 'interface' <commit> identifier '{' definition(s?) '}'
{{
"TYPE" => "INTERFACE",
"NAME" => $item{identifier},
"DATA" => $item[5]
}}
| <error?>
definition : cpp_prefix
| typedef { $item[1] }
| function { $item[1] }
typedef : 'typedef' <commit> type identifier array_len(?) ';'
{{
"TYPE" => "TYPEDEF",
"NAME" => $item{identifier},
"DATA" => $item{type},
"ARRAY_LEN" => $item[5][0]
}}
| <error?>
struct: 'struct' <commit> '{' element_list1(?) '}'
{{
"TYPE" => "STRUCT",
"ELEMENTS" => util::FlattenArray2($item[4])
}}
| <error?>
union: property_list(s?) 'union' <commit> '{' union_element(s?) '}'
{{
"TYPE" => "UNION",
"PROPERTIES" => util::FlattenArray($item[1]),
"DATA" => $item[5]
}}
| <error?>
union_element: '[' 'case' '(' constant ')' ']' base_element ';'
{{
"TYPE" => "UNION_ELEMENT",
"CASE" => $item{constant},
"DATA" => $item{base_element}
}}
| 'case' '(' constant ')' base_element ';'
{{
"TYPE" => "UNION_ELEMENT",
"CASE" => $item{constant},
"DATA" => $item{base_element}
}}
base_element: property_list(s?) type pointer(s?) identifier array_len(?)
{{
"NAME" => $item{identifier},
"TYPE" => $item{type},
"PROPERTIES" => util::FlattenArray($item[1]),
"POINTERS" => $#{$item[3]}==-1?undef:$#{$item[3]}+1,
"ARRAY_LEN" => $item[5][0]
}}
| <error>
array_len:
'[]'
{ "*" }
| '[' <commit> constant ']'
{ $item{constant} }
| <error?>
element_list1: base_element(s? /;/) ';'
{ $item[1] }
element_list2: 'void'
| base_element(s? /,/)
{ $item[1] }
pointer: '*'
property_list: '[' <commit> property(s /,/) ']'
{ $item[3] }
| <error?>
property: 'unique'
| 'in'
| 'out'
| 'ref'
| 'struct_len'
| 'context_handle'
| 'string'
| 'byte_count_pointer' '(' expression ')' {{ "$item[1]" => "$item{expression}" }}
| 'size_is' '(' expression ')' {{ "$item[1]" => "$item{expression}" }}
| 'length_is' '(' expression ')' {{ "$item[1]" => "$item{expression}" }}
| 'switch_is' '(' expression ')' {{ "$item[1]" => "$item{expression}" }}
| 'switch_type' '(' type ')' {{ "$item[1]" => $item{type} }}
identifier: /[\w?]+/
expression: /[\w?\/+*-]+/
function : type identifier '(' <commit> element_list2 ');'
{{
"TYPE" => "FUNCTION",
"NAME" => $item{identifier},
"RETURN_TYPE" => $item{type},
"DATA" => $item{element_list2}
}}
| <error?>
type :
'unsigned' type { "$item[1] $item[2]" }
| 'long' { $item[1] }
| 'string' { $item[1] }
| 'wchar_t' { $item[1] }
| struct { $item[1] }
| union { $item[1] }
| identifier { $item[1] }
| <error>
text: /[\w\s.?-]*/
constant: /-?\d+/
| '*'
cpp_prefix: '#' /.*/
|