diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-04-05 12:36:41 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:28:46 +0100 |
commit | 9a7a79ebafdd29d9d46e1dc2fc930629b434073b (patch) | |
tree | ab75c19dfaa2873d13b8c027199810f171c89e6e /gcc/rust/ast | |
parent | df46f9ee7c7c42449c015417aa1f470da4ca7267 (diff) | |
download | gcc-9a7a79ebafdd29d9d46e1dc2fc930629b434073b.zip gcc-9a7a79ebafdd29d9d46e1dc2fc930629b434073b.tar.gz gcc-9a7a79ebafdd29d9d46e1dc2fc930629b434073b.tar.bz2 |
gccrs: ast: Add difference between attributes
Add a boolean to tell inner and outer attributes ast nodes appart. This
meant refactoring a bit their parsing function.
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add boolean for differenciation.
* parse/rust-parse-impl.h (Parser::parse_doc_comment): Change
function interface to make code cleaner. It should return a body
instead of the whole attribute.
(Parser::parse_inner_attribute): Specify the inner status of the
node.
(Parser::parse_attribute_body): Change function interface to
make the code cleaner much like parse_doc_comment.
(Parser::parse_outer_attribute): Specify outer status of the
node.
* parse/rust-parse.h: Update functions prototypes.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 5c76372..0d2a16b 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -456,6 +456,8 @@ private: Location locus; + bool inner_attribute; + // TODO: maybe a variable storing whether attr input is parsed or not public: @@ -464,8 +466,9 @@ public: // Constructor has pointer AttrInput for polymorphism reasons Attribute (SimplePath path, std::unique_ptr<AttrInput> input, - Location locus = Location ()) - : path (std::move (path)), attr_input (std::move (input)), locus (locus) + Location locus = Location (), bool inner_attribute = false) + : path (std::move (path)), attr_input (std::move (input)), locus (locus), + inner_attribute (inner_attribute) {} // default destructor @@ -554,6 +557,8 @@ public: std::string as_string () const; + bool is_inner_attribute () const { return inner_attribute; } + // no visitor pattern as not currently polymorphic const SimplePath &get_path () const { return path; } |