Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / parsing_cocci / visitor_ast.ml
index 4717cba..425d477 100644 (file)
@@ -1,5 +1,9 @@
 (*
- * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
+ * Copyright 2012, INRIA
+ * Julia Lawall, Gilles Muller
+ * Copyright 2010-2011, INRIA, University of Copenhagen
+ * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
+ * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
  * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
  * This file is part of Coccinelle.
  *
@@ -47,7 +51,8 @@ type 'a combiner =
      combiner_anything : Ast.anything  -> 'a;
      combiner_expression_dots : Ast.expression Ast.dots -> 'a;
      combiner_statement_dots : Ast.statement Ast.dots -> 'a;
-     combiner_declaration_dots : Ast.declaration Ast.dots -> 'a}
+     combiner_declaration_dots : Ast.declaration Ast.dots -> 'a;
+     combiner_initialiser_dots : Ast.initialiser Ast.dots -> 'a}
 
 type ('mc,'a) cmcode = 'a combiner -> 'mc Ast_cocci.mcode -> 'a
 type ('cd,'a) ccode = 'a combiner -> ('cd -> 'a) -> 'cd -> 'a
@@ -58,7 +63,7 @@ let combiner bind option_default
     unary_mcodefn binary_mcodefn
     cv_mcodefn sign_mcodefn struct_mcodefn storage_mcodefn
     inc_file_mcodefn
-    expdotsfn paramdotsfn stmtdotsfn decldotsfn
+    expdotsfn paramdotsfn stmtdotsfn decldotsfn initdotsfn
     identfn exprfn ftfn tyfn initfn paramfn declfn rulefn stmtfn casefn
     topfn anyfn =
   let multibind l =
@@ -71,6 +76,13 @@ let combiner bind option_default
       Some x -> f x
     | None -> option_default in
 
+  let dotsfn param default all_functions arg =
+    let k d =
+      match Ast.unwrap d with
+       Ast.DOTS(l) | Ast.CIRCLES(l) | Ast.STARS(l) ->
+         multibind (List.map default l) in
+    param all_functions k arg in
+
   let rec meta_mcode x = meta_mcodefn all_functions x
   and string_mcode x = string_mcodefn all_functions x
   and const_mcode x = const_mcodefn all_functions x
@@ -84,44 +96,23 @@ let combiner bind option_default
   and storage_mcode x = storage_mcodefn all_functions x
   and inc_file_mcode x = inc_file_mcodefn all_functions x
 
-  and expression_dots d =
-    let k d =
-      match Ast.unwrap d with
-       Ast.DOTS(l) | Ast.CIRCLES(l) | Ast.STARS(l) ->
-         multibind (List.map expression l) in
-    expdotsfn all_functions k d
-
-  and parameter_dots d =
-    let k d =
-      match Ast.unwrap d with
-       Ast.DOTS(l) | Ast.CIRCLES(l) | Ast.STARS(l) ->
-         multibind (List.map parameterTypeDef l) in
-    paramdotsfn all_functions k d
-
-  and statement_dots d =
-    let k d =
-      match Ast.unwrap d with
-       Ast.DOTS(l) | Ast.CIRCLES(l) | Ast.STARS(l) ->
-         multibind (List.map statement l) in
-    stmtdotsfn all_functions k d
-
-  and declaration_dots d =
-    let k d =
-      match Ast.unwrap d with
-       Ast.DOTS(l) | Ast.CIRCLES(l) | Ast.STARS(l) ->
-         multibind (List.map declaration l) in
-    decldotsfn all_functions k d
+  and expression_dots d = dotsfn expdotsfn expression all_functions d
+  and parameter_dots d = dotsfn paramdotsfn parameterTypeDef all_functions d
+  and statement_dots d = dotsfn stmtdotsfn statement all_functions d
+  and declaration_dots d = dotsfn decldotsfn declaration all_functions d
+  and initialiser_dots d = dotsfn initdotsfn initialiser all_functions d
 
   and ident i =
     let k i =
       match Ast.unwrap i with
-         Ast.Id(name) -> string_mcode name
-       | Ast.MetaId(name,_,_,_) -> meta_mcode name
-       | Ast.MetaFunc(name,_,_,_) -> meta_mcode name
-       | Ast.MetaLocalFunc(name,_,_,_) -> meta_mcode name
-       | Ast.OptIdent(id) -> ident id
-       | Ast.UniqueIdent(id) -> ident id in
-      identfn all_functions k i
+       Ast.Id(name) -> string_mcode name
+      | Ast.MetaId(name,_,_,_) -> meta_mcode name
+      | Ast.MetaFunc(name,_,_,_) -> meta_mcode name
+      | Ast.MetaLocalFunc(name,_,_,_) -> meta_mcode name
+      | Ast.DisjId(id_list) -> multibind (List.map ident id_list)
+      | Ast.OptIdent(id) -> ident id
+      | Ast.UniqueIdent(id) -> ident id in
+    identfn all_functions k i
 
   and expression e =
     let k e =
@@ -133,6 +124,8 @@ let combiner bind option_default
                      string_mcode rp]
       | Ast.Assignment(left,op,right,simple) ->
          multibind [expression left; assign_mcode op; expression right]
+      | Ast.Sequence(left,op,right) ->
+         multibind [expression left; string_mcode op; expression right]
       | Ast.CondExpr(exp1,why,exp2,colon,exp3) ->
          multibind [expression exp1; string_mcode why;
                      get_option expression exp2; string_mcode colon;
@@ -163,13 +156,20 @@ let combiner bind option_default
          multibind
            [string_mcode szf; string_mcode lp; fullType ty; string_mcode rp]
       | Ast.TypeExp(ty) -> fullType ty
+      | Ast.Constructor(lp,ty,rp,init) ->
+         multibind
+           [string_mcode lp; fullType ty; string_mcode rp; initialiser init]
       | Ast.MetaErr(name,_,_,_)
       | Ast.MetaExpr(name,_,_,_,_,_)
       | Ast.MetaExprList(name,_,_,_) -> meta_mcode name
+      |        Ast.AsExpr(exp,asexp) -> bind (expression exp) (expression asexp)
       | Ast.EComma(cm) -> string_mcode cm
       | Ast.DisjExpr(exp_list) -> multibind (List.map expression exp_list)
-      | Ast.NestExpr(expr_dots,whencode,multi) ->
-         bind (expression_dots expr_dots) (get_option expression whencode)
+      | Ast.NestExpr(starter,expr_dots,ender,whencode,multi) ->
+         bind (string_mcode starter)
+           (bind (expression_dots expr_dots)
+              (bind (string_mcode ender)
+                 (get_option expression whencode)))
       | Ast.Edots(dots,whencode) | Ast.Ecircles(dots,whencode)
       | Ast.Estars(dots,whencode) ->
          bind (string_mcode dots) (get_option expression whencode)
@@ -180,7 +180,8 @@ let combiner bind option_default
   and fullType ft =
     let k ft =
       match Ast.unwrap ft with
-       Ast.Type(cv,ty) -> bind (get_option cv_mcode cv) (typeC ty)
+       Ast.Type(_,cv,ty) -> bind (get_option cv_mcode cv) (typeC ty)
+      |        Ast.AsType(ty,asty) -> bind (fullType ty) (fullType asty)
       | Ast.DisjType(types) -> multibind (List.map fullType types)
       | Ast.OptType(ty) -> fullType ty
       | Ast.UniqueType(ty) -> fullType ty in
@@ -216,7 +217,12 @@ let combiner bind option_default
       |        Ast.FunctionType (_,ty,lp1,params,rp1) ->
          function_type (ty,lp1,params,rp1) []
       | Ast.Array(ty,lb,size,rb) -> array_type (ty,lb,size,rb) []
-      | Ast.EnumName(kind,name) -> bind (string_mcode kind) (ident name)
+      | Ast.EnumName(kind,name) ->
+         bind (string_mcode kind) (get_option ident name)
+      | Ast.EnumDef(ty,lb,ids,rb) ->
+         multibind
+           [fullType ty; string_mcode lb; expression_dots ids;
+             string_mcode rb]
       | Ast.StructUnionName(kind,name) ->
          bind (struct_mcode kind) (get_option ident name)
       | Ast.StructUnionDef(ty,lb,decls,rb) ->
@@ -229,7 +235,7 @@ let combiner bind option_default
 
   and named_type ty id =
     match Ast.unwrap ty with
-      Ast.Type(None,ty1) ->
+      Ast.Type(_,None,ty1) ->
        (match Ast.unwrap ty1 with
          Ast.FunctionPointer(ty,lp1,star,rp1,lp2,params,rp2) ->
            function_pointer (ty,lp1,star,rp1,lp2,params,rp2) [ident id]
@@ -242,7 +248,12 @@ let combiner bind option_default
   and declaration d =
     let k d =
       match Ast.unwrap d with
-       Ast.Init(stg,ty,id,eq,ini,sem) ->
+       Ast.MetaDecl(name,_,_) | Ast.MetaField(name,_,_)
+      |        Ast.MetaFieldList(name,_,_,_) ->
+         meta_mcode name
+      |        Ast.AsDecl(decl,asdecl) ->
+         bind (declaration decl) (declaration asdecl)
+      |        Ast.Init(stg,ty,id,eq,ini,sem) ->
          bind (get_option storage_mcode stg)
            (bind (named_type ty id)
               (multibind
@@ -254,6 +265,11 @@ let combiner bind option_default
          multibind
            [ident name; string_mcode lp; expression_dots args;
              string_mcode rp; string_mcode sem]
+      | Ast.MacroDeclInit(name,lp,args,rp,eq,ini,sem) ->
+         multibind
+           [ident name; string_mcode lp; expression_dots args;
+             string_mcode rp; string_mcode eq; initialiser ini;
+             string_mcode sem]
       | Ast.TyDecl(ty,sem) -> bind (fullType ty) (string_mcode sem)
       | Ast.Typedef(stg,ty,id,sem) ->
          bind (string_mcode stg)
@@ -261,7 +277,6 @@ let combiner bind option_default
       | Ast.DisjDecl(decls) -> multibind (List.map declaration decls)
       |        Ast.Ddots(dots,whencode) ->
          bind (string_mcode dots) (get_option declaration whencode)
-      | Ast.MetaDecl(name,_,_) -> meta_mcode name
       | Ast.OptDecl(decl) -> declaration decl
       | Ast.UniqueDecl(decl) -> declaration decl in
     declfn all_functions k d
@@ -270,8 +285,14 @@ let combiner bind option_default
     let k i =
       match Ast.unwrap i with
        Ast.MetaInit(name,_,_) -> meta_mcode name
+      |        Ast.MetaInitList(name,_,_,_) -> meta_mcode name
+      |        Ast.AsInit(init,asinit) ->
+         bind (initialiser init) (initialiser asinit)
       |        Ast.InitExpr(exp) -> expression exp
-      | Ast.InitList(lb,initlist,rb,whencode) ->
+      | Ast.ArInitList(lb,initlist,rb) ->
+         multibind
+           [string_mcode lb; initialiser_dots initlist; string_mcode rb]
+      | Ast.StrInitList(allminus,lb,initlist,rb,whencode) ->
          multibind
            [string_mcode lb;
              multibind (List.map initialiser initlist);
@@ -284,6 +305,8 @@ let combiner bind option_default
            ((List.map designator designators) @
             [string_mcode eq; initialiser ini])
       | Ast.IComma(cm) -> string_mcode cm
+      | Ast.Idots(dots,whencode) ->
+         bind (string_mcode dots) (get_option initialiser whencode)
       | Ast.OptIni(i) -> initialiser i
       | Ast.UniqueIni(i) -> initialiser i in
     initfn all_functions k i
@@ -324,7 +347,7 @@ let combiner bind option_default
       | Ast.SeqStart(brace) -> string_mcode brace
       | Ast.SeqEnd(brace) -> string_mcode brace
       | Ast.ExprStatement(exp,sem) ->
-         bind (expression exp) (string_mcode sem)
+         bind (get_option expression exp) (string_mcode sem)
       | Ast.IfHeader(iff,lp,exp,rp) ->
          multibind [string_mcode iff; string_mcode lp; expression exp;
                      string_mcode rp]
@@ -363,6 +386,8 @@ let combiner bind option_default
       | Ast.Ty(ty) -> fullType ty
       | Ast.TopInit(init) -> initialiser init
       |        Ast.Include(inc,name) -> bind (string_mcode inc) (inc_file_mcode name)
+      |        Ast.Undef(def,id) ->
+         multibind [string_mcode def; ident id]
       |        Ast.DefineHeader(def,id,params) ->
          multibind [string_mcode def; ident id; define_parameters params]
       |        Ast.Default(def,colon) -> bind (string_mcode def) (string_mcode colon)
@@ -434,14 +459,19 @@ let combiner bind option_default
       | Ast.Atomic(re) -> rule_elem re
       | Ast.Disj(stmt_dots_list) ->
          multibind (List.map statement_dots stmt_dots_list)
-      | Ast.Nest(stmt_dots,whn,_,_,_) ->
-         bind (statement_dots stmt_dots)
-           (multibind (List.map (whencode statement_dots statement) whn))
+      | Ast.Nest(starter,stmt_dots,ender,whn,_,_,_) ->
+         bind (string_mcode starter)
+           (bind (statement_dots stmt_dots)
+              (bind (string_mcode ender)
+                 (multibind
+                    (List.map (whencode statement_dots statement) whn))))
       | Ast.FunDecl(header,lbrace,body,rbrace) ->
          multibind [rule_elem header; rule_elem lbrace;
                      statement_dots body; rule_elem rbrace]
       | Ast.Define(header,body) ->
          bind (rule_elem header) (statement_dots body)
+      |        Ast.AsStmt(stm,asstm) ->
+         bind (statement stm) (statement asstm)
       | Ast.Dots(d,whn,_,_) | Ast.Circles(d,whn,_,_) | Ast.Stars(d,whn,_,_) ->
          bind (string_mcode d)
            (multibind (List.map (whencode statement_dots statement) whn))
@@ -475,7 +505,7 @@ let combiner bind option_default
       match Ast.unwrap t with
        Ast.FILEINFO(old_file,new_file) ->
          bind (string_mcode old_file) (string_mcode new_file)
-      | Ast.DECL(stmt) -> statement stmt
+      | Ast.NONDECL(stmt) -> statement stmt
       | Ast.CODE(stmt_dots) -> statement_dots stmt_dots
       | Ast.ERRORWORDS(exps) -> multibind (List.map expression exps) in
     topfn all_functions k t
@@ -533,7 +563,8 @@ let combiner bind option_default
       combiner_anything = anything;
       combiner_expression_dots = expression_dots;
       combiner_statement_dots = statement_dots;
-      combiner_declaration_dots = declaration_dots} in
+      combiner_declaration_dots = declaration_dots;
+      combiner_initialiser_dots = initialiser_dots} in
   all_functions
 
 (* ---------------------------------------------------------------------- *)
@@ -556,6 +587,7 @@ type rebuilder =
       rebuilder_expression_dots : Ast.expression Ast.dots inout;
       rebuilder_statement_dots : Ast.statement Ast.dots inout;
       rebuilder_declaration_dots : Ast.declaration Ast.dots inout;
+      rebuilder_initialiser_dots : Ast.initialiser Ast.dots inout;
       rebuilder_define_param_dots : Ast.define_param Ast.dots inout;
       rebuilder_define_param : Ast.define_param inout;
       rebuilder_define_parameters : Ast.define_parameters inout;
@@ -569,47 +601,27 @@ let rebuilder
     meta_mcode string_mcode const_mcode assign_mcode fix_mcode unary_mcode
     binary_mcode cv_mcode sign_mcode struct_mcode storage_mcode
     inc_file_mcode
-    expdotsfn paramdotsfn stmtdotsfn decldotsfn
+    expdotsfn paramdotsfn stmtdotsfn decldotsfn initdotsfn
     identfn exprfn ftfn tyfn initfn paramfn declfn rulefn stmtfn casefn
     topfn anyfn =
   let get_option f = function
       Some x -> Some (f x)
     | None -> None in
-  let rec expression_dots d =
-    let k d =
-      Ast.rewrap d
-       (match Ast.unwrap d with
-         Ast.DOTS(l) -> Ast.DOTS(List.map expression l)
-       | Ast.CIRCLES(l) -> Ast.CIRCLES(List.map expression l)
-       | Ast.STARS(l) -> Ast.STARS(List.map expression l)) in
-    expdotsfn all_functions k d
 
-  and parameter_dots d =
+  let dotsfn param default all_functions arg =
     let k d =
       Ast.rewrap d
        (match Ast.unwrap d with
-         Ast.DOTS(l) -> Ast.DOTS(List.map parameterTypeDef l)
-       | Ast.CIRCLES(l) -> Ast.CIRCLES(List.map parameterTypeDef l)
-       | Ast.STARS(l) -> Ast.STARS(List.map parameterTypeDef l)) in
-    paramdotsfn all_functions k d
+         Ast.DOTS(l) -> Ast.DOTS(List.map default l)
+       | Ast.CIRCLES(l) -> Ast.CIRCLES(List.map default l)
+       | Ast.STARS(l) -> Ast.STARS(List.map default l)) in
+    param all_functions k arg in
 
-  and statement_dots d =
-    let k d =
-      Ast.rewrap d
-       (match Ast.unwrap d with
-         Ast.DOTS(l) -> Ast.DOTS(List.map statement l)
-       | Ast.CIRCLES(l) -> Ast.CIRCLES(List.map statement l)
-       | Ast.STARS(l) -> Ast.STARS(List.map statement l)) in
-    stmtdotsfn all_functions k d
-
-  and declaration_dots d =
-    let k d =
-      Ast.rewrap d
-       (match Ast.unwrap d with
-         Ast.DOTS(l) -> Ast.DOTS(List.map declaration l)
-       | Ast.CIRCLES(l) -> Ast.CIRCLES(List.map declaration l)
-       | Ast.STARS(l) -> Ast.STARS(List.map declaration l)) in
-    decldotsfn all_functions k d
+  let rec expression_dots d = dotsfn expdotsfn expression all_functions d
+  and parameter_dots d = dotsfn paramdotsfn parameterTypeDef all_functions d
+  and statement_dots d = dotsfn stmtdotsfn statement all_functions d
+  and declaration_dots d = dotsfn decldotsfn declaration all_functions d
+  and initialiser_dots d = dotsfn initdotsfn initialiser all_functions d
 
   and ident i =
     let k i =
@@ -622,6 +634,7 @@ let rebuilder
            Ast.MetaFunc(meta_mcode name,constraints,keep,inherited)
        | Ast.MetaLocalFunc(name,constraints,keep,inherited) ->
            Ast.MetaLocalFunc(meta_mcode name,constraints,keep,inherited)
+       | Ast.DisjId(id_list) -> Ast.DisjId(List.map ident id_list)
        | Ast.OptIdent(id) -> Ast.OptIdent(ident id)
        | Ast.UniqueIdent(id) -> Ast.UniqueIdent(ident id)) in
     identfn all_functions k i
@@ -638,6 +651,8 @@ let rebuilder
        | Ast.Assignment(left,op,right,simple) ->
            Ast.Assignment(expression left, assign_mcode op, expression right,
                           simple)
+       | Ast.Sequence(left,op,right) ->
+           Ast.Sequence(expression left, string_mcode op, expression right)
        | Ast.CondExpr(exp1,why,exp2,colon,exp3) ->
            Ast.CondExpr(expression exp1, string_mcode why,
                         get_option expression exp2, string_mcode colon,
@@ -667,16 +682,21 @@ let rebuilder
            Ast.SizeOfType(string_mcode szf,string_mcode lp, fullType ty,
                            string_mcode rp)
        | Ast.TypeExp(ty) -> Ast.TypeExp(fullType ty)
+       | Ast.Constructor(lp,ty,rp,init) ->
+           Ast.Constructor(string_mcode lp, fullType ty, string_mcode rp,
+                    initialiser init)
        | Ast.MetaErr(name,constraints,keep,inherited) ->
            Ast.MetaErr(meta_mcode name,constraints,keep,inherited)
        | Ast.MetaExpr(name,constraints,keep,ty,form,inherited) ->
            Ast.MetaExpr(meta_mcode name,constraints,keep,ty,form,inherited)
        | Ast.MetaExprList(name,lenname_inh,keep,inherited) ->
            Ast.MetaExprList(meta_mcode name,lenname_inh,keep,inherited)
+       | Ast.AsExpr(exp,asexp) -> Ast.AsExpr(expression exp,expression asexp)
        | Ast.EComma(cm) -> Ast.EComma(string_mcode cm)
        | Ast.DisjExpr(exp_list) -> Ast.DisjExpr(List.map expression exp_list)
-       | Ast.NestExpr(expr_dots,whencode,multi) ->
-           Ast.NestExpr(expression_dots expr_dots,
+       | Ast.NestExpr(starter,expr_dots,ender,whencode,multi) ->
+           Ast.NestExpr(string_mcode starter,expression_dots expr_dots,
+                        string_mcode ender,
                         get_option expression whencode,multi)
        | Ast.Edots(dots,whencode) ->
            Ast.Edots(string_mcode dots,get_option expression whencode)
@@ -692,7 +712,9 @@ let rebuilder
     let k ft =
       Ast.rewrap ft
        (match Ast.unwrap ft with
-         Ast.Type(cv,ty) -> Ast.Type (get_option cv_mcode cv, typeC ty)
+         Ast.Type(allminus,cv,ty) ->
+           Ast.Type (allminus,get_option cv_mcode cv, typeC ty)
+       | Ast.AsType(ty,asty) -> Ast.AsType(fullType ty,fullType asty)
        | Ast.DisjType(types) -> Ast.DisjType(List.map fullType types)
        | Ast.OptType(ty) -> Ast.OptType(fullType ty)
        | Ast.UniqueType(ty) -> Ast.UniqueType(fullType ty)) in
@@ -720,7 +742,10 @@ let rebuilder
            Ast.Array(fullType ty, string_mcode lb,
                      get_option expression size, string_mcode rb)
        | Ast.EnumName(kind,name) ->
-           Ast.EnumName(string_mcode kind, ident name)
+           Ast.EnumName(string_mcode kind, get_option ident name)
+       | Ast.EnumDef(ty,lb,ids,rb) ->
+           Ast.EnumDef (fullType ty, string_mcode lb, expression_dots ids,
+                        string_mcode rb)
        | Ast.StructUnionName(kind,name) ->
            Ast.StructUnionName (struct_mcode kind, get_option ident name)
        | Ast.StructUnionDef(ty,lb,decls,rb) ->
@@ -736,7 +761,15 @@ let rebuilder
     let k d =
       Ast.rewrap d
        (match Ast.unwrap d with
-         Ast.Init(stg,ty,id,eq,ini,sem) ->
+         Ast.MetaDecl(name,keep,inherited) ->
+           Ast.MetaDecl(meta_mcode name,keep,inherited)
+       | Ast.MetaField(name,keep,inherited) ->
+           Ast.MetaField(meta_mcode name,keep,inherited)
+       | Ast.MetaFieldList(name,lenname_inh,keep,inherited) ->
+           Ast.MetaFieldList(meta_mcode name,lenname_inh,keep,inherited)
+       | Ast.AsDecl(decl,asdecl) ->
+           Ast.AsDecl(declaration decl,declaration asdecl)
+       | Ast.Init(stg,ty,id,eq,ini,sem) ->
            Ast.Init(get_option storage_mcode stg, fullType ty, ident id,
                     string_mcode eq, initialiser ini, string_mcode sem)
        | Ast.UnInit(stg,ty,id,sem) ->
@@ -745,6 +778,11 @@ let rebuilder
        | Ast.MacroDecl(name,lp,args,rp,sem) ->
            Ast.MacroDecl(ident name, string_mcode lp, expression_dots args,
                          string_mcode rp,string_mcode sem)
+       | Ast.MacroDeclInit(name,lp,args,rp,eq,ini,sem) ->
+           Ast.MacroDeclInit
+             (ident name, string_mcode lp, expression_dots args,
+              string_mcode rp,string_mcode eq,initialiser ini,
+              string_mcode sem)
        | Ast.TyDecl(ty,sem) -> Ast.TyDecl(fullType ty, string_mcode sem)
        | Ast.Typedef(stg,ty,id,sem) ->
            Ast.Typedef(string_mcode stg, fullType ty, typeC id,
@@ -752,8 +790,6 @@ let rebuilder
        | Ast.DisjDecl(decls) -> Ast.DisjDecl(List.map declaration decls)
        | Ast.Ddots(dots,whencode) ->
            Ast.Ddots(string_mcode dots, get_option declaration whencode)
-       | Ast.MetaDecl(name,keep,inherited) ->
-           Ast.MetaDecl(meta_mcode name,keep,inherited)
        | Ast.OptDecl(decl) -> Ast.OptDecl(declaration decl)
        | Ast.UniqueDecl(decl) -> Ast.UniqueDecl(declaration decl)) in
     declfn all_functions k d
@@ -764,9 +800,17 @@ let rebuilder
        (match Ast.unwrap i with
          Ast.MetaInit(name,keep,inherited) ->
            Ast.MetaInit(meta_mcode name,keep,inherited)
+       | Ast.MetaInitList(name,lenname_inh,keep,inherited) ->
+           Ast.MetaInitList(meta_mcode name,lenname_inh,keep,inherited)
+       | Ast.AsInit(ini,asini) ->
+           Ast.AsInit(initialiser ini,initialiser asini)
        | Ast.InitExpr(exp) -> Ast.InitExpr(expression exp)
-       | Ast.InitList(lb,initlist,rb,whencode) ->
-           Ast.InitList(string_mcode lb, List.map initialiser initlist,
+       | Ast.ArInitList(lb,initlist,rb) ->
+           Ast.ArInitList(string_mcode lb, initialiser_dots initlist,
+                          string_mcode rb)
+       | Ast.StrInitList(allminus,lb,initlist,rb,whencode) ->
+           Ast.StrInitList(allminus,
+                        string_mcode lb, List.map initialiser initlist,
                         string_mcode rb, List.map initialiser whencode)
        | Ast.InitGccName(name,eq,ini) ->
            Ast.InitGccName(ident name, string_mcode eq, initialiser ini)
@@ -775,6 +819,8 @@ let rebuilder
              (List.map designator designators, string_mcode eq,
               initialiser ini)
        | Ast.IComma(cm) -> Ast.IComma(string_mcode cm)
+       | Ast.Idots(dots,whencode) ->
+           Ast.Idots(string_mcode dots,get_option initialiser whencode)
        | Ast.OptIni(i) -> Ast.OptIni(initialiser i)
        | Ast.UniqueIni(i) -> Ast.UniqueIni(initialiser i)) in
     initfn all_functions k i
@@ -818,7 +864,7 @@ let rebuilder
        | Ast.SeqStart(brace) -> Ast.SeqStart(string_mcode brace)
        | Ast.SeqEnd(brace) -> Ast.SeqEnd(string_mcode brace)
        | Ast.ExprStatement(exp,sem) ->
-           Ast.ExprStatement (expression exp, string_mcode sem)
+           Ast.ExprStatement (get_option expression exp, string_mcode sem)
        | Ast.IfHeader(iff,lp,exp,rp) ->
            Ast.IfHeader(string_mcode iff, string_mcode lp, expression exp,
              string_mcode rp)
@@ -864,6 +910,8 @@ let rebuilder
        | Ast.TopInit(init) -> Ast.TopInit(initialiser init)
        | Ast.Include(inc,name) ->
            Ast.Include(string_mcode inc,inc_file_mcode name)
+       | Ast.Undef(def,id) ->
+           Ast.Undef(string_mcode def,ident id)
        | Ast.DefineHeader(def,id,params) ->
            Ast.DefineHeader(string_mcode def,ident id,
                             define_parameters params)
@@ -943,8 +991,9 @@ let rebuilder
        | Ast.Atomic(re) -> Ast.Atomic(rule_elem re)
        | Ast.Disj(stmt_dots_list) ->
            Ast.Disj (List.map statement_dots stmt_dots_list)
-       | Ast.Nest(stmt_dots,whn,multi,bef,aft) ->
-           Ast.Nest(statement_dots stmt_dots,
+       | Ast.Nest(starter,stmt_dots,ender,whn,multi,bef,aft) ->
+           Ast.Nest(string_mcode starter,statement_dots stmt_dots,
+                    string_mcode ender,
                     List.map (whencode statement_dots statement) whn,
                     multi,bef,aft)
        | Ast.FunDecl(header,lbrace,body,rbrace) ->
@@ -952,6 +1001,7 @@ let rebuilder
                        statement_dots body, rule_elem rbrace)
        | Ast.Define(header,body) ->
            Ast.Define(rule_elem header,statement_dots body)
+       | Ast.AsStmt(stm,asstm) -> Ast.AsStmt(statement stm,statement asstm)
        | Ast.Dots(d,whn,bef,aft) ->
            Ast.Dots(string_mcode d,
                     List.map (whencode statement_dots statement) whn,bef,aft)
@@ -998,7 +1048,7 @@ let rebuilder
        (match Ast.unwrap t with
          Ast.FILEINFO(old_file,new_file) ->
            Ast.FILEINFO (string_mcode old_file, string_mcode new_file)
-       | Ast.DECL(stmt) -> Ast.DECL(statement stmt)
+       | Ast.NONDECL(stmt) -> Ast.NONDECL(statement stmt)
        | Ast.CODE(stmt_dots) -> Ast.CODE(statement_dots stmt_dots)
        | Ast.ERRORWORDS(exps) -> Ast.ERRORWORDS (List.map expression exps)) in
     topfn all_functions k t
@@ -1056,6 +1106,7 @@ let rebuilder
       rebuilder_expression_dots = expression_dots;
       rebuilder_statement_dots = statement_dots;
       rebuilder_declaration_dots = declaration_dots;
+      rebuilder_initialiser_dots = initialiser_dots;
       rebuilder_define_param_dots = define_param_dots;
       rebuilder_define_param = define_param;
       rebuilder_define_parameters = define_parameters;