polserver/pol-core/bscript/compiler/analyzer/FlowControlScopes.h
Eric Swanson 1a3619b231
Add support for while loops (#268)
Adds:
- analyzer/FlowControlScope: Registers a break/continue scope
- analyzer/FlowControlScopes: Registry for break/continue scopes
- ast/LabelableStatement: Base class for AST nodes that can be labelled (loops and case)
- ast/LoopStatement: Base class for AST nodes for loops (have a break and continue label)
- ast/WhileLoop: AST node for a while loop
2020-09-03 19:46:27 -07:00

36 lines
765 B
C++

#ifndef POLSERVER_FLOWCONTROLSCOPES_H
#define POLSERVER_FLOWCONTROLSCOPES_H
#include <map>
#include <string>
namespace Pol::Bscript::Compiler
{
class FlowControlScope;
class Report;
class Variables;
class FlowControlScopes
{
public:
FlowControlScopes( const Variables& local_variables, Report& report );
const FlowControlScope* find( const std::string& name );
bool any() const;
private:
friend class FlowControlScope;
void push( const FlowControlScope* );
void pop( const FlowControlScope* );
const FlowControlScope* current_unnamed_scope;
std::map<std::string, const FlowControlScope*> named_scopes;
const Variables& local_variables;
Report& report;
};
} // namespace Pol::Bscript::Compiler
#endif // POLSERVER_FLOWCONTROLSCOPES_H