summaryrefslogtreecommitdiff
path: root/source4/build/pidl/idl.gram
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-12-14 04:09:29 +0000
committerAndrew Tridgell <tridge@samba.org>2000-12-14 04:09:29 +0000
commitce74988dc831d856a94b341d7df3501932b1c43c (patch)
tree54a62a7dc4a2581768fac8b55023fd14bd33cfce /source4/build/pidl/idl.gram
downloadsamba-ce74988dc831d856a94b341d7df3501932b1c43c.tar.gz
samba-ce74988dc831d856a94b341d7df3501932b1c43c.tar.bz2
samba-ce74988dc831d856a94b341d7df3501932b1c43c.zip
first version
(This used to be commit 14135ed6bbff54d7b493f9be7748c2ad7440a97b)
Diffstat (limited to 'source4/build/pidl/idl.gram')
-rw-r--r--source4/build/pidl/idl.gram135
1 files changed, 135 insertions, 0 deletions
diff --git a/source4/build/pidl/idl.gram b/source4/build/pidl/idl.gram
new file mode 100644
index 0000000000..00b3952ba2
--- /dev/null
+++ b/source4/build/pidl/idl.gram
@@ -0,0 +1,135 @@
+{
+ 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 : typedef { $item[1] }
+ | function { $item[1] }
+
+typedef : 'typedef' <commit> type identifier array_len(?) ';'
+ {{
+ "TYPE" => "TYPEDEF",
+ "NAME" => $item{identifier},
+ "DATA" => $item{type},
+ "ARRAY_LEN" => $item{array_len}[0]
+ }}
+ | <error?>
+
+struct: 'struct' <commit> '{' element_list1(?) '}'
+ {{
+ "TYPE" => "STRUCT",
+ "ELEMENTS" => util::FlattenArray($item{element_list1})
+ }}
+ | <error?>
+
+union: property_list(s?) 'union' <commit> '{' union_element(s?) '}'
+ {{
+ "TYPE" => "UNION",
+ "PROPERTIES" => util::FlattenArray($item[1]),
+ "DATA" => $item{union_element}
+ }}
+ | <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{pointer}}==-1?undef:$#{$item{pointer}}+1,
+ "ARRAY_LEN" => $item{array_len}[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'
+ | 'in'
+ | 'out'
+ | 'ref'
+ | '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: '#' /.*/