diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/ast/chunk-list.hh | |
Diffstat (limited to 'tiger-compiler/src/ast/chunk-list.hh')
| -rw-r--r-- | tiger-compiler/src/ast/chunk-list.hh | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/chunk-list.hh b/tiger-compiler/src/ast/chunk-list.hh new file mode 100644 index 0000000..3674e27 --- /dev/null +++ b/tiger-compiler/src/ast/chunk-list.hh @@ -0,0 +1,80 @@ +/** + ** \file ast/chunk-list.hh + ** \brief Declaration of ast::ChunkList. + */ + +#pragma once + +#include <ast/ast.hh> + +namespace ast +{ + /// ChunkList. + class ChunkList : public Ast + { + public: + using list_type = std::list<ChunkInterface*>; + /// Define value type + using value_type = list_type::value_type; + /// Define size type + using size_type = list_type::size_type; + /// Define reference to value type + using reference = list_type::reference; + /// Define const reference to value type + using const_reference = list_type::const_reference; + /// Define shorthand type for D-declations iterator. + using iterator = list_type::iterator; + /// Define shorthand type for D-declations const iterator. + using const_iterator = list_type::const_iterator; + + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + + /// Prepend \a d. + void push_front(ChunkInterface* d); + /// Append \a d. + void emplace_back(ChunkInterface* d); + + /// Splice the content of \a ds in front of this list. + void splice_front(ChunkList& ds); + /// Splice the content of \a ds at the back this list. + void splice_back(ChunkList& ds); + + /// Construct a ChunkList node. + ChunkList(const Location& location); + + public: + /** \name Ctor & dtor. + ** \{ */ + /// Construct a ChunkList node. + ChunkList(const Location& location, const ChunkList::list_type& chunks); + ChunkList(const ChunkList&) = delete; + ChunkList& operator=(const ChunkList&) = delete; + /// Destroy a ChunkList node. + ~ChunkList() override; + /** \} */ + + /// \name Visitors entry point. + /// \{ */ + /// Accept a const visitor \a v. + void accept(ConstVisitor& v) const override; + /// Accept a non-const visitor \a v. + void accept(Visitor& v) override; + /// \} + + /** \name Accessors. + ** \{ */ + /// Return declarations. + const ChunkList::list_type& chunks_get() const; + /// Return declarations. + ChunkList::list_type& chunks_get(); + /** \} */ + + protected: + /// Declarations. + ChunkList::list_type chunks_; + }; +} // namespace ast +#include <ast/chunk-list.hxx> |
