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
7
#pragma once
8
9
#include <stack>
10
39
struct
ContextExpectations
{
40
bool
can_take_primitive
=
true
;
41
bool
can_take_object
=
false
;
42
};
43
52
class
ExpectationsStack
{
53
private
:
54
std::stack<ContextExpectations>
stack
;
55
static
constexpr
ContextExpectations
default_expectations
= {
true
,
false
};
56
public
:
57
void
push
(
const
ContextExpectations
& expectations) {
58
stack
.push(expectations);
59
}
60
61
void
push
(
bool
can_take_primitive,
bool
can_take_object) {
62
stack
.push({can_take_primitive, can_take_object});
63
}
64
65
void
pop
() {
66
if
(!
stack
.empty())
stack
.pop();
67
}
68
69
ContextExpectations
top
()
const
{
70
if
(
stack
.empty())
return
default_expectations
;
71
return
stack
.top();
72
}
73
74
bool
canTakePrimitive
()
const
{
75
if
(
stack
.empty())
return
default_expectations
.
can_take_primitive
;
76
return
stack
.top().can_take_primitive;
77
}
78
79
bool
canTakeObject
()
const
{
80
if
(
stack
.empty())
return
default_expectations
.
can_take_object
;
81
return
stack
.top().can_take_object;
82
}
83
};
ExpectationsStack
A stack to manage ContextExpectations during AST traversal.
Definition
ContextExpectations.h:52
ExpectationsStack::push
void push(const ContextExpectations &expectations)
Definition
ContextExpectations.h:57
ExpectationsStack::canTakeObject
bool canTakeObject() const
Definition
ContextExpectations.h:79
ExpectationsStack::canTakePrimitive
bool canTakePrimitive() const
Definition
ContextExpectations.h:74
ExpectationsStack::stack
std::stack< ContextExpectations > stack
Definition
ContextExpectations.h:54
ExpectationsStack::top
ContextExpectations top() const
Definition
ContextExpectations.h:69
ExpectationsStack::pop
void pop()
Definition
ContextExpectations.h:65
ExpectationsStack::default_expectations
static constexpr ContextExpectations default_expectations
Definition
ContextExpectations.h:55
ExpectationsStack::push
void push(bool can_take_primitive, bool can_take_object)
Definition
ContextExpectations.h:61
ContextExpectations
Represents the expectations for the current parsing context.
Definition
ContextExpectations.h:39
ContextExpectations::can_take_primitive
bool can_take_primitive
Definition
ContextExpectations.h:40
ContextExpectations::can_take_object
bool can_take_object
Definition
ContextExpectations.h:41
Generated by
1.9.8