#pragma once #include "dtcore/inc/dtscriptdescriptor.h" #include "dtcore/inc/dtscriptstatementcompound.h" namespace dt { class ScriptParserState { public: ScriptParserState(const ScriptDescriptor& script, ScriptStatementCompound* root); ScriptStatementCompound* GetRoot() const { return m_Root; } void PushBlock(ScriptStatementCompound* stm) { m_CompoundStack.PushBack(stm); } bool PopBlock(); ScriptStatementCompound* GetParentStatement() const { return m_CompoundStack.Back(); } SizeT GetCompoundStackSize() const { return m_CompoundStack.Size(); } void PushBack(ScriptStatement* stm); void PushAsRoot(ScriptStatementCompound* stm); ScriptStatement* GetLast() const { return m_Last; } void SetCurrentLineById(int id); const ScriptLines& GetLines() const { return m_Script.GetLines(); } const ScriptLine& GetCurrentLine() const { return m_Script.GetLines()[m_LineIndex]; } bool HasNextLine() const { return m_LineIndex < m_Script.GetLines().Size() - 1; } const ScriptLine& GetNextLine() { return m_Script.GetLines()[++m_LineIndex]; } private: ScriptDescriptor m_Script; SizeT m_LineIndex; ScriptStatementCompound* m_Root; Vector m_CompoundStack; ScriptStatement* m_Last; }; }