[Linux-kernel-mentees] [RFC PATCH 18/25] parsing_c: parser: Make abstract_declarator pass attributes
Jaskaran Singh
jaskaransingh7654321 at gmail.com
Fri Apr 24 09:17:54 UTC 2020
The attributes in abstract_declarator can be used for adding parameter
attributes, cast attributes and others to the C AST. Make
abstract_declarator pass these attributes in a tuple.
Signed-off-by: Jaskaran Singh <jaskaransingh7654321 at gmail.com>
---
parsing_c/parser_c.mly | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/parsing_c/parser_c.mly b/parsing_c/parser_c.mly
index da6b9c7b..0c3da206 100644
--- a/parsing_c/parser_c.mly
+++ b/parsing_c/parser_c.mly
@@ -1397,13 +1397,14 @@ tccro: TCCro { dt "tccro" ();$1 }
/*(*-----------------------------------------------------------------------*)*/
abstract_declarator:
- | pointer { snd $1 }
- | direct_abstract_declarator { $1 }
- | pointer direct_abstract_declarator { fun x -> x +> $2 +> (snd $1) }
+ | pointer { $1 }
+ | direct_abstract_declarator { ([], $1) }
+ | pointer direct_abstract_declarator
+ { (fst $1, fun x -> x +> $2 +> (snd $1)) }
direct_abstract_declarator:
| TOPar abstract_declarator TCPar /*(* forunparser: old: $2 *)*/
- { fun x -> mk_ty (ParenType ($2 x)) [$1;$3] }
+ { fun x -> mk_ty (ParenType ((snd $2) x)) [$1;$3] }
| TOCro TCCro
{ fun x -> mk_ty (Array (None, x)) [$1;$2] }
@@ -1461,7 +1462,7 @@ parameter_decl2:
{ LP.kr_impossible();
let ((returnType,hasreg), iihasreg) = fixDeclSpecForParam (snd $1) in
{ p_namei = None;
- p_type = $2 returnType;
+ p_type = (snd $2) returnType;
p_register = hasreg, iihasreg;
}
}
@@ -2118,7 +2119,7 @@ define_val:
}
| decl_spec abstract_declarator
{ let returnType = fixDeclSpecForMacro (snd $1) in
- let typ = $2 returnType in
+ let typ = (snd $2) returnType in
DefineType typ
}
--
2.21.1
More information about the Linux-kernel-mentees
mailing list