From: Jaskaran Singh <jaskaran.singh@collabora.com>
To: cocci@systeme.lip6.fr
Subject: [Cocci] [PATCH 10/20] parsing_cocci: unparse_ast0: Wrap SmPL Attributes
Date: Wed, 8 Jul 2020 18:23:46 +0530 [thread overview]
Message-ID: <20200708125357.8998-11-jaskaran.singh@collabora.com> (raw)
In-Reply-To: <20200708125357.8998-1-jaskaran.singh@collabora.com>
Attributes are wrapped in the SmPL AST. Reflect these changes in
unparse_ast0.ml.
Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com>
---
parsing_cocci/unparse_ast0.ml | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/parsing_cocci/unparse_ast0.ml b/parsing_cocci/unparse_ast0.ml
index 81bbb71a..109f1844 100644
--- a/parsing_cocci/unparse_ast0.ml
+++ b/parsing_cocci/unparse_ast0.ml
@@ -223,8 +223,7 @@ let rec expression e =
expression exp; mcode print_string ar; ident field
| Ast0.Cast(lp,ty,attr,rp,exp) ->
mcode print_string_box lp; typeC ty; close_box();
- (if not (attr = []) then print_string " ");
- print_between (fun _ -> print_string " ") (mcode print_string) attr;
+ print_attribute_list attr;
mcode print_string rp; expression exp
| Ast0.SizeOfExpr(szf,exp) ->
mcode print_string szf; expression exp
@@ -408,15 +407,13 @@ and declaration d =
| Ast0.Init(stg,ty,id,attr,eq,ini,sem) ->
print_option (mcode U.storage) stg;
print_named_type ty id;
- (if not (attr = []) then print_string " ");
- print_between (fun _ -> print_string " ") (mcode print_string) attr;
+ print_attribute_list attr;
print_string " ";
mcode print_string eq; print_string " "; initialiser ini;
mcode print_string sem
| Ast0.UnInit(stg,ty,id,attr,sem) ->
print_option (mcode U.storage) stg; print_named_type ty id;
- (if not (attr = []) then print_string " ");
- print_between (fun _ -> print_string " ") (mcode print_string) attr;
+ print_attribute_list attr;
mcode print_string sem
| Ast0.FunProto(fninfo,name,lp1,params,va,rp1,sem) ->
List.iter print_fninfo fninfo;
@@ -429,8 +426,7 @@ and declaration d =
ident name; mcode print_string_box lp;
let _ = dots (function _ -> ()) expression args in
close_box(); mcode print_string rp;
- (if not (attr = []) then print_string " ");
- print_between (fun _ -> print_string " ") (mcode print_string) attr;
+ print_attribute_list attr;
mcode print_string sem
| Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
print_option (mcode U.storage) stg;
@@ -442,8 +438,7 @@ and declaration d =
mcode print_string sem
| Ast0.TyDecl(ty,attr,sem) ->
typeC ty;
- (if not (attr = []) then print_string " ");
- print_between (fun _ -> print_string " ") (mcode print_string) attr;
+ print_attribute_list attr;
mcode print_string sem
| Ast0.Typedef(stg,ty,id,sem) ->
mcode print_string stg; typeC ty; typeC id;
@@ -557,16 +552,13 @@ and parameterTypeDef p =
match Ast0.unwrap p with
Ast0.VoidParam(ty,attr) ->
typeC ty;
- (if (attr = []) then print_string " ");
- print_between (fun _ -> print_string " ") (mcode print_string) attr;
+ print_attribute_list attr;
| Ast0.Param(ty,Some id,attr) ->
print_named_type ty id;
- (if (attr = []) then print_string " ");
- print_between (fun _ -> print_string " ") (mcode print_string) attr;
+ print_attribute_list attr;
| Ast0.Param(ty,None,attr) ->
typeC ty;
- (if (attr = []) then print_string " ");
- print_between (fun _ -> print_string " ") (mcode print_string) attr;
+ print_attribute_list attr;
| Ast0.MetaParam(name,_,_) -> mcode print_meta name
| Ast0.MetaParamList(name,_,_,_) -> mcode print_meta name
| Ast0.PComma(cm) -> mcode print_string cm; print_space()
@@ -767,7 +759,15 @@ and print_fninfo = function
Ast0.FStorage(stg) -> mcode U.storage stg
| Ast0.FType(ty) -> typeC ty
| Ast0.FInline(inline) -> mcode print_string inline
- | Ast0.FAttr(attr) -> mcode print_string attr
+ | Ast0.FAttr(attr) -> print_attribute attr
+
+and print_attribute_list attrs =
+ if not (attrs = []) then print_string " ";
+ print_between (fun _ -> print_string " ") print_attribute attrs
+
+and print_attribute a =
+ match Ast0.unwrap a with
+ Ast0.Attribute(attr) -> mcode print_string attr
and whencode notfn alwaysfn = function
Ast0.WhenNot (_,_,a) ->
--
2.21.3
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
next prev parent reply other threads:[~2020-07-08 12:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-08 12:53 [Cocci] [PATCH v2 00/20] parsing_cocci: Wrap SmPL Attributes Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 01/20] parsing_cocci: ast0_cocci: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 02/20] parsing_cocci: parser: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 03/20] parsing_cocci: visitor_ast0: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 04/20] parsing_cocci: adjust_pragmas: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 05/20] parsing_cocci: arity: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 06/20] parsing_cocci: compute_lines: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 07/20] parsing_cocci: context_neg: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 08/20] parsing_cocci: iso_pattern: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 09/20] parsing_cocci: index: " Jaskaran Singh
2020-07-08 12:53 ` Jaskaran Singh [this message]
2020-07-08 12:53 ` [Cocci] [PATCH 11/20] parsing_cocci: ast0toast: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 12/20] parsing_cocci: ast_cocci: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 13/20] parsing_cocci: visitor_ast: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 14/20] parsing_cocci: get_constants2: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 15/20] parsing_cocci: safe_for_multi_decls: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 16/20] parsing_cocci: unify_ast: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 17/20] parsing_cocci: pretty_print_cocci: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 18/20] parsing_c: unparse_cocci: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 19/20] engine: cocci_vs_c: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 20/20] ocaml: coccilib: " Jaskaran Singh
2020-07-08 12:56 ` [Cocci] [PATCH v2 00/20] parsing_cocci: " Jaskaran Singh
-- strict thread matches above, loose matches on Subject: below --
2020-07-03 17:59 [Cocci] [PATCH " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 10/20] parsing_cocci: unparse_ast0: " Jaskaran Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200708125357.8998-11-jaskaran.singh@collabora.com \
--to=jaskaran.singh@collabora.com \
--cc=cocci@systeme.lip6.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).