added primitive define macros
authorAndrew Tridgell <tridge@samba.org>
Wed, 17 May 2000 07:10:50 +0000 (07:10 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 17 May 2000 07:10:50 +0000 (07:10 +0000)
started converting matty's srvsvc.idl to a .struct file
(This used to be commit cf8d4c42e259d65d4d16c91316acc0bad71ff177)

source3/aparser/parsetree.awk
source3/aparser/token.awk

index fe0958e7bfc1605c822d5353a3d063296162a150..6fee6e2a4a6627ef28d130fe55a981fbf27c69f5 100644 (file)
@@ -9,17 +9,10 @@ function start_module(name)
        num_tests=0;
 }
 
-function parse_typedef(type1, type2,
-                      LOCAL, type, i)
+function parse_define(def1, def2,
+                     LOCAL, type, i)
 {
-       type=type2;
-       if (substr(type,1,1)=="*") type=substr(type,2);
-
-       i=match(type,"[[]");
-       if (i != 0) type = substr(type, 1, i-1);
-       start_struct(type);
-       add_struct_elem(type1, type2);
-       end_struct("");
+       defines[def1]=def2;
 }
 
 function start_struct(name) 
@@ -44,6 +37,9 @@ function end_struct(name)
 function add_element(type, elem, case,
                     LOCAL, elem_num, i, v)
 {
+       while (defines[type]!="") {
+               type=defines[type];
+       }
        elem_num=num_elements;
 
        if (substr(elem, 1, 1) == "*") {
index a64700f536870fcf59e01117fc2a34ad0d56a84f..d0703439e99daf724980e8f499a27713251b5794 100644 (file)
@@ -10,6 +10,12 @@ function parse_error(msg) {
        next;
 }
 
+/^\#define.*;/ {
+       split($0,a,"[ \t;]*");
+       parse_define(a[2], a[3]);
+       next;
+}
+
 # ignore comments
 /^[ \t]*\#/ {
        next;
@@ -34,13 +40,6 @@ function parse_error(msg) {
        next;
 }
 
-/^[ \t]*typedef.*;/ {
-       {if (current_struct!="") parse_error("typedefs must be global");}
-       split($0,a,"[ \t;]*");
-       parse_typedef(a[2], a[3]);
-       next;
-}
-
 /^[ \t]*struct.*\{/ {
        {if (current_struct!="") parse_error("you cannot have nested structures");}
        start_struct($2);
@@ -76,8 +75,8 @@ function parse_error(msg) {
 }
 
 /^[ \t]*\} .*;/ {
-       split($0,a,"[ \t;]*");
-       end_struct(a[2]);
+       split($2,a,"[ \t;]*");
+       end_struct(a[1]);
        next;
 }