Bash++
Bash++ compiler internal documentation
Main Page
Namespaces
Concepts
Classes
Files
File List
File Members
src
listener
ContextExpectations.h
Go to the documentation of this file.
1
6
#pragma once
7
8
#include <stack>
9
38
struct
ContextExpectations
{
39
bool
can_take_primitive
=
true
;
40
bool
can_take_object
=
false
;
41
};
42
51
class
ExpectationsStack
{
52
private
:
53
std::stack<ContextExpectations>
stack
;
54
static
constexpr
ContextExpectations
default_expectations
= {
true
,
false
};
55
public
:
56
void
push
(
const
ContextExpectations
& expectations) {
57
stack
.push(expectations);
58
}
59
60
void
push
(
bool
can_take_primitive,
bool
can_take_object) {
61
stack
.push({can_take_primitive, can_take_object});
62
}
63
64
void
pop
() {
65
if
(!
stack
.empty())
stack
.pop();
66
}
67
68
ContextExpectations
top
()
const
{
69
if
(
stack
.empty())
return
default_expectations
;
70
return
stack
.top();
71
}
72
73
bool
canTakePrimitive
()
const
{
74
if
(
stack
.empty())
return
default_expectations
.
can_take_primitive
;
75
return
stack
.top().can_take_primitive;
76
}
77
78
bool
canTakeObject
()
const
{
79
if
(
stack
.empty())
return
default_expectations
.
can_take_object
;
80
return
stack
.top().can_take_object;
81
}
82
};
ExpectationsStack
A stack to manage ContextExpectations during AST traversal.
Definition
ContextExpectations.h:51
ExpectationsStack::push
void push(const ContextExpectations &expectations)
Definition
ContextExpectations.h:56
ExpectationsStack::canTakeObject
bool canTakeObject() const
Definition
ContextExpectations.h:78
ExpectationsStack::canTakePrimitive
bool canTakePrimitive() const
Definition
ContextExpectations.h:73
ExpectationsStack::stack
std::stack< ContextExpectations > stack
Definition
ContextExpectations.h:53
ExpectationsStack::top
ContextExpectations top() const
Definition
ContextExpectations.h:68
ExpectationsStack::pop
void pop()
Definition
ContextExpectations.h:64
ExpectationsStack::default_expectations
static constexpr ContextExpectations default_expectations
Definition
ContextExpectations.h:54
ExpectationsStack::push
void push(bool can_take_primitive, bool can_take_object)
Definition
ContextExpectations.h:60
ContextExpectations
Represents the expectations for the current parsing context.
Definition
ContextExpectations.h:38
ContextExpectations::can_take_primitive
bool can_take_primitive
Definition
ContextExpectations.h:39
ContextExpectations::can_take_object
bool can_take_object
Definition
ContextExpectations.h:40
Generated by
1.9.8