summaryrefslogtreecommitdiff
path: root/source3/aparser/parsetree.awk
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-05-15 13:41:05 +0000
committerAndrew Tridgell <tridge@samba.org>2000-05-15 13:41:05 +0000
commit32a7cf9188672b0c4766056eb762972f8488aa8e (patch)
tree04d27186b802525e7449c03a908827a67f67200a /source3/aparser/parsetree.awk
parente2e33eb3207e1a6f85ca36cafc564aa9427fd7af (diff)
downloadsamba-32a7cf9188672b0c4766056eb762972f8488aa8e.tar.gz
samba-32a7cf9188672b0c4766056eb762972f8488aa8e.tar.bz2
samba-32a7cf9188672b0c4766056eb762972f8488aa8e.zip
started update to handle arbitrary arrays
note: this code is currently broken. (This used to be commit 15646ebd84ee4e63a251c87800677f3dd2ae6971)
Diffstat (limited to 'source3/aparser/parsetree.awk')
-rw-r--r--source3/aparser/parsetree.awk63
1 files changed, 40 insertions, 23 deletions
diff --git a/source3/aparser/parsetree.awk b/source3/aparser/parsetree.awk
index e0f946a663..6f2697ec91 100644
--- a/source3/aparser/parsetree.awk
+++ b/source3/aparser/parsetree.awk
@@ -4,6 +4,8 @@ function start_module(name)
{
module=name;
num_structs=0;
+ num_elements=0;
+ num_unions=0;
}
function start_struct(name)
@@ -21,44 +23,59 @@ function end_struct()
current_struct="";
}
-function add_elem(type, elem,
- LOCAL, elem_num)
+function add_element(type, elem, case,
+ LOCAL, elem_num, i, v)
{
- elem_num=structs[current_struct, "num_elems"];
- structs[current_struct, elem_num, "type"] = type;
- structs[current_struct, elem_num, "elem"] = elem;
- structs[current_struct, elem_num, "array_len"] = "";
- structs[current_struct, "num_elems"]++;
+ elem_num=num_elements;
+
+ if (substr(elem, 1, 1) == "*") {
+ elem=substr(elem, 2);
+ elements[elem_num, "ptr"]=1;
+ }
+
+ i=match(elem,"[[]");
+ if (i != 0) {
+ v = substr(elem, i+1, length(elem)-i-1);
+ elem=substr(elem, 1, i-1);
+ if (type=="union") {
+ elements[elem_num, "switch"] = v;
+ } else {
+ elements[elem_num, "array_len"] = v;
+ }
+ }
+
+ elements[elem_num, "type"] = type;
+ elements[elem_num, "elem"] = elem;
+ elements[elem_num, "case"] = case;
+
+ num_elements++;
return elem_num;
}
-function add_array(array_len, type, elem,
- LOCAL, elem_num)
+function add_struct_elem(type, elem, case,
+ LOCAL, elem_num)
{
- elem_num=add_elem(type, elem);
- structs[current_struct, elem_num, "array_len"] = array_len;
+ elem_num=structs[current_struct, "num_elems"];
+ structs[current_struct, elem_num] = add_element(type, elem, case);
+ structs[current_struct, "num_elems"]++;
+ return structs[current_struct, elem_num];
}
-function start_union(switch, elem)
+function start_union(elem)
{
- current_union=elem;
- add_elem("union", elem);
- structs[current_struct, "unions", current_union, "switch"] = switch;
- structs[current_struct, "unions", current_union, "num_elems"] = 0;
+ current_union = add_struct_elem("union", elem);
+ unions[current_union, "num_elems"] = 0;
}
-function parse_case(value, type, elem,
+function parse_case(case, type, elem,
LOCAL, elem_num)
{
- elem_num =structs[current_struct, "unions", current_union, "num_elems"];
- structs[current_struct, "unions", current_union, elem_num, "type"] = type;
- structs[current_struct, "unions", current_union, elem_num, "elem"] = elem;
- structs[current_struct, "unions", current_union, elem_num, "value"] = value;
- structs[current_struct, "unions", current_union, "num_elems"]++;
+ elem_num = unions[current_union, "num_elems"];
+ unions[current_union, elem_num] = add_element(type, elem, case);
+ unions[current_union, "num_elems"]++;
}
function end_union()
{
current_union="";
}
-