Removes ExecutionIterator.h and Parser.h from Gems/ScriptCanvas
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/containers/set.h>
|
||||
#include <AzCore/std/containers/stack.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <ScriptCanvas/Core/Core.h>
|
||||
|
||||
#include "ExecutionVisitor.h"
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
class Graph;
|
||||
class Node;
|
||||
|
||||
namespace Grammar
|
||||
{
|
||||
/**
|
||||
This is the effective lexer of the system. It properly identifies which canvas node is the next 'token'
|
||||
*/
|
||||
class ExecutionIterator
|
||||
{
|
||||
friend class ExecutionVisitor;
|
||||
|
||||
public:
|
||||
ExecutionIterator();
|
||||
ExecutionIterator(const Graph& graph);
|
||||
ExecutionIterator(const Node& block);
|
||||
|
||||
bool Begin();
|
||||
bool Begin(const Graph& graph);
|
||||
bool Begin(const Node& block);
|
||||
AZ_INLINE const Node* GetCurrentToken() const { return *m_current; }
|
||||
const Node* operator->() const;
|
||||
explicit operator bool() const;
|
||||
bool operator!() const;
|
||||
ExecutionIterator& operator++();
|
||||
void PrettyPrint() const;
|
||||
|
||||
protected:
|
||||
static const Node* FindNextStatement(const Node& current);
|
||||
|
||||
void PushFunctionCall();
|
||||
void PushExpression();
|
||||
void PushStatement();
|
||||
void BuildNextStatement();
|
||||
|
||||
bool BuildQueue(const Graph& graph);
|
||||
bool BuildQueue(const Node& node);
|
||||
bool BuildQueue();
|
||||
|
||||
private:
|
||||
// track whether we're in a expression stack
|
||||
bool m_pushingExpressions = false;
|
||||
// current canvas node of any type
|
||||
const Node* m_currentSourceNode = nullptr;
|
||||
// current executable statement that isn't just an expression
|
||||
const Node* m_currentSourceStatementNode = nullptr;
|
||||
// first statement in the block entry
|
||||
const Node* m_currentSourceStatementRoot = nullptr;
|
||||
// canvas source
|
||||
const Graph* m_source = nullptr;
|
||||
|
||||
NodeIdList m_sourceNodes;
|
||||
// "parent-less" executable statements, or parented only to a start node
|
||||
NodePtrConstList m_currentSourceInitialStatements;
|
||||
// detect infinite loops
|
||||
AZStd::set<const Node*> m_iteratedStatements;
|
||||
|
||||
ExecutionVisitor m_visitor;
|
||||
// final queue of iterated nodes
|
||||
AZStd::vector<const Node*> m_queue;
|
||||
// current position in the final queue
|
||||
NodePtrConstList::iterator m_current = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Parser
|
||||
|
||||
} // namepsace ScriptCanvas
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/containers/set.h>
|
||||
#include <ScriptCanvas/AST/AST.h>
|
||||
#include <ScriptCanvas/AST/Nodes.h>
|
||||
#include <ScriptCanvas/Core/Core.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
|
||||
#include "ExecutionIterator.h"
|
||||
#include "ParseError.h"
|
||||
#include "ParserVisitor.h"
|
||||
|
||||
namespace ScriptCanvas
|
||||
{
|
||||
class Graph;
|
||||
class Node;
|
||||
|
||||
namespace AST
|
||||
{
|
||||
class Block;
|
||||
}
|
||||
|
||||
namespace Grammar
|
||||
{
|
||||
NodePtrConstList FindInitialStatements(const NodeIdList& nodes);
|
||||
NodePtrConstList FindInitialStatements(const Node& node);
|
||||
const Node* FindNextStatement(const Node& node);
|
||||
|
||||
class Parser
|
||||
{
|
||||
friend class ParserVisitor;
|
||||
|
||||
public:
|
||||
Parser(const Graph& graph);
|
||||
|
||||
AZ_CLASS_ALLOCATOR(Parser, AZ::SystemAllocator, 0);
|
||||
|
||||
AST::SmartPtrConst<AST::Block> Parse();
|
||||
void ConsumeToken();
|
||||
const Node* GetToken() const;
|
||||
const Graph& GetSource() const;
|
||||
const NodeIdList& GetSourceNodeIDs() const;
|
||||
AST::NodePtr GetTree() const;
|
||||
bool IsValid() const;
|
||||
void SetRoot(AST::SmartPtr<AST::Block>&& root);
|
||||
void AddChild(AST::NodePtr&& child);
|
||||
|
||||
Grammar::eRule GetExpectedRule() const;
|
||||
|
||||
protected:
|
||||
void AddError(ParseError&& error);
|
||||
void AddStatement(AST::SmartPtrConst<AST::Statement>&& statement);
|
||||
void FindInitialStatements();
|
||||
void FindNextSourceNode();
|
||||
void InitializeGraphBlock();
|
||||
|
||||
AST::SmartPtrConst<AST::BinaryOperation> CreateBinaryOperator(const Node& node, Grammar::eRule operatorType, AST::SmartPtrConst<AST::Expression>&& lhs, AST::SmartPtrConst<AST::Expression>&& rhs);
|
||||
AST::SmartPtrConst<AST::BinaryOperation> ParseBinaryOperation(const Node& node, Grammar::eRule operatorType);
|
||||
AST::SmartPtrConst<AST::Expression> ParseExpression(const Node& node);
|
||||
AST::SmartPtrConst<AST::ExpressionList> ParseExpressionList(const Node& node);
|
||||
AST::NodePtrConst ParseFunctionCall(const Node& node, const char* functionName);
|
||||
AST::SmartPtrConst<AST::FunctionCallAsStatement> ParseFunctionCallAsStatement(const Node& node, const char* functionName);
|
||||
AST::SmartPtrConst<AST::Numeral> ParseNumeral(const Node& node);
|
||||
|
||||
private:
|
||||
class ExpressionScoper
|
||||
{
|
||||
public:
|
||||
AZ_INLINE ExpressionScoper(Parser& parser)
|
||||
: m_parser(parser)
|
||||
{
|
||||
++m_parser.m_expressionDepth;
|
||||
}
|
||||
|
||||
AZ_INLINE ~ExpressionScoper()
|
||||
{
|
||||
--m_parser.m_expressionDepth;
|
||||
}
|
||||
|
||||
private:
|
||||
Parser& m_parser;
|
||||
};
|
||||
|
||||
friend class ExpressionScoper;
|
||||
|
||||
int m_expressionDepth = 0;
|
||||
Grammar::ExecutionIterator m_executionIterator;
|
||||
AST::SmartPtr<AST::Block> m_currentBlock;
|
||||
AST::SmartPtr<AST::Block> m_root;
|
||||
AZStd::set<ID> m_consumedSourceNodes;
|
||||
AZStd::vector<ParseError> m_errors;
|
||||
ParserVisitor m_visitor;
|
||||
};
|
||||
} // namespace Grammar
|
||||
|
||||
} // namespace ScriptCanvas}
|
||||
Reference in New Issue
Block a user