/** * * OOAS Compiler - C++ AST * * Copyright 2015, AIT Austrian Institute of Technology. * All rights reserved. * * SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED. * * If you modify the file please update the list of contributors below to in- * clude your name. Please also stick to the coding convention of using TABs * to do the basic (block-level) indentation and spaces for anything after * that. (Enable the display of special chars and it should be pretty obvious * what this means.) Also, remove all trailing whitespace. * * Contributors: * Willibald Krenn (AIT) * Stephan Zimmerer (AIT) * Christoph Czurda (AIT) * */ #pragma once #include #include #include #include namespace Ast { /** * You must not change the assigned values as this * needs to be kept in sync with the definitions in Argos! */ enum class StatementKind : std::uint8_t { GuardedCommand = 0, Call = 1, Assignment = 2, SeqBlock = 3, NondetBlock = 4, PrioBlock = 5, Skip = 6, Abort = 7, Kill = 8, QualConstraint = 9, Break = 10, STATEMENTKIND_LAST_ITEM = Break }; #define STATEMENTKIND_NR_ITEMS ((std::uint8_t)StatementKind::STATEMENTKIND_LAST_ITEM + 1) class Statement: public AstElement { protected: typedef Statement* (*ConstrPtr)(); typedef Statement* (*CopyConstrPtr)(const Statement& toCopy); StatementKind m_kind; std::int32_t m_line; std::int32_t m_pos; Statement(StatementKind kind): AstElement(AstNodeTypeEnum::statement), m_kind(kind), m_line(-1), m_pos(-1) {}; Statement(const Statement& toCopy): AstElement(AstNodeTypeEnum::statement), m_kind(toCopy.m_kind), m_line(toCopy.m_line), m_pos(toCopy.m_pos) {} static Base::FuncPtr s_stmntVmt [2][STATEMENTKIND_NR_ITEMS]; static Statement* createVirtual(StatementKind aType); // virtual constructor used by Ast static Statement* createVirtual(const Statement& toCopy); // virtual copy constructor used by Ast public: friend class Ast; void init(std::int32_t line, std::int32_t col) { m_line = line; m_pos = col; } StatementKind kind() const {return m_kind;} std::int32_t line() const {return m_line;}; std::int32_t pos() const {return m_pos;}; void accept(IAstVisitor& visitor) override; std::string toString() const { std::string result = "Stmnt "; result += std::to_string((std::uint32_t) m_kind ); result += " at "; result += std::to_string(m_line); result += ":"; result += std::to_string(m_pos); return result; } }; }