From 32a7cf9188672b0c4766056eb762972f8488aa8e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 May 2000 13:41:05 +0000 Subject: started update to handle arbitrary arrays note: this code is currently broken. (This used to be commit 15646ebd84ee4e63a251c87800677f3dd2ae6971) --- source3/aparser/parsetree.awk | 63 +++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 23 deletions(-) (limited to 'source3/aparser/parsetree.awk') 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=""; } - -- cgit