From 18d84727abe9a6116ca2a01403cd67a11bfc8994 Mon Sep 17 00:00:00 2001 From: Borna Rajkovic Date: Tue, 29 Mar 2022 23:49:32 +0200 Subject: [PATCH] Refactor --- SchemeEditor.pro | 26 --- comdel/parser/astnode.h | 306 +++++++++++++++++++++++++++++- comdel/parser/comdelparser.cpp | 92 ++++----- comdel/parser/comdelparser.h | 23 ++- comdel/parser/parserutil.cpp | 2 +- comdel/parser/parserutil.h | 5 +- comdel/parser/tokenstype.cpp | 6 +- domain/display/display.cpp | 6 - domain/display/display.h | 18 -- domain/display/displayitem.cpp | 6 - domain/display/displayitem.h | 17 -- domain/library/addressspace.cpp | 6 - domain/library/addressspace.h | 19 -- domain/library/attribute.cpp | 5 - domain/library/attribute.h | 21 -- domain/library/bus.cpp | 6 - domain/library/bus.h | 33 ---- domain/library/component.cpp | 6 - domain/library/component.h | 37 ---- domain/library/connection.cpp | 6 - domain/library/connection.h | 23 --- domain/library/library.cpp | 6 - domain/library/library.h | 34 ---- domain/library/pin.cpp | 6 - domain/library/pin.h | 43 ----- domain/library/popup.cpp | 6 - domain/library/popup.h | 37 ---- domain/library/rule.cpp | 6 - domain/library/rule.h | 44 ----- domain/library/value.cpp | 5 - domain/library/value.h | 100 ---------- domain/library/wire.cpp | 6 - domain/library/wire.h | 31 --- domain/schema/instanceattribute.h | 2 +- domain/schema/wireinstance.h | 3 +- 35 files changed, 362 insertions(+), 636 deletions(-) delete mode 100644 domain/display/display.cpp delete mode 100644 domain/display/display.h delete mode 100644 domain/display/displayitem.cpp delete mode 100644 domain/display/displayitem.h delete mode 100644 domain/library/addressspace.cpp delete mode 100644 domain/library/addressspace.h delete mode 100644 domain/library/attribute.cpp delete mode 100644 domain/library/attribute.h delete mode 100644 domain/library/bus.cpp delete mode 100644 domain/library/bus.h delete mode 100644 domain/library/component.cpp delete mode 100644 domain/library/component.h delete mode 100644 domain/library/connection.cpp delete mode 100644 domain/library/connection.h delete mode 100644 domain/library/library.cpp delete mode 100644 domain/library/library.h delete mode 100644 domain/library/pin.cpp delete mode 100644 domain/library/pin.h delete mode 100644 domain/library/popup.cpp delete mode 100644 domain/library/popup.h delete mode 100644 domain/library/rule.cpp delete mode 100644 domain/library/rule.h delete mode 100644 domain/library/value.cpp delete mode 100644 domain/library/value.h delete mode 100644 domain/library/wire.cpp delete mode 100644 domain/library/wire.h diff --git a/SchemeEditor.pro b/SchemeEditor.pro index 6446666..7c03bc8 100644 --- a/SchemeEditor.pro +++ b/SchemeEditor.pro @@ -18,19 +18,6 @@ SOURCES += \ comdel/parser/sourceerror.cpp \ comdel/parser/token.cpp \ comdel/parser/tokenstype.cpp \ - domain/display/display.cpp \ - domain/display/displayitem.cpp \ - domain/library/addressspace.cpp \ - domain/library/attribute.cpp \ - domain/library/bus.cpp \ - domain/library/component.cpp \ - domain/library/connection.cpp \ - domain/library/library.cpp \ - domain/library/pin.cpp \ - domain/library/popup.cpp \ - domain/library/rule.cpp \ - domain/library/value.cpp \ - domain/library/wire.cpp \ domain/schema/connectioninstance.cpp \ domain/schema/instance.cpp \ domain/schema/instanceattribute.cpp \ @@ -52,19 +39,6 @@ HEADERS += \ comdel/parser/sourceerror.h \ comdel/parser/token.h \ comdel/parser/tokenstype.h \ - domain/display/display.h \ - domain/display/displayitem.h \ - domain/library/addressspace.h \ - domain/library/attribute.h \ - domain/library/bus.h \ - domain/library/component.h \ - domain/library/connection.h \ - domain/library/library.h \ - domain/library/pin.h \ - domain/library/popup.h \ - domain/library/rule.h \ - domain/library/value.h \ - domain/library/wire.h \ domain/schema/connectioninstance.h \ domain/schema/instance.h \ domain/schema/instanceattribute.h \ diff --git a/comdel/parser/astnode.h b/comdel/parser/astnode.h index cda1d9c..116363a 100644 --- a/comdel/parser/astnode.h +++ b/comdel/parser/astnode.h @@ -2,6 +2,8 @@ #define ASTNODE_H #include "token.h" +#include +#include /** * AST base class, all AST node classes extand this class. Class contains basic @@ -26,26 +28,24 @@ public: }; -class StringNode: public AstNode { -public: +struct StringNode: public AstNode +{ std::string value; }; - -class IdentifierNode: public AstNode { -public: +struct IdentifierNode: public AstNode +{ std::string value; }; -class NumberNode: public AstNode { -public: +struct NumberNode: public AstNode { long long int value; NumberNode(std::string expression); NumberNode(): value(0) {} }; -class CountNode: public AstNode { -public: +struct CountNode: public AstNode +{ NumberNode first; NumberNode second; @@ -53,4 +53,292 @@ public: CountNode() {} }; + +struct AddressSpace: public AstNode +{ + IdentifierNode name; + NumberNode start; + NumberNode end; +}; + + +class Value: AstNode +{ +public: + enum ValueType { + INT, + STRING, + BOOL, + IDENTIFIER + }; + + +private: + ValueType type; + std::optional intValue; + std::optional stringValue; + std::optional boolValue; + std::optional identifierValue; + +public: + ValueType getType() { + return type; + } + long long asInt() { + if(is(INT)) { + return intValue.value(); + } + throw "cannot convert type to int"; + } + std::string asString() { + if(is(STRING)) { + return stringValue.value(); + } + throw "cannot convert type to string"; + } + std::string asIdentifier() { + if(is(IDENTIFIER)) { + return identifierValue.value(); + } + throw "cannot convert type to identifier"; + } + bool asBool() { + if(is(BOOL)) { + return boolValue.value(); + } + throw "cannot convert type to bool"; + } + + bool is(ValueType type) { + return this->type == type; + } + + static Value ofBool(bool _value) { + Value value; + value.type = BOOL; + value.boolValue = std::optional(_value); + return value; + } + + static Value ofInt(long long _value) { + Value value; + value.type = INT; + value.intValue = std::optional(_value); + return value; + } + + static Value ofString(std::string _value) { + Value value; + value.type = STRING; + value.stringValue = std::optional(_value); + return value; + } + + static Value ofIdentifier(std::string _value) { + Value value; + value.type = IDENTIFIER; + value.identifierValue = std::optional(_value); + return value; + } +}; + +struct Condition +{ + bool negated; + IdentifierNode functionName; + std::vector params; +}; + +class Action: AstNode { +public: + enum ActionType { + ERROR, + WARNING + }; + + ActionType type; + StringNode message; +}; + + +struct IfStmt: AstNode +{ + Condition condition; + Action action; +}; + + +struct Rule: AstNode +{ + std::vector statements; +}; + + +struct EnumerationNode: AstNode +{ + StringNode key; + Value value; +}; + +struct Popup: AstNode +{ + enum PopupType { + AUTOMATIC, + ON_DEMAND + }; + + PopupType type; + StringNode title; + StringNode text; + + bool enumerated; + std::vector enumeration; + + std::vector rules; +}; + +struct PropertyNode: public AstNode +{ + IdentifierNode key; + Value value; +}; + + +struct DisplayItemNode: AstNode +{ + IdentifierNode type; + std::vector values; +}; + + +struct DisplayNode: AstNode +{ + std::vector items; +}; + + +struct PinConnectionNode: AstNode +{ + enum ConnectionType { + CHECK_ONLY, + AUTOMATICALLY + }; + + StringNode message; + ConnectionType type; +}; + + +struct PinNode: AstNode +{ + enum PinType { + IN_OUT, + IN, + OUT + }; + + IdentifierNode name; + PinType type; + StringNode tooltip; + + PinConnectionNode connection; + + DisplayNode display; +}; + + +struct WireNode: public AstNode +{ + enum WireType { + WIRE, + WIRED_AND, + WIRED_OR, + R_WIRE + }; + WireType type; + IdentifierNode name; + NumberNode size; +/* + bool isTerminatedWith; + long terminatedWith; + + bool isIfUntrminated; + long ifUnterminated; +*/ +}; + + +struct AttributeNode: AstNode +{ + Value::ValueType type; + IdentifierNode name; + std::optional defaultValue; + std::optional popup; +}; + +struct ConnectionNode: AstNode +{ + IdentifierNode component; + IdentifierNode pin; + IdentifierNode bus; + std::vector attributes; + std::vector wires; +}; + + +struct ComponentNode: AstNode +{ + enum ComponentType { + OTHER, + PROCESSOR, + MEMORY + }; + + IdentifierNode name; + StringNode tooltip; + StringNode source; + ComponentType type; + std::vector rules; + StringNode instanceName; + CountNode count; + DisplayNode display; + std::vector pin; + std::vector attributes; +}; + + +struct BusNode: AstNode +{ + enum BusType { + AUTOMATIC, + REGULAR + }; + + BusType type; + IdentifierNode name; + StringNode tooltip; + CountNode count; + DisplayNode display; + + std::vector wires; +}; + +struct LibraryNode: AstNode +{ + StringNode name; + StringNode libraryInfo; + StringNode header; + StringNode componentDirectory; + + std::vector addressSpaces; + + std::vector components; + std::vector buses; + std::vector connections; + + std::vector messages; +}; + + + #endif // ASTNODE_H diff --git a/comdel/parser/comdelparser.cpp b/comdel/parser/comdelparser.cpp index 83d84f2..4993aa2 100644 --- a/comdel/parser/comdelparser.cpp +++ b/comdel/parser/comdelparser.cpp @@ -207,11 +207,11 @@ Spanner ComdelParser::getSpanner() * ****************************************************************************/ -std::optional ComdelParser::parse() +std::optional ComdelParser::parse() { auto spanner = getSpanner(); - Library library{}; + LibraryNode library{}; while ( ! check(TokenType::END_OF_FILE) ) { PResult> err; @@ -398,14 +398,14 @@ PResult ComdelParser::parseAddress() /**************************************************************************** * -* Component := "@component" + IDENTIFIER + ("processor" | "memory") { COMPONENT_BLOCK } +* ComponentNode := "@component" + IDENTIFIER + ("processor" | "memory") { COMPONENT_BLOCK } * ****************************************************************************/ -PResult ComdelParser::parseComponent() +PResult ComdelParser::parseComponent() { auto spanner = getSpanner(); - Component component{}; + ComponentNode component{}; RETURN_IF_NOT_TOKEN(TokenType::KW_COMPONENT); @@ -413,12 +413,12 @@ PResult ComdelParser::parseComponent() if(check(TokenType::CT_PROCESSOR)) { bump(); - component.type = Component::PROCESSOR; + component.type = ComponentNode::PROCESSOR; } else if(check(TokenType::CT_MEMORY)) { bump(); - component.type = Component::MEMORY; + component.type = ComponentNode::MEMORY; } else { - component.type = Component::OTHER; + component.type = ComponentNode::OTHER; } RETURN_IF_NOT_TOKEN(TokenType::LBRACE); @@ -457,17 +457,17 @@ PResult ComdelParser::parseComponent() /**************************************************************************** * -* Display := "@display {" + (DISPLAY_ITEM)* + "}" +* DisplayNode := "@display {" + (DISPLAY_ITEM)* + "}" * ****************************************************************************/ -PResult ComdelParser::parseDisplay() { +PResult ComdelParser::parseDisplay() { auto spanner = getSpanner(); RETURN_IF_NOT_TOKEN(TokenType::KW_DISPLAY); - Display display; + DisplayNode display; RETURN_IF_NOT_TOKEN(TokenType::LBRACE); while(!check(TokenType::RBRACE)) { - PResult item; + PResult item; item = parseDisplayItem(); RETURN_IF_ERR(item); display.items.push_back(*item); @@ -478,12 +478,12 @@ PResult ComdelParser::parseDisplay() { /**************************************************************************** * -* DisplayItem := "TYPE {(KEY + ":" + VALUE + ";")*} +* DisplayItemNode := "TYPE {(KEY + ":" + VALUE + ";")*} * ****************************************************************************/ -PResult ComdelParser::parseDisplayItem() { +PResult ComdelParser::parseDisplayItem() { auto spanner = getSpanner(); - DisplayItem displayItem; + DisplayItemNode displayItem; ASSIGN_OR_RETURN_IF_ERR(displayItem.type, parseIdentifier()); RETURN_IF_NOT_TOKEN(TokenType::LBRACE); @@ -500,12 +500,12 @@ PResult ComdelParser::parseDisplayItem() { /**************************************************************************** * -* Bus := "@bus " + NAME + TYPE + "{" + POPUP + "}" +* BusNode := "@bus " + NAME + TYPE + "{" + POPUP + "}" * ****************************************************************************/ -PResult ComdelParser::parseBus() { +PResult ComdelParser::parseBus() { auto spanner = getSpanner(); - Bus bus; + BusNode bus; RETURN_IF_NOT_TOKEN(TokenType::KW_BUS); @@ -514,9 +514,9 @@ PResult ComdelParser::parseBus() { if(check(TokenType::IDENTIFIER)) { auto tokenType = parseIdentifier(); if(tokenType.value().value == "automatic") { - bus.type = Bus::AUTOMATIC; + bus.type = BusNode::AUTOMATIC; } else if(tokenType.value().value == "regular") { - bus.type = Bus::REGULAR; + bus.type = BusNode::REGULAR; } else { return PError(SourceError{current().span, "expected 'automatic' or 'regular'"}); } @@ -558,12 +558,12 @@ PResult ComdelParser::parseBus() { /**************************************************************************** * -* Wire := NAME(){0,1} TYPE)* +* WireNode := NAME(){0,1} TYPE)* * ****************************************************************************/ -PResult ComdelParser::parseWire() { +PResult ComdelParser::parseWire() { auto spanner = getSpanner(); - Wire wire; + WireNode wire; ASSIGN_OR_RETURN_IF_ERR(wire.name, parseIdentifier()); @@ -576,20 +576,20 @@ PResult ComdelParser::parseWire() { } // default - wire.type = Wire::WIRE; + wire.type = WireNode::WIRE; if(check(TokenType::WIRE_DEFAULT)) { bump(); - wire.type = Wire::WIRE; + wire.type = WireNode::WIRE; } else if(check(TokenType::WIRE_AND)) { bump(); - wire.type = Wire::WIRED_AND; + wire.type = WireNode::WIRED_AND; } else if(check(TokenType::WIRE_OR)) { bump(); - wire.type = Wire::WIRED_OR; + wire.type = WireNode::WIRED_OR; } else if(check(TokenType::R_WIRE)) { bump(); - wire.type = Wire::R_WIRE; + wire.type = WireNode::R_WIRE; } return spanner(wire); @@ -598,30 +598,30 @@ PResult ComdelParser::parseWire() { /**************************************************************************** * -* Pin := "@pin" NAME TYPE "{" +* PinNode := "@pin" NAME TYPE "{" "@tooltip" MESSAGE "@connection" TYPE "(" MESSAGE ")" - Display + DisplayNode } * ****************************************************************************/ -PResult ComdelParser::parsePin() { +PResult ComdelParser::parsePin() { auto spanner = getSpanner(); RETURN_IF_NOT_TOKEN(TokenType::KW_PIN); - Pin pin{}; + PinNode pin{}; ASSIGN_OR_RETURN_IF_ERR(pin.name, parseIdentifier()); if(check(TokenType::PIN_IN)) { bump(); - pin.type = Pin::IN; + pin.type = PinNode::IN; } else if(check(TokenType::PIN_OUT)) { bump(); - pin.type = Pin::OUT; + pin.type = PinNode::OUT; } else if(check(TokenType::PIN_IN_OUT)) { bump(); - pin.type = Pin::IN_OUT; + pin.type = PinNode::IN_OUT; } else { return unexpected(); } @@ -649,21 +649,21 @@ PResult ComdelParser::parsePin() { /**************************************************************************** * -* PinConnection := "@connection " + ("check_only" | "automatically") + "(" + MESSAGE + ")" +* PinConnectionNode := "@connection " + ("check_only" | "automatically") + "(" + MESSAGE + ")" * ****************************************************************************/ -PResult ComdelParser::parsePinConnection() { +PResult ComdelParser::parsePinConnection() { auto spanner = getSpanner(); - PinConnection connection{}; + PinConnectionNode connection{}; RETURN_IF_NOT_TOKEN(TokenType::KW_CONNECTION); if(check(TokenType::IDENTIFIER)) { auto type = parseIdentifier(); if(type.value().value == "check_only") { - connection.type = PinConnection::CHECK_ONLY; + connection.type = PinConnectionNode::CHECK_ONLY; } else if(type.value().value == "automatically") { - connection.type = PinConnection::AUTOMATICALLY; + connection.type = PinConnectionNode::AUTOMATICALLY; } else { return PError(SourceError{current().span, "expected identifiers 'check_only' or 'automatically'"}); } @@ -681,12 +681,12 @@ PResult ComdelParser::parsePinConnection() { /**************************************************************************** * -* Attribute := "@attribute " + NAME + TYPE ("default" + VALUE){0,1} ("{" POPUP "}"){0,1} +* AttributeNode := "@attribute " + NAME + TYPE ("default" + VALUE){0,1} ("{" POPUP "}"){0,1} * ****************************************************************************/ -PResult ComdelParser::parseAttribute() { +PResult ComdelParser::parseAttribute() { auto spanner = getSpanner(); - Attribute attribute; + AttributeNode attribute; RETURN_IF_NOT_TOKEN(TokenType::KW_ATTRIBUTE); @@ -839,12 +839,12 @@ PResult ComdelParser::parsePopup() { /**************************************************************************** * -* Connection := "@connection (" + COMPONENT + "." + PIN + "," + BUS) {" + CONNECTION + "}" +* ConnectionNode := "@connection (" + COMPONENT + "." + PIN + "," + BUS) {" + CONNECTION + "}" * ****************************************************************************/ -PResult ComdelParser::parseConnection() { +PResult ComdelParser::parseConnection() { auto spanner = getSpanner(); - Connection connection; + ConnectionNode connection; RETURN_IF_NOT_TOKEN(TokenType::KW_CONNECTION); diff --git a/comdel/parser/comdelparser.h b/comdel/parser/comdelparser.h index 1919bc4..01858a7 100644 --- a/comdel/parser/comdelparser.h +++ b/comdel/parser/comdelparser.h @@ -4,13 +4,12 @@ #include "sourceerror.h" #include "presult.h" #include "token.h" +#include "astnode.h" #include #include #include -#include - /// Records the current span and can later be called on /// an ast node to apply the entire span to that node /// @@ -71,24 +70,24 @@ private: PResult parseProperty(std::optional valueType); PResult parseEnumeration(); - PResult parseComponent(); + PResult parseComponent(); PResult parseAddress(); - PResult parsePin(); - PResult parseDisplay(); - PResult parsePinConnection(); - PResult parseAttribute(); + PResult parsePin(); + PResult parseDisplay(); + PResult parsePinConnection(); + PResult parseAttribute(); PResult parsePopup(); PResult parseRule(); - PResult parseBus(); - PResult parseWire(); - PResult parseConnection(); - PResult parseDisplayItem(); + PResult parseBus(); + PResult parseWire(); + PResult parseConnection(); + PResult parseDisplayItem(); PResult parseIfStatement(); PResult parseValue(); public: ComdelParser(std::vector tokens); - std::optional parse(); + std::optional parse(); const std::vector& getErrors(); }; diff --git a/comdel/parser/parserutil.cpp b/comdel/parser/parserutil.cpp index 02bd608..43b75e6 100644 --- a/comdel/parser/parserutil.cpp +++ b/comdel/parser/parserutil.cpp @@ -6,7 +6,7 @@ #include #include -std::optional loadLibraryFromFile(ParseContext * parseContext, +std::optional loadLibraryFromFile(ParseContext * parseContext, const char* name, std::ostream& stream) { diff --git a/comdel/parser/parserutil.h b/comdel/parser/parserutil.h index 5296ab1..0c3c315 100644 --- a/comdel/parser/parserutil.h +++ b/comdel/parser/parserutil.h @@ -1,11 +1,10 @@ #ifndef PARSERUTIL_H #define PARSERUTIL_H +#include "astnode.h" #include "parsecontext.h" -#include - -std::optional loadLibraryFromFile(ParseContext * parseContext, +std::optional loadLibraryFromFile(ParseContext * parseContext, const char* name, std::ostream& stream); diff --git a/comdel/parser/tokenstype.cpp b/comdel/parser/tokenstype.cpp index 74797a2..08858bd 100644 --- a/comdel/parser/tokenstype.cpp +++ b/comdel/parser/tokenstype.cpp @@ -113,17 +113,17 @@ TokenTables::TokenTables() { add( TokenType::BOOL_TYPE, "bool", TOKENIZABLE), add( TokenType::WIRE_TYPE, "wire", TOKENIZABLE), - // Wire types + // WireNode types add( TokenType::WIRE_DEFAULT, "normal_wire", TOKENIZABLE), add( TokenType::WIRE_AND, "wired_and", TOKENIZABLE), add( TokenType::WIRE_OR, "wired_or", TOKENIZABLE), add( TokenType::R_WIRE, "r_wire", TOKENIZABLE), - // Component types + // ComponentNode types add( TokenType::CT_MEMORY, "memory", TOKENIZABLE), add( TokenType::CT_PROCESSOR, "processor", TOKENIZABLE), - // Pin type + // PinNode type add( TokenType::PIN_IN, "in", TOKENIZABLE), add( TokenType::PIN_OUT, "out", TOKENIZABLE), add( TokenType::PIN_IN_OUT, "inOut", TOKENIZABLE), diff --git a/domain/display/display.cpp b/domain/display/display.cpp deleted file mode 100644 index 733f5c7..0000000 --- a/domain/display/display.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "display.h" - -Display::Display() -{ - -} diff --git a/domain/display/display.h b/domain/display/display.h deleted file mode 100644 index 5b0975d..0000000 --- a/domain/display/display.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef DOMAIN_DISPLAY_DISPLAY_H -#define DOMAIN_DISPLAY_DISPLAY_H - -#include "displayitem.h" - -#include - -#include - -class Display: AstNode -{ -public: - Display(); - - std::vector items; -}; - -#endif // DOMAIN_DISPLAY_DISPLAY_H diff --git a/domain/display/displayitem.cpp b/domain/display/displayitem.cpp deleted file mode 100644 index 8c61448..0000000 --- a/domain/display/displayitem.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "displayitem.h" - -DisplayItem::DisplayItem() -{ - -} diff --git a/domain/display/displayitem.h b/domain/display/displayitem.h deleted file mode 100644 index 700586b..0000000 --- a/domain/display/displayitem.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef DISPLAYITEM_H -#define DISPLAYITEM_H - -#include -#include -#include "../library/value.h" - - -class DisplayItem: AstNode -{ -public: - IdentifierNode type; - std::vector values; - DisplayItem(); -}; - -#endif // DISPLAYITEM_H diff --git a/domain/library/addressspace.cpp b/domain/library/addressspace.cpp deleted file mode 100644 index 0ad67c5..0000000 --- a/domain/library/addressspace.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "addressspace.h" - -AddressSpace::AddressSpace() -{ - -} diff --git a/domain/library/addressspace.h b/domain/library/addressspace.h deleted file mode 100644 index 5d26744..0000000 --- a/domain/library/addressspace.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ADDRESSSPACE_H -#define ADDRESSSPACE_H - -#include - -#include - -class AddressSpace: public AstNode -{ -public: - IdentifierNode name; - NumberNode start; - NumberNode end; - - AddressSpace(); -}; - - -#endif // ADDRESSSPACE_H diff --git a/domain/library/attribute.cpp b/domain/library/attribute.cpp deleted file mode 100644 index bac48d4..0000000 --- a/domain/library/attribute.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "attribute.h" - -Attribute::Attribute() -{ -} diff --git a/domain/library/attribute.h b/domain/library/attribute.h deleted file mode 100644 index 92af635..0000000 --- a/domain/library/attribute.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef DOMAIN_LIBRARY_ATTRIBUTE_H -#define DOMAIN_LIBRARY_ATTRIBUTE_H - -#include "value.h" -#include "popup.h" - -#include - -class Attribute: AstNode -{ -public: - - Value::ValueType type; - IdentifierNode name; - std::optional defaultValue; - std::optional popup; - - Attribute(); -}; - -#endif // DOMAIN_LIBRARY_ATTRIBUTE_H diff --git a/domain/library/bus.cpp b/domain/library/bus.cpp deleted file mode 100644 index 3ab4f29..0000000 --- a/domain/library/bus.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "bus.h" - -Bus::Bus() -{ - -} diff --git a/domain/library/bus.h b/domain/library/bus.h deleted file mode 100644 index 6c3d60b..0000000 --- a/domain/library/bus.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef DOMAIN_LIBRARY_BUS_H -#define DOMAIN_LIBRARY_BUS_H - -#include "wire.h" - -#include -#include - -#include - -#include - - -class Bus: AstNode -{ -public: - enum BusType { - AUTOMATIC, - REGULAR - }; - - BusType type; - IdentifierNode name; - StringNode tooltip; - CountNode count; - Display display; - - std::vector wires; - - Bus(); -}; - -#endif // DOMAIN_LIBRARY_BUS_H diff --git a/domain/library/component.cpp b/domain/library/component.cpp deleted file mode 100644 index f557273..0000000 --- a/domain/library/component.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "component.h" - -Component::Component() -{ - -} diff --git a/domain/library/component.h b/domain/library/component.h deleted file mode 100644 index 66b1bc0..0000000 --- a/domain/library/component.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef COMPONENT_H -#define COMPONENT_H - -#include "rule.h" -#include "pin.h" -#include "attribute.h" - -#include -#include - -#include - - -class Component: AstNode -{ -public: - enum ComponentType { - OTHER, - PROCESSOR, - MEMORY - }; - - IdentifierNode name; - StringNode tooltip; - StringNode source; - ComponentType type; - std::vector rules; - StringNode instanceName; - CountNode count; - Display display; - std::vector pin; - std::vector attributes; - - Component(); -}; - -#endif // COMPONENT_H diff --git a/domain/library/connection.cpp b/domain/library/connection.cpp deleted file mode 100644 index 3cb95e8..0000000 --- a/domain/library/connection.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "connection.h" - -Connection::Connection() -{ - -} diff --git a/domain/library/connection.h b/domain/library/connection.h deleted file mode 100644 index 6924f10..0000000 --- a/domain/library/connection.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef DOMAIN_LIBRARY_CONNECTION_H -#define DOMAIN_LIBRARY_CONNECTION_H - -#include "attribute.h" -#include "bus.h" -#include "component.h" - -#include -#include - -class Connection: AstNode -{ -public: - IdentifierNode component; - IdentifierNode pin; - IdentifierNode bus; - std::vector attributes; - std::vector wires; - - Connection(); -}; - -#endif // DOMAIN_LIBRARY_CONNECTION_H diff --git a/domain/library/library.cpp b/domain/library/library.cpp deleted file mode 100644 index 2af5622..0000000 --- a/domain/library/library.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "library.h" - -Library::Library() -{ - -} diff --git a/domain/library/library.h b/domain/library/library.h deleted file mode 100644 index d74aac0..0000000 --- a/domain/library/library.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef LIBRARY_H -#define LIBRARY_H - -#include "addressspace.h" -#include "bus.h" -#include "component.h" -#include "connection.h" - -#include -#include -#include - -class Library: AstNode -{ -public: - StringNode name; - StringNode libraryInfo; - StringNode header; - StringNode componentDirectory; - - std::vector addressSpaces; - - std::vector components; - std::vector buses; - std::vector connections; - - std::vector messages; - - Library(); -}; - - - -#endif // LIBRARY_H diff --git a/domain/library/pin.cpp b/domain/library/pin.cpp deleted file mode 100644 index d9b7308..0000000 --- a/domain/library/pin.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "pin.h" - -Pin::Pin() -{ - -} diff --git a/domain/library/pin.h b/domain/library/pin.h deleted file mode 100644 index c2cf8e1..0000000 --- a/domain/library/pin.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef DOMAIN_LIBRARY_PIN_H -#define DOMAIN_LIBRARY_PIN_H - -#include - -#include - -#include - - -class PinConnection: AstNode { -public: - enum ConnectionType { - CHECK_ONLY, - AUTOMATICALLY - }; - - StringNode message; - ConnectionType type; -}; - - -class Pin: AstNode -{ -public: - enum PinType { - IN_OUT, - IN, - OUT - }; - - IdentifierNode name; - PinType type; - StringNode tooltip; - - PinConnection connection; - - Display display; - - Pin(); -}; - -#endif // DOMAIN_LIBRARY_PIN_H diff --git a/domain/library/popup.cpp b/domain/library/popup.cpp deleted file mode 100644 index 86a4f8b..0000000 --- a/domain/library/popup.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "popup.h" - -Popup::Popup() -{ - -} diff --git a/domain/library/popup.h b/domain/library/popup.h deleted file mode 100644 index 20c52a0..0000000 --- a/domain/library/popup.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef DOMAIN_LIBRARY_POPUP_H -#define DOMAIN_LIBRARY_POPUP_H - -#include "rule.h" - -#include -#include -#include - - -class EnumerationNode: AstNode { -public: - StringNode key; - Value value; -}; - -class Popup: AstNode -{ -public: - enum PopupType { - AUTOMATIC, - ON_DEMAND - }; - - PopupType type; - StringNode title; - StringNode text; - - bool enumerated; - std::vector enumeration; - - std::vector rules; - - Popup(); -}; - -#endif // DOMAIN_LIBRARY_POPUP_H diff --git a/domain/library/rule.cpp b/domain/library/rule.cpp deleted file mode 100644 index 0e6fb41..0000000 --- a/domain/library/rule.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "rule.h" - -Rule::Rule() -{ - -} diff --git a/domain/library/rule.h b/domain/library/rule.h deleted file mode 100644 index 551d243..0000000 --- a/domain/library/rule.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef DOMAIN_LIBRARY_RULE_H -#define DOMAIN_LIBRARY_RULE_H - -#include "value.h" - -#include -#include - -class Action; -class Condition; -class IfStmt; - -class Rule: AstNode -{ -public: - std::vector statements; - Rule(); -}; - -class Action: AstNode { -public: - enum ActionType { - ERROR, - WARNING - }; - - ActionType type; - StringNode message; -}; - -class Condition { -public: - bool negated; - IdentifierNode functionName; - std::vector params; -}; - -class IfStmt: AstNode { -public: - Condition condition; - Action action; -}; - -#endif // DOMAIN_LIBRARY_RULE_H diff --git a/domain/library/value.cpp b/domain/library/value.cpp deleted file mode 100644 index 456bbc0..0000000 --- a/domain/library/value.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "value.h" - -Value::Value() -{ -} diff --git a/domain/library/value.h b/domain/library/value.h deleted file mode 100644 index 06b831d..0000000 --- a/domain/library/value.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef DOMAIN_LIBRARY_VALUE_H -#define DOMAIN_LIBRARY_VALUE_H - -#include -#include -#include - -class Value: AstNode -{ -public: - enum ValueType { - INT, - STRING, - BOOL, - IDENTIFIER - }; - - -private: - ValueType type; - std::optional intValue; - std::optional stringValue; - std::optional boolValue; - std::optional identifierValue; - -public: - Value(); - - ValueType getType() { - return type; - } - long long asInt() { - if(is(INT)) { - return intValue.value(); - } - throw "cannot convert type to int"; - } - std::string asString() { - if(is(STRING)) { - return stringValue.value(); - } - throw "cannot convert type to string"; - } - std::string asIdentifier() { - if(is(IDENTIFIER)) { - return identifierValue.value(); - } - throw "cannot convert type to identifier"; - } - bool asBool() { - if(is(BOOL)) { - return boolValue.value(); - } - throw "cannot convert type to bool"; - } - - bool is(ValueType type) { - return this->type == type; - } - - static Value ofBool(bool _value) { - Value value; - value.type = BOOL; - value.boolValue = std::optional(_value); - return value; - } - - static Value ofInt(long long _value) { - Value value; - value.type = INT; - value.intValue = std::optional(_value); - return value; - } - - static Value ofString(std::string _value) { - Value value; - value.type = STRING; - value.stringValue = std::optional(_value); - return value; - } - - static Value ofIdentifier(std::string _value) { - Value value; - value.type = IDENTIFIER; - value.identifierValue = std::optional(_value); - return value; - } - -}; - -class PropertyNode: public AstNode { -public: - IdentifierNode key; - Value value; - - PropertyNode() {} -}; - - -#endif // DOMAIN_LIBRARY_VALUE_H diff --git a/domain/library/wire.cpp b/domain/library/wire.cpp deleted file mode 100644 index db47a4c..0000000 --- a/domain/library/wire.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "wire.h" - -Wire::Wire() -{ - -} diff --git a/domain/library/wire.h b/domain/library/wire.h deleted file mode 100644 index 98dec7d..0000000 --- a/domain/library/wire.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef DOMAIN_LIBRARY_WIRE_H -#define DOMAIN_LIBRARY_WIRE_H - -#include - -#include - - -class Wire: public AstNode -{ -public: - enum WireType { - WIRE, - WIRED_AND, - WIRED_OR, - R_WIRE - }; - WireType type; - IdentifierNode name; - NumberNode size; -/* - bool isTerminatedWith; - long terminatedWith; - - bool isIfUntrminated; - long ifUnterminated; -*/ - Wire(); -}; - -#endif // DOMAIN_LIBRARY_WIRE_H diff --git a/domain/schema/instanceattribute.h b/domain/schema/instanceattribute.h index ebece91..267c956 100644 --- a/domain/schema/instanceattribute.h +++ b/domain/schema/instanceattribute.h @@ -1,7 +1,7 @@ #ifndef DOMAIN_SCHEMA_ATTRIBUTE_H #define DOMAIN_SCHEMA_ATTRIBUTE_H -#include +#include class InstanceAttribute: AstNode { diff --git a/domain/schema/wireinstance.h b/domain/schema/wireinstance.h index ca22659..413e090 100644 --- a/domain/schema/wireinstance.h +++ b/domain/schema/wireinstance.h @@ -2,14 +2,13 @@ #define DOMAIN_SCHEMA_WIREINSTANCE_H #include -#include #include class WireInstance: AstNode { std::string name; std::pair position; - Display display; + DisplayNode display; public: WireInstance();