aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/parser/state.ixx
blob: 15a9d1a3413c7271d4514d1684d2552fb85d19d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// file      : xsde/cxx/parser/state.ixx
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

namespace xsde
{
  namespace cxx
  {
    namespace parser
    {
      // parser_stack
      //
      inline parser_stack::
      parser_stack (parser_state& first)
          : stack_ (sizeof (parser_state), &first)
      {
      }

#ifdef XSDE_EXCEPTIONS
      inline void parser_stack::
#else
      inline stack::error parser_stack::
#endif
      push (parser_state& s)
      {
#ifdef XSDE_EXCEPTIONS
        stack_.push ();
#else
        if (stack::error e = stack_.push ())
          return e;
#endif

        *static_cast<parser_state*> (stack_.top ()) = s;

#ifndef XSDE_EXCEPTIONS
        return stack::error_none;
#endif
      }

      inline void parser_stack::
      pop ()
      {
        stack_.pop ();
      }

      inline parser_state& parser_stack::
      top ()
      {
        return *static_cast<parser_state*> (stack_.top ());
      }

      inline void parser_stack::
      clear ()
      {
        stack_.clear ();
      }
    }
  }
}