X-Git-Url: http://git.hcoop.net/bpt/coccinelle.git/blobdiff_plain/3a31414346dd7d7e8baa4cb8b804a2d5e1797962..abad11c5570b7b9bbae5ff92b3050cf68fe3fd14:/parsing_cocci/adjust_pragmas.ml diff --git a/parsing_cocci/adjust_pragmas.ml b/parsing_cocci/adjust_pragmas.ml index 43e09bd..aadb009 100644 --- a/parsing_cocci/adjust_pragmas.ml +++ b/parsing_cocci/adjust_pragmas.ml @@ -1,5 +1,7 @@ (* - * Copyright 2010, INRIA, 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 @@ -22,6 +24,7 @@ *) +# 0 "./adjust_pragmas.ml" (* Find a directive or comment at the end of a statement. Things with aft given None, because they can accomodate their own directives or comments *) @@ -45,13 +48,13 @@ let right_mcode (a,b,info,mcodekind,d,e) = ([],_) | (_,Ast0.PLUS _) -> None | (l,_) -> Some(l,(a,b,{info with Ast0.strings_after = []},mcodekind,d,e)) -let update_before pragmas (info,x) = +let update_before pragmas (info,x,adj) = ({info with Ast0.strings_before = pragmas @ info.Ast0.strings_before}, - Ast0.PLUS Ast.ONE) (* not sure what the arg should be... one seems safe *) + Ast0.PLUS Ast.ONE,adj)(*not sure what the arg should be... one seems safe*) let update_after pragmas (info,x) = ({info with Ast0.strings_after = info.Ast0.strings_after @ pragmas}, - Ast0.PLUS Ast.ONE) (* not sure what the arg should be... one seems safe *) + Ast0.PLUS Ast.ONE) (*not sure what the arg should be... one seems safe*) let rec right_decl d = match Ast0.unwrap d with @@ -61,6 +64,10 @@ let rec right_decl d = | Ast0.MetaField(name,pure) -> call_right right_mcode name d (function name -> Ast0.MetaField(name,pure)) + | Ast0.MetaFieldList(name,lenname,pure) -> + call_right right_mcode name d + (function name -> Ast0.MetaFieldList(name,lenname,pure)) + | Ast0.AsDecl(decl,asdecl) -> failwith "not possible" | Ast0.Init(Some stg,ty,id,eq,ini,sem) -> call_right right_mcode sem d (function sem -> Ast0.Init(Some stg,ty,id,eq,ini,sem)) @@ -76,6 +83,9 @@ let rec right_decl d = | Ast0.MacroDecl(name,lp,args,rp,sem) -> call_right right_mcode sem d (function sem -> Ast0.MacroDecl(name,lp,args,rp,sem)) + | Ast0.MacroDeclInit(name,lp,args,rp,eq,ini,sem) -> + call_right right_mcode sem d + (function sem -> Ast0.MacroDeclInit(name,lp,args,rp,eq,ini,sem)) | Ast0.TyDecl(ty,sem) -> call_right right_mcode sem d (function sem -> Ast0.TyDecl(ty,sem)) @@ -107,7 +117,7 @@ let rec right_statement s = | Ast0.Do(d,body,whl,lp,exp,rp,sem) -> call_right right_mcode sem s (function sem -> Ast0.Do(d,body,whl,lp,exp,rp,sem)) - | Ast0.For(fr,lp,e1,sem1,e2,sem2,e3,rp,body,aft) -> None + | Ast0.For(fr,lp,first,e2,sem2,e3,rp,body,aft) -> None | Ast0.Iterator(nm,lp,args,rp,body,aft) -> None | Ast0.Switch(switch,lp,exp,rp,lb,decls,cases,rb) -> call_right right_mcode rb s @@ -136,6 +146,7 @@ let rec right_statement s = | Ast0.MetaStmtList(name,pure) -> call_right right_mcode name s (function name -> Ast0.MetaStmtList(name,pure)) + | Ast0.AsStmt(stm,asstm) -> failwith "not possible" | Ast0.Disj(starter,statement_dots_list,mids,ender) -> None | Ast0.Nest(starter,stmt_dots,ender,whn,multi) -> None (* the following are None, because they can't be adjacent to an aft node *) @@ -208,6 +219,7 @@ let rec left_ty t = call_right left_mcode name t (function name -> Ast0.TypeName(name)) | Ast0.MetaType(name,x) -> call_right left_mcode name t (function name -> Ast0.MetaType(name,x)) + | Ast0.AsType(ty,asty) -> failwith "not possible" | Ast0.DisjType(starter,types,mids,ender) -> None | Ast0.OptType(ty) -> call_right left_ty ty t (function ty -> Ast0.OptType(ty)) @@ -216,22 +228,21 @@ let rec left_ty t = let rec left_ident i = match Ast0.unwrap i with - Ast0.Id(name) -> - call_right left_mcode name i - (function name -> Ast0.Id(name)) - | Ast0.MetaId(name,a,b) -> - call_right left_mcode name i - (function name -> Ast0.MetaId(name,a,b)) - | Ast0.MetaFunc(name,a,b) -> - call_right left_mcode name i - (function name -> Ast0.MetaFunc(name,a,b)) - | Ast0.MetaLocalFunc(name,a,b) -> - call_right left_mcode name i - (function name -> Ast0.MetaLocalFunc(name,a,b)) - | Ast0.OptIdent(id) -> - call_right left_ident id i (function id -> Ast0.OptIdent(id)) - | Ast0.UniqueIdent(id) -> - call_right left_ident id i (function id -> Ast0.UniqueIdent(id)) + Ast0.Id(name) -> + call_right left_mcode name i (function name -> Ast0.Id(name)) + | Ast0.MetaId(name,a,b,c) -> + call_right left_mcode name i (function name -> Ast0.MetaId(name,a,b,c)) + | Ast0.MetaFunc(name,a,b) -> + call_right left_mcode name i (function name -> Ast0.MetaFunc(name,a,b)) + | Ast0.MetaLocalFunc(name,a,b) -> + call_right left_mcode name i + (function name -> Ast0.MetaLocalFunc(name,a,b)) + | Ast0.DisjId(starter,ids,mids,ender) -> None + | Ast0.OptIdent(id) -> + call_right left_ident id i (function id -> Ast0.OptIdent(id)) + | Ast0.UniqueIdent(id) -> + call_right left_ident id i (function id -> Ast0.UniqueIdent(id)) + | Ast0.AsIdent(id,asid) -> failwith "not possible" let left_fundecl name fninfo = let fncall_right processor data cont = @@ -260,6 +271,10 @@ let rec left_decl decl = | Ast0.MetaField(name,pure) -> call_right right_mcode name decl (function name -> Ast0.MetaField(name,pure)) + | Ast0.MetaFieldList(name,lenname,pure) -> + call_right right_mcode name decl + (function name -> Ast0.MetaFieldList(name,lenname,pure)) + | Ast0.AsDecl(decl,asdecl) -> failwith "not possible" | Ast0.Init(Some stg,ty,id,eq,ini,sem) -> call_right left_mcode stg decl (function stg -> Ast0.Init(Some stg,ty,id,eq,ini,sem)) @@ -275,6 +290,9 @@ let rec left_decl decl = | Ast0.MacroDecl(name,lp,args,rp,sem) -> call_right left_ident name decl (function name -> Ast0.MacroDecl(name,lp,args,rp,sem)) + | Ast0.MacroDeclInit(name,lp,args,rp,eq,ini,sem) -> + call_right left_ident name decl + (function name -> Ast0.MacroDeclInit(name,lp,args,rp,eq,ini,sem)) | Ast0.TyDecl(ty,sem) -> call_right left_ty ty decl (function ty -> Ast0.TyDecl(ty,sem)) | Ast0.Typedef(stg,ty,id,sem) -> @@ -322,12 +340,12 @@ let process = None -> Ast0.unwrap s | Some (pragmas,body) -> Ast0.While(whl,lp,exp,rp,body,update_before pragmas aft)) - | Ast0.For(fr,lp,e1,sem1,e2,sem2,e3,rp,body,aft) -> + | Ast0.For(fr,lp,first,e2,sem2,e3,rp,body,aft) -> (match right_statement body with None -> Ast0.unwrap s | Some (pragmas,body) -> Ast0.For - (fr,lp,e1,sem1,e2,sem2,e3,rp,body, + (fr,lp,first,e2,sem2,e3,rp,body, update_before pragmas aft)) | Ast0.Iterator(nm,lp,args,rp,body,aft) -> (match right_statement body with