From: Julia Lawall <julia.lawall@inria.fr>
To: Jaskaran Singh <jaskaran.singh@collabora.com>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] [PATCH 02/20] parsing_cocci: parser: Wrap SmPL Attributes
Date: Mon, 6 Jul 2020 22:03:47 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.22.394.2007062203360.2521@hadrien> (raw)
In-Reply-To: <20200703175931.1693-3-jaskaran.singh@collabora.com>
On Fri, 3 Jul 2020, Jaskaran Singh wrote:
> Attributes are wrapped in the SmPL AST. Reciprocate this and wrap
> attributes in the SmPL parser.
This doesn't apply for me.
julia
>
> Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com>
> ---
> parsing_cocci/parse_aux.ml | 3 +++
> parsing_cocci/parse_aux.mli | 7 +++++++
> parsing_cocci/parser_cocci_menhir.mly | 18 ++++++++++--------
> 3 files changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/parsing_cocci/parse_aux.ml b/parsing_cocci/parse_aux.ml
> index b5d1afb4..f2036bfc 100644
> --- a/parsing_cocci/parse_aux.ml
> +++ b/parsing_cocci/parse_aux.ml
> @@ -152,6 +152,9 @@ let logic_op ast_op left op right =
> let make_cv cv ty =
> match cv with None -> ty | Some x -> Ast0.wrap (Ast0.ConstVol(x,ty))
>
> +let make_attr attr =
> + Ast0.wrap(Ast0.Attribute(id2mcode attr))
> +
> let top_dots l = Ast0.wrap l
>
> (* here the offset is that of the first in the sequence of *s, not that of
> diff --git a/parsing_cocci/parse_aux.mli b/parsing_cocci/parse_aux.mli
> index 91d7cb26..0ecf10b0 100644
> --- a/parsing_cocci/parse_aux.mli
> +++ b/parsing_cocci/parse_aux.mli
> @@ -151,6 +151,13 @@ val logic_op :
> string -> Ast0_cocci.expression -> Ast0_cocci.base_expression Ast0_cocci.wrap
> val make_cv :
> Ast_cocci.const_vol Ast0_cocci.mcode option -> Ast0_cocci.typeC -> Ast0_cocci.typeC
> +val make_attr:
> + string *
> + (Data.line_type * int * int * int * int * int *
> + (Ast_cocci.added_string * Ast0_cocci.position_info) list *
> + (Ast_cocci.added_string * Ast0_cocci.position_info) list *
> + Ast0_cocci.anything list * string) ->
> + Ast0_cocci.attr
> val top_dots : 'a -> 'a Ast0_cocci.wrap
> val pointerify :
> Ast0_cocci.typeC ->
> diff --git a/parsing_cocci/parser_cocci_menhir.mly b/parsing_cocci/parser_cocci_menhir.mly
> index 63cb8b5e..32bcd63c 100644
> --- a/parsing_cocci/parser_cocci_menhir.mly
> +++ b/parsing_cocci/parser_cocci_menhir.mly
> @@ -1495,11 +1495,11 @@ fninfo:
> let _ = List.find (function Ast0.FInline(_) -> true | _ -> false) $2 in
> raise (Semantic_cocci.Semantic "duplicate inline")
> with Not_found -> (Ast0.FInline(P.clt2mcode "inline" $1))::$2 }
> - | Tattr fninfo
> + | a=Tattr fninfo
> { try
> let _ = List.find (function Ast0.FAttr(_) -> true | _ -> false) $2 in
> raise (Semantic_cocci.Semantic "multiple attributes")
> - with Not_found -> (Ast0.FAttr(P.id2mcode $1))::$2 }
> + with Not_found -> (Ast0.FAttr(P.make_attr a))::$2 }
>
> fninfo_nt:
> /* empty */ { [] }
> @@ -1514,11 +1514,11 @@ fninfo_nt:
> let _ = List.find (function Ast0.FInline(_) -> true | _ -> false) $2 in
> raise (Semantic_cocci.Semantic "duplicate inline")
> with Not_found -> (Ast0.FInline(P.clt2mcode "inline" $1))::$2 }
> - | Tattr fninfo_nt
> + | a=Tattr fninfo_nt
> { try
> let _ = List.find (function Ast0.FAttr(_) -> true | _ -> false) $2 in
> raise (Semantic_cocci.Semantic "duplicate init")
> - with Not_found -> (Ast0.FAttr(P.id2mcode $1))::$2 }
> + with Not_found -> (Ast0.FAttr(P.make_attr a))::$2 }
>
> storage:
> s=Tstatic { P.clt2mcode Ast.Static s }
> @@ -3227,12 +3227,14 @@ script_virt_name_decl:
>
> %inline
> attr_list:
> - { [] }
> - | a=Tattr f=full_attr_list {P.id2mcode a::f}
> + { [] }
> + | Tattr f=full_attr_list
> + { let a = P.make_attr $1 in a::f }
>
> full_attr_list:
> - { [] }
> - | Tattr full_attr_list {P.id2mcode $1::$2}
> + { [] }
> + | Tattr f=full_attr_list
> + { let a = P.make_attr $1 in a::f }
>
> anything: /* used for script code */
> TIdentifier { "identifier" }
> --
> 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-06 20:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-03 17:59 [Cocci] [PATCH 00/20] parsing_cocci: Wrap SmPL Attributes Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 01/20] parsing_cocci: ast0_cocci: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 02/20] parsing_cocci: parser: " Jaskaran Singh
2020-07-06 20:03 ` Julia Lawall [this message]
2020-07-07 9:51 ` Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 03/20] parsing_cocci: visitor_ast0: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 04/20] parsing_cocci: adjust_pragmas: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 05/20] parsing_cocci: arity: " Jaskaran Singh
2020-07-06 20:04 ` Julia Lawall
2020-07-03 17:59 ` [Cocci] [PATCH 06/20] parsing_cocci: compute_lines: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 07/20] parsing_cocci: context_neg: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 08/20] parsing_cocci: iso_pattern: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 09/20] parsing_cocci: index: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 10/20] parsing_cocci: unparse_ast0: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 11/20] parsing_cocci: ast0toast: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 12/20] parsing_cocci: ast_cocci: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 13/20] parsing_cocci: visitor_ast: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 14/20] parsing_cocci: get_constants2: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 15/20] parsing_cocci: safe_for_multi_decls: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 16/20] parsing_cocci: unify_ast: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 17/20] parsing_cocci: pretty_print_cocci: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 18/20] parsing_c: unparse_cocci: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 19/20] engine: cocci_vs_c: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 20/20] ocaml: coccilib: " Jaskaran Singh
2020-07-08 12:53 [Cocci] [PATCH v2 00/20] parsing_cocci: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 02/20] parsing_cocci: parser: " 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=alpine.DEB.2.22.394.2007062203360.2521@hadrien \
--to=julia.lawall@inria.fr \
--cc=cocci@systeme.lip6.fr \
--cc=jaskaran.singh@collabora.com \
/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).