Mercurial > octave
changeset 33295:979a51024c94
new class to store delimiters surrounding parse tree elements
* delimiter-list.h: New file.
* libinterp/parse-tree/module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 02 Apr 2024 13:25:59 -0400 |
parents | 561b46657d4c |
children | 70b7f1c285c7 |
files | libinterp/parse-tree/module.mk libinterp/parse-tree/pt-delimiter-list.h |
diffstat | 2 files changed, 60 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/module.mk Tue Apr 02 13:13:17 2024 -0400 +++ b/libinterp/parse-tree/module.mk Tue Apr 02 13:25:59 2024 -0400 @@ -23,6 +23,7 @@ %reldir%/pt-colon.h \ %reldir%/pt-const.h \ %reldir%/pt-decl.h \ + %reldir%/pt-delimiter-list.h \ %reldir%/pt-eval.h \ %reldir%/pt-except.h \ %reldir%/pt-exp.h \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libinterp/parse-tree/pt-delimiter-list.h Tue Apr 02 13:25:59 2024 -0400 @@ -0,0 +1,59 @@ +//////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024 The Octave Project Developers +// +// See the file COPYRIGHT.md in the top-level directory of this +// distribution or <https://octave.org/copyright/>. +// +// This file is part of Octave. +// +// Octave is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Octave is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Octave; see the file COPYING. If not, see +// <https://www.gnu.org/licenses/>. +// +//////////////////////////////////////////////////////////////////////// + +#if ! defined (octave_tree_delimiter_list_h) +#define octave_tree_delimiter_list_h 1 + +#include "octave-config.h" + +#include <stack> + +#include "token.h" + +OCTAVE_BEGIN_NAMESPACE(octave) + +class tree_delimiter_list +{ +public: + + typedef std::pair<token, token> element_type; + + OCTAVE_DEFAULT_CONSTRUCT_COPY_MOVE_DELETE (tree_delimiter_list) + + size_t count () const { return m_delimiters.size (); } + + void push (const token& open_delim, const token& close_delim) + { + m_delimiters.push (element_type (open_delim, close_delim)); + } + +private: + + std::stack<element_type> m_delimiters; +}; + +OCTAVE_END_NAMESPACE(octave) + +#endif