2022-04-08 18:17:58 +00:00
|
|
|
#ifndef AST_NODE_H
|
|
|
|
#define AST_NODE_H
|
2022-03-29 19:31:45 +00:00
|
|
|
|
|
|
|
#include "token.h"
|
2022-06-12 14:02:24 +00:00
|
|
|
#include "color.h"
|
2022-05-27 06:18:17 +00:00
|
|
|
#include "source_error.h"
|
2022-03-29 21:49:32 +00:00
|
|
|
#include <optional>
|
2022-05-27 06:18:17 +00:00
|
|
|
#include <utility>
|
2022-03-29 21:49:32 +00:00
|
|
|
#include <vector>
|
2022-03-29 19:31:45 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* BASE TYPES *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2022-03-29 19:31:45 +00:00
|
|
|
/**
|
2022-04-08 18:17:58 +00:00
|
|
|
* AST base class, all AST node classes extend this class. Class contains basic
|
|
|
|
* information about nodes location in file.
|
2022-03-29 19:31:45 +00:00
|
|
|
*/
|
|
|
|
class AstNode {
|
|
|
|
public:
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains information about where in source file given node is located */
|
2022-03-29 19:31:45 +00:00
|
|
|
Span span;
|
|
|
|
|
|
|
|
AstNode() = default;
|
2022-05-27 06:18:17 +00:00
|
|
|
AstNode(AstNode &&) = default;
|
|
|
|
AstNode &operator=(AstNode &&) = default;
|
|
|
|
AstNode(const AstNode &) = default;
|
|
|
|
AstNode &operator=(const AstNode &) = default;
|
2022-04-24 20:21:45 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/**
|
|
|
|
* AST base enum class,
|
|
|
|
* Used to represent AST enums
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
template<typename T>
|
|
|
|
struct EnumNode : public AstNode {
|
2022-04-24 20:21:45 +00:00
|
|
|
EnumNode() = default;
|
2022-05-27 06:18:17 +00:00
|
|
|
|
|
|
|
explicit EnumNode(T value) : value(value) {}
|
2022-03-29 19:31:45 +00:00
|
|
|
|
2022-04-24 20:21:45 +00:00
|
|
|
T value;
|
2022-03-29 19:31:45 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents string
|
|
|
|
* value contains quote-marks ("" or '' depending on string type)
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct StringNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** String including quote-marks*/
|
2022-03-29 19:31:45 +00:00
|
|
|
std::string value;
|
2022-05-27 06:18:17 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Returns string without quote-marks */
|
2022-04-24 20:21:45 +00:00
|
|
|
std::string asString();
|
2022-03-29 19:31:45 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents identifiers */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct IdentifierNode : public AstNode {
|
2022-03-29 19:31:45 +00:00
|
|
|
std::string value;
|
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents all numbers used
|
|
|
|
* All numbers must fit into long long int
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct NumberNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
long long int value = 0;
|
2022-05-27 06:18:17 +00:00
|
|
|
|
|
|
|
explicit NumberNode(const std::string &expression);
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
NumberNode() = default;
|
2022-03-29 19:31:45 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents color
|
|
|
|
* color comes in two formats #RRGGBB or #RRGGBBAA (AA representing opacity)
|
|
|
|
* */
|
2022-06-12 14:02:24 +00:00
|
|
|
struct ColorNode : public AstNode {
|
|
|
|
Color color;
|
|
|
|
|
|
|
|
explicit ColorNode(const std::string &expression);
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
ColorNode() = default;
|
2022-06-12 14:02:24 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents ordered number pair */
|
|
|
|
struct NumberPairNode : public AstNode {
|
2022-03-29 19:31:45 +00:00
|
|
|
NumberNode first;
|
|
|
|
NumberNode second;
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
NumberPairNode(NumberNode first, NumberNode second) : first(first), second(second) {}
|
2022-05-27 06:18:17 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
NumberPairNode() = default;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents generic value
|
|
|
|
* Because attributes can contain different value types,
|
|
|
|
* this allows us to use one generic type for all attributes
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
class ValueNode : public AstNode {
|
2022-03-29 21:49:32 +00:00
|
|
|
public:
|
|
|
|
enum ValueType {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Stores same content as NumberNode */
|
2022-03-29 21:49:32 +00:00
|
|
|
INT,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Stores same content as StringNode */
|
2022-03-29 21:49:32 +00:00
|
|
|
STRING,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Stores true or false */
|
2022-03-29 21:49:32 +00:00
|
|
|
BOOL,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Stores wire nam or null */
|
2022-03-31 21:20:41 +00:00
|
|
|
WIRE,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Default type assigned when node value is of type IdentifierNode and more correct type is assigned later */
|
2022-04-08 20:46:47 +00:00
|
|
|
IDENTIFIER,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Stores memory name or null */
|
2022-05-15 21:55:03 +00:00
|
|
|
MEMORY,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Stores null */
|
2022-04-08 20:46:47 +00:00
|
|
|
NIL,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Store same content as ColorNode */
|
2022-06-12 14:02:24 +00:00
|
|
|
COLOR,
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Type determines what is stored inside ValueNode */
|
|
|
|
EnumNode<ValueType> type = EnumNode(NIL);
|
|
|
|
/** All possible values for ValueNode are stored inside optionals */
|
|
|
|
std::optional<long long> intValue = std::nullopt;
|
|
|
|
std::optional<std::string> stringValue = std::nullopt;
|
|
|
|
std::optional<bool> boolValue = std::nullopt;
|
|
|
|
std::optional<std::string> identifierValue = std::nullopt;
|
|
|
|
std::optional<Color> colorValue = std::nullopt;
|
2022-03-29 21:49:32 +00:00
|
|
|
|
|
|
|
public:
|
2022-05-15 21:55:03 +00:00
|
|
|
ValueNode() = default;
|
2022-03-31 21:20:41 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
ValueType getType() const;
|
2022-05-27 06:18:17 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Checks ValueNode is of requested type and returns it or returns default value for given type*/
|
|
|
|
long long int asInt();
|
2022-04-24 20:21:45 +00:00
|
|
|
std::string asString();
|
|
|
|
std::string asIdentifier();
|
2022-06-12 14:02:24 +00:00
|
|
|
Color asColor();
|
2022-04-24 20:21:45 +00:00
|
|
|
bool asBool();
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Returns true if ValueNode is of given valueType */
|
2022-04-24 20:21:45 +00:00
|
|
|
bool is(ValueType valueType);
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Static methods used to generate ValueNodes of requested type */
|
2022-04-24 20:21:45 +00:00
|
|
|
static ValueNode ofBool(bool _value);
|
|
|
|
static ValueNode ofInt(long long _value);
|
|
|
|
static ValueNode ofString(std::string _value);
|
|
|
|
static ValueNode ofIdentifier(std::string _value);
|
2022-05-15 21:55:03 +00:00
|
|
|
static ValueNode ofMemory(std::optional<std::string> _value);
|
2022-04-24 20:21:45 +00:00
|
|
|
static ValueNode ofNull();
|
2022-06-12 14:02:24 +00:00
|
|
|
static ValueNode ofColor(Color color);
|
2022-05-15 21:55:03 +00:00
|
|
|
static ValueNode ofWire(std::optional<std::string> _value);
|
2022-06-12 22:48:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Represents an identifier-value pair*/
|
|
|
|
struct PropertyNode : public AstNode {
|
|
|
|
IdentifierNode key;
|
|
|
|
ValueNode value;
|
|
|
|
|
|
|
|
PropertyNode() = default;
|
|
|
|
PropertyNode(IdentifierNode key, ValueNode value): key(key), value(value) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Represents a string-value pair */
|
|
|
|
struct StringPropertyNode : public AstNode {
|
|
|
|
StringNode key;
|
|
|
|
ValueNode value;
|
|
|
|
|
|
|
|
StringPropertyNode() = default;
|
|
|
|
StringPropertyNode(StringNode key, ValueNode value): key(key), value(value) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* RULE TYPES *
|
|
|
|
*****************************************************************************/
|
2022-06-12 14:02:24 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
struct IfStatementNode;
|
|
|
|
|
|
|
|
/** Represents validation rule
|
|
|
|
* Rules are made from a list of
|
|
|
|
* if - else if statements
|
|
|
|
* */
|
|
|
|
struct RuleNode : public AstNode {
|
|
|
|
std::vector<IfStatementNode> statements;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents condition inside if statement
|
|
|
|
* Every condition is made from optional negation operator !
|
|
|
|
* Function called and list of function parameters
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct ConditionNode {
|
2022-03-29 21:49:32 +00:00
|
|
|
bool negated;
|
|
|
|
IdentifierNode functionName;
|
2022-03-31 21:20:41 +00:00
|
|
|
std::vector<ValueNode> params;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents action executed inside if statement
|
|
|
|
* */
|
|
|
|
struct ActionNode : public AstNode {
|
|
|
|
/** There are two types of action determined by action type */
|
2022-03-29 21:49:32 +00:00
|
|
|
enum ActionType {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Error actions represent invalid state and cause validation to fail */
|
2022-03-29 21:49:32 +00:00
|
|
|
ERROR,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Warning actions represent states that can cause issue when simulating
|
|
|
|
* model but models created with it are still valid
|
|
|
|
* */
|
2022-03-29 21:49:32 +00:00
|
|
|
WARNING
|
|
|
|
};
|
|
|
|
|
2022-04-24 20:21:45 +00:00
|
|
|
EnumNode<ActionType> type;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Message used if condition is fulfilled */
|
2022-03-29 21:49:32 +00:00
|
|
|
StringNode message;
|
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** If statements represents one validation check inside rule */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct IfStatementNode : public AstNode {
|
2022-03-31 21:20:41 +00:00
|
|
|
ConditionNode condition;
|
|
|
|
ActionNode action;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* ATTRIBUTE TYPES *
|
|
|
|
*****************************************************************************/
|
2022-03-29 21:49:32 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents popup dialog used to modified attribute inside which it is defined
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct PopupNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Determines type of popup*/
|
2022-03-29 21:49:32 +00:00
|
|
|
enum PopupType {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Automatic popup is opened when component or connection containing it is defined */
|
2022-03-29 21:49:32 +00:00
|
|
|
AUTOMATIC,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** On demand popups are opened on user request usually from context menus*/
|
2022-03-29 21:49:32 +00:00
|
|
|
ON_DEMAND
|
|
|
|
};
|
|
|
|
|
2022-04-24 20:21:45 +00:00
|
|
|
std::optional<EnumNode<PopupType>> type;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Title of popup */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<StringNode> title;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Text of popup */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<StringNode> text;
|
2022-03-29 21:49:32 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** If popup contains an enumeration*/
|
2022-03-29 21:49:32 +00:00
|
|
|
bool enumerated;
|
2022-06-12 22:48:12 +00:00
|
|
|
std::vector<StringPropertyNode> enumeration;
|
2022-03-29 21:49:32 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Validation rules for given popup */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::vector<RuleNode> rules;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents component or connection attribute
|
|
|
|
* Attributes are values that can programmatically be changed
|
|
|
|
* if popup is defined
|
|
|
|
* */
|
|
|
|
struct AttributeNode : public AstNode {
|
|
|
|
/** Type of attribute */
|
|
|
|
ValueNode::ValueType type;
|
|
|
|
/** Name of attribute */
|
|
|
|
IdentifierNode name;
|
|
|
|
/** Default type of attribute */
|
|
|
|
std::optional<ValueNode> defaultValue;
|
|
|
|
/** Popup used to change attribute value */
|
|
|
|
std::optional<PopupNode> popup;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* DISPLAY TYPES *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
struct DisplayItemNode;
|
|
|
|
|
|
|
|
/** Represents how a component or bus is rendered
|
|
|
|
* Display is made from an list of display items
|
|
|
|
* */
|
|
|
|
struct DisplayNode : public AstNode {
|
|
|
|
std::vector<DisplayItemNode> items;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** DisplayItem represents one rendered item
|
|
|
|
* in source code items are defined similar to json objects
|
|
|
|
* eg.
|
|
|
|
* @code rect {
|
|
|
|
* x: 100;
|
|
|
|
* y: 100;
|
|
|
|
* w: 100;
|
|
|
|
* h: 100;
|
|
|
|
* fillColor: #123456
|
|
|
|
* }
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct DisplayItemNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains type of display item */
|
2022-03-29 21:49:32 +00:00
|
|
|
IdentifierNode type;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains all property nodes */
|
2022-03-29 21:49:32 +00:00
|
|
|
std::vector<PropertyNode> values;
|
2022-05-17 22:14:33 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Returns value of requested property
|
|
|
|
* If requested property doesn't exists default value is returned (eg. asInt is called but PropertyNode contains string)
|
|
|
|
* If value of requested property is different than expected nullopt is retured
|
|
|
|
* */
|
|
|
|
std::optional<long long int> asInt(const std::string &property, long long int _default = 0);
|
|
|
|
std::optional<Color> asColor(const std::string &property, Color _default = Color(0, 0, 0));
|
|
|
|
std::optional<std::string> asString(const std::string &property, std::string _default = "");
|
2022-03-29 21:49:32 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
private:
|
|
|
|
std::optional<PropertyNode> getProperty(const std::string &property);
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* LIBRARY TYPES *
|
|
|
|
*****************************************************************************/
|
2022-03-29 21:49:32 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents AddressSpaces
|
|
|
|
* Address spaces are defined with their name and address range
|
|
|
|
* */
|
|
|
|
struct AddressSpaceNode : public AstNode {
|
|
|
|
IdentifierNode name;
|
|
|
|
/** Range represent which addresses are available for components that use memory space [first, second> */
|
|
|
|
NumberPairNode range;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Pins are used to create component-component or component-bus connections */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct PinNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Determines pin type, pin types currently only affect how pins are rendered */
|
2022-03-29 21:49:32 +00:00
|
|
|
enum PinType {
|
|
|
|
IN_OUT,
|
|
|
|
IN,
|
|
|
|
OUT
|
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Name of pin */
|
2022-03-29 21:49:32 +00:00
|
|
|
IdentifierNode name;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Type of pin */
|
2022-04-24 20:21:45 +00:00
|
|
|
EnumNode<PinType> type;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Tooltip content displayed on hover over pin */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<StringNode> tooltip;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** If present this means pin must be connected to another component or bus to create connection
|
|
|
|
* Connection contains error message shown
|
|
|
|
* */
|
|
|
|
std::optional<StringNode> connection;
|
|
|
|
/** Determines how the pin is displayed */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<DisplayNode> display;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** If pin connection is optional it requires list of wires used to populate comdel model */
|
2022-04-09 12:10:40 +00:00
|
|
|
std::optional<std::vector<ValueNode>> wires;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/**
|
|
|
|
* Represents COMDEL component
|
|
|
|
* */
|
|
|
|
struct ComponentNode : public AstNode {
|
|
|
|
/** Determines type of component */
|
|
|
|
enum ComponentType {
|
|
|
|
/** Generic component */
|
|
|
|
OTHER,
|
|
|
|
/** Represents processor, all processors have implicit attribute _memory if type memory
|
|
|
|
* used when generating COMDEL model to connect memories and processors
|
|
|
|
*/
|
|
|
|
PROCESSOR,
|
|
|
|
/** Represents memory, all components of type memory can be selected in _memory attribute of processor */
|
|
|
|
MEMORY
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Component name */
|
|
|
|
IdentifierNode name;
|
|
|
|
/** Tooltip displayed on hover */
|
|
|
|
std::optional<StringNode> tooltip;
|
|
|
|
/** Contains path to COMDEL source containing current component */
|
|
|
|
std::optional<StringNode> source;
|
|
|
|
/** Type of component */
|
|
|
|
EnumNode<ComponentType> type;
|
|
|
|
/** List of component level rules */
|
|
|
|
std::vector<RuleNode> rules;
|
|
|
|
/** Default used to name instances */
|
|
|
|
std::optional<IdentifierNode> instanceName;
|
|
|
|
/** Count determines number of instances allowed in a schema */
|
|
|
|
std::optional<NumberPairNode> count;
|
|
|
|
/** Display determines how component is rendered */
|
|
|
|
std::optional<DisplayNode> display;
|
|
|
|
/** List of all pins */
|
|
|
|
std::vector<PinNode> pins;
|
|
|
|
/** List of all attributes */
|
|
|
|
std::vector<AttributeNode> attributes;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** WireNode represents COMDEL wire
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct WireNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Determines type of wires */
|
2022-03-29 21:49:32 +00:00
|
|
|
enum WireType {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Generic wire */
|
2022-03-29 21:49:32 +00:00
|
|
|
WIRE,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** wired_and can have multiple sources, that are ANDed together */
|
2022-03-29 21:49:32 +00:00
|
|
|
WIRED_AND,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** wired_and can have multiple sources, that are ORed together */
|
2022-03-29 21:49:32 +00:00
|
|
|
WIRED_OR,
|
2022-06-12 22:48:12 +00:00
|
|
|
/** r_wire can remain unconnected */
|
2022-03-29 21:49:32 +00:00
|
|
|
R_WIRE
|
|
|
|
};
|
2022-04-24 20:21:45 +00:00
|
|
|
EnumNode<WireType> type;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Name of wire */
|
2022-03-29 21:49:32 +00:00
|
|
|
IdentifierNode name;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Number of bits inside of a wire */
|
2022-03-29 21:49:32 +00:00
|
|
|
NumberNode size;
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** If wire is visible or hidden, this determines how wires are generated in COMDEL */
|
2022-05-08 22:51:47 +00:00
|
|
|
bool hidden = false;
|
2022-04-05 21:48:07 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** If wire isn't connected to anything it is replaced with terminate with terminateWith value */
|
2022-04-24 20:21:45 +00:00
|
|
|
bool hasTerminateWith;
|
|
|
|
ValueNode terminateWith;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Buses dont exist in COMDEL but they are useful
|
|
|
|
* as they allow us to connect multiple COMDEL wires together
|
|
|
|
* */
|
|
|
|
struct BusNode : public AstNode {
|
|
|
|
enum BusType {
|
|
|
|
/** This busses connect two components */
|
|
|
|
AUTOMATIC,
|
|
|
|
/**
|
|
|
|
* This busses allow us to connect multiple component together using one bus
|
|
|
|
* */
|
|
|
|
REGULAR,
|
|
|
|
/** This busses connect two components,
|
|
|
|
* they differ from automatic as they allow us to connect same pins multiple times */
|
|
|
|
SINGLE_AUTOMATIC
|
|
|
|
};
|
|
|
|
|
|
|
|
EnumNode<BusType> type;
|
2022-03-29 21:49:32 +00:00
|
|
|
IdentifierNode name;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Default used to name instances */
|
|
|
|
std::optional<IdentifierNode> instanceName;
|
|
|
|
/** Tooltip displayed on hover */
|
|
|
|
std::optional<StringNode> tooltip;
|
|
|
|
/** Count determines number of instances allowed in a schema */
|
|
|
|
std::optional<NumberPairNode> count;
|
|
|
|
/** Display determines how component is rendered */
|
|
|
|
std::optional<DisplayNode> display;
|
|
|
|
|
|
|
|
/** List of all COMDEL wires contained in bus */
|
|
|
|
std::vector<WireNode> wires;
|
2022-03-29 21:49:32 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents ComponentConnection key in Connection node
|
|
|
|
* (eg. componentName.pinName)
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct ConnectionComponentNode : public AstNode {
|
2022-03-29 21:49:32 +00:00
|
|
|
IdentifierNode component;
|
|
|
|
IdentifierNode pin;
|
2022-04-09 17:44:02 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents Connection node
|
|
|
|
* Connection can be between component and bus in which second is null,
|
|
|
|
* or between two components
|
|
|
|
* */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct ConnectionNode : public AstNode {
|
2022-04-09 17:44:02 +00:00
|
|
|
ConnectionComponentNode first;
|
|
|
|
std::optional<ConnectionComponentNode> second;
|
|
|
|
|
2022-03-29 21:49:32 +00:00
|
|
|
IdentifierNode bus;
|
|
|
|
std::vector<AttributeNode> attributes;
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** If connection is of type component-component it contains two pairs of wires */
|
2022-04-09 17:44:02 +00:00
|
|
|
std::vector<ValueNode> firstWires;
|
|
|
|
std::optional<std::vector<ValueNode>> secondWires;
|
|
|
|
};
|
2022-03-29 21:49:32 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** LibraryNode represent library instance */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct LibraryNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Name of library */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<StringNode> name;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Library info contains generic information about library */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<StringNode> libraryInfo;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains text that is added to top of COMDEL file */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<StringNode> header;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains path to component directory */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<StringNode> componentDirectory;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains text that is added to top of System component in COMDEL file */
|
2022-05-15 23:02:34 +00:00
|
|
|
std::optional<StringNode> componentHeader;
|
2022-03-29 21:49:32 +00:00
|
|
|
|
2022-03-31 21:20:41 +00:00
|
|
|
std::vector<AddressSpaceNode> addressSpaces;
|
2022-03-29 21:49:32 +00:00
|
|
|
|
|
|
|
std::vector<ComponentNode> components;
|
|
|
|
std::vector<BusNode> buses;
|
|
|
|
std::vector<ConnectionNode> connections;
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains properties used to translate dialog and error messages */
|
2022-03-29 21:49:32 +00:00
|
|
|
std::vector<PropertyNode> messages;
|
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* LIBRARY TYPES *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/** Represents instance of attribute in component or connection instance */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct InstanceAttributeNode : public AstNode {
|
2022-03-31 21:20:41 +00:00
|
|
|
IdentifierNode name;
|
|
|
|
ValueNode value;
|
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents instance of a component or a bus */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct InstanceNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains instance name */
|
2022-03-31 21:20:41 +00:00
|
|
|
IdentifierNode name;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains component name */
|
2022-03-31 21:20:41 +00:00
|
|
|
IdentifierNode component;
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains position of component instance */
|
|
|
|
std::optional<NumberPairNode> position;
|
2022-03-31 21:20:41 +00:00
|
|
|
std::vector<InstanceAttributeNode> attributes;
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains size of bus instances */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<NumberNode> size;
|
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents ComponentConnection of a selected instance */
|
|
|
|
struct ConnectionComponentInstanceNode : public AstNode {
|
|
|
|
/** Name of component instance */
|
2022-03-31 21:20:41 +00:00
|
|
|
IdentifierNode instance;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Name of pin */
|
2022-03-31 21:20:41 +00:00
|
|
|
IdentifierNode pin;
|
2022-04-09 17:44:02 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represents Connection instance */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct ConnectionInstanceNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
ConnectionComponentInstanceNode first;
|
|
|
|
std::optional<ConnectionComponentInstanceNode> second;
|
2022-04-09 17:44:02 +00:00
|
|
|
|
2022-03-31 21:20:41 +00:00
|
|
|
IdentifierNode bus;
|
|
|
|
|
|
|
|
std::vector<InstanceAttributeNode> attributes;
|
|
|
|
};
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Represent schema instance */
|
2022-05-27 06:18:17 +00:00
|
|
|
struct SchemaNode : public AstNode {
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains path to library source */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<StringNode> source;
|
2022-03-29 21:49:32 +00:00
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains list of instances */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::vector<InstanceNode> instances;
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains list of connection */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::vector<ConnectionInstanceNode> connections;
|
|
|
|
|
2022-06-12 22:48:12 +00:00
|
|
|
/** Contains library */
|
2022-03-31 21:20:41 +00:00
|
|
|
std::optional<LibraryNode> library;
|
|
|
|
};
|
2022-03-29 21:49:32 +00:00
|
|
|
|
2022-04-08 18:17:58 +00:00
|
|
|
#endif // AST_NODE_H
|