GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
pt-delimiter-list.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2024-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_tree_delimiter_list_h)
27#define octave_tree_delimiter_list_h 1
28
29#include "octave-config.h"
30
31#include <stack>
32
33#include "filepos.h"
34#include "token.h"
35
37
39{
40public:
41
42 typedef std::pair<token, token> element_type;
43
44 OCTAVE_DEFAULT_CONSTRUCT_COPY_MOVE_DELETE (tree_delimiter_list)
45
46 size_t count () const { return m_delimiters.size (); }
47
48 bool empty () const { return m_delimiters.empty (); }
49
50 void push (const token& open_delim, const token& close_delim)
51 {
52 m_delimiters.push (element_type (open_delim, close_delim));
53 }
54
56 {
57 if (m_delimiters.empty ())
58 return filepos ();
59
60 const element_type& elt = m_delimiters.top ();
61 return elt.first.beg_pos ();
62 }
63
65 {
66 if (m_delimiters.empty ())
67 return filepos ();
68
69 const element_type& elt = m_delimiters.top ();
70 return elt.second.end_pos ();
71 }
72
73private:
74
75 std::stack<element_type> m_delimiters;
76};
77
78OCTAVE_END_NAMESPACE(octave)
79
80#endif
Definition token.h:42
void push(const token &open_delim, const token &close_delim)
filepos beg_pos() const
filepos end_pos() const
std::pair< token, token > element_type
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn