diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/ExecutionIterator.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/ExecutionIterator.h deleted file mode 100644 index 03c6842b7c..0000000000 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/ExecutionIterator.h +++ /dev/null @@ -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 -#include -#include -#include - -#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 m_iteratedStatements; - - ExecutionVisitor m_visitor; - // final queue of iterated nodes - AZStd::vector m_queue; - // current position in the final queue - NodePtrConstList::iterator m_current = nullptr; - }; - - } // namespace Parser - -} // namepsace ScriptCanvas diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/Parser.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/Parser.h deleted file mode 100644 index f6a02e24c8..0000000000 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/Parser.h +++ /dev/null @@ -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 -#include -#include -#include -#include - -#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 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&& root); - void AddChild(AST::NodePtr&& child); - - Grammar::eRule GetExpectedRule() const; - - protected: - void AddError(ParseError&& error); - void AddStatement(AST::SmartPtrConst&& statement); - void FindInitialStatements(); - void FindNextSourceNode(); - void InitializeGraphBlock(); - - AST::SmartPtrConst CreateBinaryOperator(const Node& node, Grammar::eRule operatorType, AST::SmartPtrConst&& lhs, AST::SmartPtrConst&& rhs); - AST::SmartPtrConst ParseBinaryOperation(const Node& node, Grammar::eRule operatorType); - AST::SmartPtrConst ParseExpression(const Node& node); - AST::SmartPtrConst ParseExpressionList(const Node& node); - AST::NodePtrConst ParseFunctionCall(const Node& node, const char* functionName); - AST::SmartPtrConst ParseFunctionCallAsStatement(const Node& node, const char* functionName); - AST::SmartPtrConst 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 m_currentBlock; - AST::SmartPtr m_root; - AZStd::set m_consumedSourceNodes; - AZStd::vector m_errors; - ParserVisitor m_visitor; - }; - } // namespace Grammar - -} // namespace ScriptCanvas}