Added display name
This commit is contained in:
parent
7be3a1b5bc
commit
eaa115d115
|
@ -19,7 +19,7 @@ namespace display {
|
||||||
|
|
||||||
Component::Component(const std::shared_ptr<domain::ComponentInstance> &instance): instance(instance) {
|
Component::Component(const std::shared_ptr<domain::ComponentInstance> &instance): instance(instance) {
|
||||||
setFlag(ItemSendsGeometryChanges, true);
|
setFlag(ItemSendsGeometryChanges, true);
|
||||||
setToolTip(QString::fromStdString(instance->name + "::" + instance->component.getName()));
|
setToolTip(QString::fromStdString(instance->name + "::" + instance->component.getDisplayName()));
|
||||||
instance->component.getDisplay().render(this, domain::ui::DisplayContext(instance.get()));
|
instance->component.getDisplay().render(this, domain::ui::DisplayContext(instance.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace display {
|
||||||
auto newName = dialog->getName();
|
auto newName = dialog->getName();
|
||||||
|
|
||||||
Application::instance()->renameComponent(currentName, newName);
|
Application::instance()->renameComponent(currentName, newName);
|
||||||
setToolTip(QString::fromStdString(instance->name + "::" + instance->component.getName()));
|
setToolTip(QString::fromStdString(instance->name + "::" + instance->component.getDisplayName()));
|
||||||
});
|
});
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
for (int i = 0; i < this->instance->attributes.size(); i++) {
|
for (int i = 0; i < this->instance->attributes.size(); i++) {
|
||||||
|
@ -51,9 +51,9 @@ namespace display {
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
auto action = menu.addAction(QString::fromStdString("Izmjeni '" + attr->name + "'"),
|
auto action = menu.addAction(QString::fromStdString("Izmjeni '" + attr->attribute.getDisplayName() + "'"),
|
||||||
[attr]() {
|
[attr]() {
|
||||||
auto dialog = new AttributeDialog("Izmjeni " + attr->name, "Izmjeni", attr);
|
auto dialog = new AttributeDialog("Izmjeni " + attr->attribute.getDisplayName(), "Izmjeni", attr);
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
});
|
});
|
||||||
action->setEnabled(enabled);
|
action->setEnabled(enabled);
|
||||||
|
@ -109,8 +109,8 @@ namespace display {
|
||||||
}
|
}
|
||||||
for (int i = 0; i < pinConnection->attributes.size(); i++) {
|
for (int i = 0; i < pinConnection->attributes.size(); i++) {
|
||||||
auto *attr = &pinConnection->attributes[i];
|
auto *attr = &pinConnection->attributes[i];
|
||||||
menu.addAction(QString::fromStdString("Izmjeni '" + attr->name + "'"),[attr]() {
|
menu.addAction(QString::fromStdString("Izmjeni '" + attr->attribute.getDisplayName() + "'"),[attr]() {
|
||||||
auto dialog = new AttributeDialog("Izmjeni '" + attr->name + "'", "Izmjeni", attr);
|
auto dialog = new AttributeDialog("Izmjeni '" + attr->attribute.getDisplayName() + "'", "Izmjeni", attr);
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ namespace display {
|
||||||
auto newName = dialog->getName();
|
auto newName = dialog->getName();
|
||||||
|
|
||||||
Application::instance()->renameBus(currentName, newName);
|
Application::instance()->renameBus(currentName, newName);
|
||||||
setToolTip(QString::fromStdString(busInstance->name + "::" + busInstance->bus.getName()));
|
setToolTip(QString::fromStdString(busInstance->name + "::" + busInstance->bus.getDisplayName()));
|
||||||
});
|
});
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(QString::fromStdString("Ukloni " + this->busInstance->name), [this]() {
|
menu.addAction(QString::fromStdString("Ukloni " + this->busInstance->name), [this]() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace display {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &component: library->getComponents()) {
|
for (auto &component: library->getComponents()) {
|
||||||
auto item = new LibraryListItem{component.getName(), "comdel/component", component.getName(),
|
auto item = new LibraryListItem{component.getDisplayName(), "comdel/component", component.getName(),
|
||||||
componentList};
|
componentList};
|
||||||
item->setToolTip(QString::fromStdString(component.getTooltip()));
|
item->setToolTip(QString::fromStdString(component.getTooltip()));
|
||||||
componentList->addItem(item);
|
componentList->addItem(item);
|
||||||
|
@ -41,7 +41,7 @@ namespace display {
|
||||||
|
|
||||||
for (auto &bus: library->getBuses()) {
|
for (auto &bus: library->getBuses()) {
|
||||||
if (bus.getType() == domain::Bus::REGULAR) {
|
if (bus.getType() == domain::Bus::REGULAR) {
|
||||||
auto item = new LibraryListItem{bus.getName(), "comdel/bus", bus.getName(), busList};
|
auto item = new LibraryListItem{bus.getDisplayName(), "comdel/bus", bus.getName(), busList};
|
||||||
item->setToolTip(QString::fromStdString(bus.getTooltip()));
|
item->setToolTip(QString::fromStdString(bus.getTooltip()));
|
||||||
busList->addItem(item);
|
busList->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,7 +282,7 @@ namespace display {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto dialog = new AttributeDialog("Postavi " + attribute.name, "Postavi", &attribute);
|
auto dialog = new AttributeDialog("Postavi " + attribute.attribute.getDisplayName(), "Postavi", &attribute);
|
||||||
if(dialog->exec() == QDialog::Rejected) {
|
if(dialog->exec() == QDialog::Rejected) {
|
||||||
// if any dialog isn't set, whole creation is rejected
|
// if any dialog isn't set, whole creation is rejected
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -44,8 +44,15 @@ namespace domain {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Attribute::Attribute(std::string name, Value defaultValue, std::optional<Popup> popup)
|
Attribute::Attribute(std::string name, std::optional<std::string> displayName, Value defaultValue, std::optional<Popup> popup)
|
||||||
: name(name), defaultValue(defaultValue), popup(popup) {}
|
: name(name), displayName(displayName), defaultValue(defaultValue), popup(popup) {}
|
||||||
|
|
||||||
|
std::string Attribute::getDisplayName() {
|
||||||
|
if(displayName.has_value()) {
|
||||||
|
return *displayName;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Attribute::getName() {
|
std::string Attribute::getName() {
|
||||||
return name;
|
return name;
|
||||||
|
|
|
@ -61,13 +61,16 @@ namespace domain {
|
||||||
|
|
||||||
class Attribute {
|
class Attribute {
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::optional<std::string> displayName;
|
||||||
Value defaultValue;
|
Value defaultValue;
|
||||||
std::optional<Popup> popup;
|
std::optional<Popup> popup;
|
||||||
public:
|
public:
|
||||||
Attribute(std::string name, Value defaultValue, std::optional<Popup> popup = std::nullopt);
|
Attribute(std::string name, std::optional<std::string> displayName, Value defaultValue, std::optional<Popup> popup = std::nullopt);
|
||||||
|
|
||||||
std::string getName();
|
std::string getName();
|
||||||
|
|
||||||
|
std::string getDisplayName();
|
||||||
|
|
||||||
Value getDefault();
|
Value getDefault();
|
||||||
|
|
||||||
std::optional<Popup> getPopup();
|
std::optional<Popup> getPopup();
|
||||||
|
|
|
@ -35,14 +35,21 @@ namespace domain {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bus::Bus(std::string name, std::string instanceName, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires,
|
Bus::Bus(std::string name, std::optional<std::string> displayName, std::string instanceName, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires,
|
||||||
std::optional<ui::Bus> displayBus)
|
std::optional<ui::Bus> displayBus)
|
||||||
: name(name), instanceName(instanceName), tooltip(tooltip), type(type), count(count), wires(wires), displayBus(displayBus) {}
|
: name(name), displayName(displayName), instanceName(instanceName), tooltip(tooltip), type(type), count(count), wires(wires), displayBus(displayBus) {}
|
||||||
|
|
||||||
std::string Bus::getName() {
|
std::string Bus::getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Bus::getDisplayName() {
|
||||||
|
if(displayName.has_value()) {
|
||||||
|
return *displayName;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Bus::getTooltip() {
|
std::string Bus::getTooltip() {
|
||||||
return tooltip;
|
return tooltip;
|
||||||
}
|
}
|
||||||
|
@ -62,4 +69,5 @@ namespace domain {
|
||||||
std::optional<ui::Bus> Bus::getDisplayBus() {
|
std::optional<ui::Bus> Bus::getDisplayBus() {
|
||||||
return displayBus;
|
return displayBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -54,6 +54,7 @@ namespace domain {
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::optional<std::string> displayName;
|
||||||
std::string instanceName;
|
std::string instanceName;
|
||||||
std::string tooltip;
|
std::string tooltip;
|
||||||
BusType type;
|
BusType type;
|
||||||
|
@ -63,11 +64,13 @@ namespace domain {
|
||||||
std::vector<Wire> wires;
|
std::vector<Wire> wires;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Bus(std::string name, std::string instanceName, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires,
|
Bus(std::string name, std::optional<std::string> displayName, std::string instanceName, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires,
|
||||||
std::optional<ui::Bus> display = std::nullopt);
|
std::optional<ui::Bus> display = std::nullopt);
|
||||||
|
|
||||||
std::string getName();
|
std::string getName();
|
||||||
|
|
||||||
|
std::string getDisplayName();
|
||||||
|
|
||||||
std::string getInstanceName();
|
std::string getInstanceName();
|
||||||
|
|
||||||
std::string getTooltip();
|
std::string getTooltip();
|
||||||
|
|
|
@ -2,16 +2,23 @@
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
Component::Component(string name, string tooltip, string source, ComponentType type,
|
Component::Component(string name, optional<string> displayName, string tooltip, string source, ComponentType type,
|
||||||
vector<Rule> rules, string instanceName, pair<int, int> count, Display display,
|
vector<Rule> rules, string instanceName, pair<int, int> count, Display display,
|
||||||
vector<Pin> pins, vector<Attribute> attributes)
|
vector<Pin> pins, vector<Attribute> attributes)
|
||||||
: name(name), tooltip(tooltip), source(source), type(type), rules(rules), instanceName(instanceName),
|
: name(name), displayName(displayName), tooltip(tooltip), source(source), type(type), rules(rules), instanceName(instanceName),
|
||||||
count(count), display(display), pins(pins), attributes(attributes) {}
|
count(count), display(display), pins(pins), attributes(attributes) {}
|
||||||
|
|
||||||
std::string Component::getName() {
|
std::string Component::getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Component::getDisplayName() {
|
||||||
|
if(displayName.has_value()) {
|
||||||
|
return displayName.value();
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Component::getTooltip() {
|
std::string Component::getTooltip() {
|
||||||
return tooltip;
|
return tooltip;
|
||||||
}
|
}
|
||||||
|
@ -94,5 +101,4 @@ namespace domain {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace domain {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::optional<std::string> displayName;
|
||||||
std::string tooltip;
|
std::string tooltip;
|
||||||
std::string source;
|
std::string source;
|
||||||
ComponentType type;
|
ComponentType type;
|
||||||
|
@ -36,12 +37,14 @@ namespace domain {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Component(string name, string tooltip, string source, ComponentType type,
|
Component(string name, optional<string> displayName, string tooltip, string source, ComponentType type,
|
||||||
vector<Rule> rules, string instanceName, pair<int, int> count, Display display,
|
vector<Rule> rules, string instanceName, pair<int, int> count, Display display,
|
||||||
vector<Pin> pins, vector<Attribute> attributes);
|
vector<Pin> pins, vector<Attribute> attributes);
|
||||||
|
|
||||||
std::string getName();
|
std::string getName();
|
||||||
|
|
||||||
|
std::string getDisplayName();
|
||||||
|
|
||||||
std::string getTooltip();
|
std::string getTooltip();
|
||||||
|
|
||||||
std::string getSource();
|
std::string getSource();
|
||||||
|
|
|
@ -199,6 +199,11 @@ namespace domain {
|
||||||
std::optional<Bus> SchemaCreator::loadBus(BusNode node) {
|
std::optional<Bus> SchemaCreator::loadBus(BusNode node) {
|
||||||
std::string busName = node.name.value;
|
std::string busName = node.name.value;
|
||||||
|
|
||||||
|
std::optional<std::string> displayName = nullopt;
|
||||||
|
if(node.displayName.has_value()) {
|
||||||
|
displayName = node.displayName->asString();
|
||||||
|
}
|
||||||
|
|
||||||
if (!node.instanceName) {
|
if (!node.instanceName) {
|
||||||
errors.emplace_back(node.span, "missing @instanceName");
|
errors.emplace_back(node.span, "missing @instanceName");
|
||||||
return nullopt;
|
return nullopt;
|
||||||
|
@ -261,7 +266,7 @@ namespace domain {
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Bus(busName, instanceName, tooltip, type, count, wires, displayBus);
|
return Bus(busName, displayName, instanceName, tooltip, type, count, wires, displayBus);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<AddressSpace> SchemaCreator::loadAddressSpace(AddressSpaceNode node) {
|
std::optional<AddressSpace> SchemaCreator::loadAddressSpace(AddressSpaceNode node) {
|
||||||
|
@ -459,6 +464,11 @@ namespace domain {
|
||||||
|
|
||||||
std::string componentName = node.name.value;
|
std::string componentName = node.name.value;
|
||||||
|
|
||||||
|
std::optional<std::string> displayName = nullopt;
|
||||||
|
if (node.displayName.has_value()) {
|
||||||
|
displayName = node.displayName->asString();
|
||||||
|
}
|
||||||
|
|
||||||
if (!node.tooltip) {
|
if (!node.tooltip) {
|
||||||
errors.emplace_back(node.span, "missing @tooltip");
|
errors.emplace_back(node.span, "missing @tooltip");
|
||||||
pop();
|
pop();
|
||||||
|
@ -535,7 +545,7 @@ namespace domain {
|
||||||
}
|
}
|
||||||
|
|
||||||
pop();
|
pop();
|
||||||
return Component(componentName, tooltip, source, type, rules, instanceName, count, *display, pins, attributes);
|
return Component(componentName, displayName, tooltip, source, type, rules, instanceName, count, *display, pins, attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Wire> SchemaCreator::loadWire(WireNode node) {
|
std::optional<Wire> SchemaCreator::loadWire(WireNode node) {
|
||||||
|
@ -721,6 +731,12 @@ namespace domain {
|
||||||
std::optional<Attribute> SchemaCreator::loadAttribute(AttributeNode node) {
|
std::optional<Attribute> SchemaCreator::loadAttribute(AttributeNode node) {
|
||||||
std::string name = node.name.value;
|
std::string name = node.name.value;
|
||||||
pushAdditional(name);
|
pushAdditional(name);
|
||||||
|
|
||||||
|
std::optional<std::string> displayName = nullopt;
|
||||||
|
if (node.displayName.has_value()) {
|
||||||
|
displayName = node.displayName->asString();
|
||||||
|
}
|
||||||
|
|
||||||
Value value;
|
Value value;
|
||||||
|
|
||||||
if (current().inComponent) {
|
if (current().inComponent) {
|
||||||
|
@ -754,7 +770,7 @@ namespace domain {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current().attributes.emplace_back(name, value);
|
current().attributes.emplace_back(name, nullopt, value);
|
||||||
|
|
||||||
std::optional<Popup> popup;
|
std::optional<Popup> popup;
|
||||||
if (node.popup) {
|
if (node.popup) {
|
||||||
|
@ -762,7 +778,7 @@ namespace domain {
|
||||||
}
|
}
|
||||||
|
|
||||||
pop();
|
pop();
|
||||||
return Attribute(name, value, popup);
|
return Attribute(name, displayName, value, popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Popup> SchemaCreator::loadPopup(PopupNode node, std::string name, Value::ValueType type) {
|
std::optional<Popup> SchemaCreator::loadPopup(PopupNode node, std::string name, Value::ValueType type) {
|
||||||
|
@ -771,7 +787,7 @@ namespace domain {
|
||||||
pushAdditional(name);
|
pushAdditional(name);
|
||||||
|
|
||||||
current().attributes.clear();
|
current().attributes.clear();
|
||||||
current().attributes.emplace_back(name, Value::ofType(type));
|
current().attributes.emplace_back(name, nullopt, Value::ofType(type));
|
||||||
|
|
||||||
if (!node.title) {
|
if (!node.title) {
|
||||||
errors.emplace_back(node.span, "missing @title");
|
errors.emplace_back(node.span, "missing @title");
|
||||||
|
@ -1028,7 +1044,7 @@ namespace domain {
|
||||||
if (std::count_if(attributes.begin(), attributes.end(),
|
if (std::count_if(attributes.begin(), attributes.end(),
|
||||||
[&attr](InstanceAttribute &attribute) { return attr.getName() == attribute.name; }) ==
|
[&attr](InstanceAttribute &attribute) { return attr.getName() == attribute.name; }) ==
|
||||||
0) {
|
0) {
|
||||||
errors.emplace_back(SourceError(instance.span, "missing attribute '" + attr.getName() + "'"));
|
errors.emplace_back(SourceError(instance.span, "missing attribute '" + attr.getDisplayName() + "'"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1062,7 +1078,7 @@ namespace domain {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Attribute> SchemaCreator::createMemoryAttribute() {
|
std::optional<Attribute> SchemaCreator::createMemoryAttribute() {
|
||||||
return Attribute("_memory", Value::fromMemoryReference(std::nullopt), createMemoryPopup());
|
return Attribute("_memory", nullopt, Value::fromMemoryReference(std::nullopt), createMemoryPopup());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Popup> SchemaCreator::createMemoryPopup() {
|
std::optional<Popup> SchemaCreator::createMemoryPopup() {
|
||||||
|
|
|
@ -256,6 +256,8 @@ struct AttributeNode : public AstNode {
|
||||||
ValueNode::ValueType type;
|
ValueNode::ValueType type;
|
||||||
/** Name of attribute */
|
/** Name of attribute */
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
|
/** Display name */
|
||||||
|
std::optional<StringNode> displayName;
|
||||||
/** Default type of attribute */
|
/** Default type of attribute */
|
||||||
std::optional<ValueNode> defaultValue;
|
std::optional<ValueNode> defaultValue;
|
||||||
/** Popup used to change attribute value */
|
/** Popup used to change attribute value */
|
||||||
|
@ -360,6 +362,8 @@ struct ComponentNode : public AstNode {
|
||||||
|
|
||||||
/** Component name */
|
/** Component name */
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
|
/** Component name */
|
||||||
|
std::optional<StringNode> displayName;
|
||||||
/** Tooltip displayed on hover */
|
/** Tooltip displayed on hover */
|
||||||
std::optional<StringNode> tooltip;
|
std::optional<StringNode> tooltip;
|
||||||
/** Contains path to COMDEL source containing current component */
|
/** Contains path to COMDEL source containing current component */
|
||||||
|
@ -425,7 +429,10 @@ struct BusNode : public AstNode {
|
||||||
};
|
};
|
||||||
|
|
||||||
EnumNode<BusType> type;
|
EnumNode<BusType> type;
|
||||||
|
/** Bus name */
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
|
/** Display name */
|
||||||
|
std::optional<StringNode> displayName;
|
||||||
/** Default used to name instances */
|
/** Default used to name instances */
|
||||||
std::optional<IdentifierNode> instanceName;
|
std::optional<IdentifierNode> instanceName;
|
||||||
/** Tooltip displayed on hover */
|
/** Tooltip displayed on hover */
|
||||||
|
|
|
@ -481,6 +481,7 @@ PResult<AddressSpaceNode> ComdelParser::parseAddress() {
|
||||||
*
|
*
|
||||||
* ComponentNode := "@component" + IdentifierNode + ComponentType + "{"
|
* ComponentNode := "@component" + IdentifierNode + ComponentType + "{"
|
||||||
* "@instanceName" + IdentifierNode
|
* "@instanceName" + IdentifierNode
|
||||||
|
* ["@displayName" + StringNode]{0,1}
|
||||||
* "@tooltip" + StringNode
|
* "@tooltip" + StringNode
|
||||||
* "@source" + StringNode
|
* "@source" + StringNode
|
||||||
* "@tooltip" + StringNode
|
* "@tooltip" + StringNode
|
||||||
|
@ -507,6 +508,8 @@ PResult<ComponentNode> ComdelParser::parseComponent() {
|
||||||
PResult<poly<AstNode>> err;
|
PResult<poly<AstNode>> err;
|
||||||
if (consume(TokenType::KW_INSTANCE_NAME)) {
|
if (consume(TokenType::KW_INSTANCE_NAME)) {
|
||||||
ASSIGN_OR_SET_ERR(component.instanceName, parseIdentifier());
|
ASSIGN_OR_SET_ERR(component.instanceName, parseIdentifier());
|
||||||
|
} else if (consume(TokenType::KW_DISPLAY_NAME)) {
|
||||||
|
ASSIGN_OR_SET_ERR(component.displayName, parseString());
|
||||||
} else if (consume(TokenType::KW_TOOLTIP)) {
|
} else if (consume(TokenType::KW_TOOLTIP)) {
|
||||||
ASSIGN_OR_SET_ERR(component.tooltip, parseString());
|
ASSIGN_OR_SET_ERR(component.tooltip, parseString());
|
||||||
} else if (consume(TokenType::KW_SOURCE)) {
|
} else if (consume(TokenType::KW_SOURCE)) {
|
||||||
|
@ -608,6 +611,7 @@ PResult<DisplayItemNode> ComdelParser::parseDisplayItem() {
|
||||||
* BusNode := "@bus " + IdentifierNode + BusType + "{"
|
* BusNode := "@bus " + IdentifierNode + BusType + "{"
|
||||||
* "@tooltip" + StringNode
|
* "@tooltip" + StringNode
|
||||||
* "@instanceName" + StringNode
|
* "@instanceName" + StringNode
|
||||||
|
* ["@displayName" + StringNode]{0,1}
|
||||||
* DisplayNode
|
* DisplayNode
|
||||||
* "@wires {" + [WireNode + ","]{0..N} + WireNode "}"
|
* "@wires {" + [WireNode + ","]{0..N} + WireNode "}"
|
||||||
* "}"
|
* "}"
|
||||||
|
@ -628,6 +632,8 @@ PResult<BusNode> ComdelParser::parseBus() {
|
||||||
PResult<poly<AstNode>> err;
|
PResult<poly<AstNode>> err;
|
||||||
if (consume(TokenType::KW_TOOLTIP)) {
|
if (consume(TokenType::KW_TOOLTIP)) {
|
||||||
ASSIGN_OR_SET_ERR(bus.tooltip, parseString());
|
ASSIGN_OR_SET_ERR(bus.tooltip, parseString());
|
||||||
|
} else if (consume(TokenType::KW_DISPLAY_NAME)) {
|
||||||
|
ASSIGN_OR_SET_ERR(bus.displayName, parseString());
|
||||||
} else if (consume(TokenType::KW_INSTANCE_NAME)) {
|
} else if (consume(TokenType::KW_INSTANCE_NAME)) {
|
||||||
ASSIGN_OR_SET_ERR(bus.instanceName, parseIdentifier());
|
ASSIGN_OR_SET_ERR(bus.instanceName, parseIdentifier());
|
||||||
} else if (consume(TokenType::KW_COUNT)) {
|
} else if (consume(TokenType::KW_COUNT)) {
|
||||||
|
@ -810,10 +816,13 @@ PResult<PinNode> ComdelParser::parsePin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* AttributeNode := "@attribute " + IdentifierNode + ValueType + ("default" + ValueNode){0,1} + ("{" PopupNode "}"){0,1}
|
* AttributeNode := "@attribute " + IdentifierNode + ValueType + ("default" + ValueNode){0,1} + ("{"
|
||||||
*
|
* [PopupNode]
|
||||||
****************************************************************************/
|
* ["@displayName" + StringNode]{0,1}
|
||||||
|
* "}"){0,1}
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
PResult<AttributeNode> ComdelParser::parseAttribute() {
|
PResult<AttributeNode> ComdelParser::parseAttribute() {
|
||||||
auto spanner = getSpanner();
|
auto spanner = getSpanner();
|
||||||
AttributeNode attribute;
|
AttributeNode attribute;
|
||||||
|
@ -889,16 +898,27 @@ PResult<AttributeNode> ComdelParser::parseAttribute() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check(TokenType::LBRACE)) {
|
if (consume(TokenType::LBRACE)) {
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
while(!consume(TokenType::RBRACE)) {
|
||||||
if (!check(TokenType::KW_POPUP)) {
|
PResult<poly<AstNode>> err;
|
||||||
return unexpected();
|
if (check(TokenType::KW_POPUP)) {
|
||||||
}
|
|
||||||
|
|
||||||
PopupNode popup;
|
PopupNode popup;
|
||||||
ASSIGN_OR_RETURN_IF_ERR(popup, parsePopup());
|
ASSIGN_OR_SET_ERR(popup, parsePopup());
|
||||||
attribute.popup = std::optional<PopupNode>(popup);
|
attribute.popup = std::optional<PopupNode>(popup);
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::RBRACE);
|
} else if (consume(TokenType::KW_DISPLAY_NAME)) {
|
||||||
|
ASSIGN_OR_SET_ERR(attribute.displayName, parseString());
|
||||||
|
} else {
|
||||||
|
err = unexpected();
|
||||||
|
bump();
|
||||||
|
}
|
||||||
|
if (!err.has_value()) {
|
||||||
|
errors.push_back(err.error());
|
||||||
|
skipUntilNextKeyword();
|
||||||
|
if (check(TokenType::END_OF_FILE)) {
|
||||||
|
return PError({Span(spanner.lo), "Reached EOF"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return spanner(attribute);
|
return spanner(attribute);
|
||||||
|
|
|
@ -101,6 +101,7 @@ enum class TokenType {
|
||||||
KW_SCHEMA,
|
KW_SCHEMA,
|
||||||
KW_POSITION,
|
KW_POSITION,
|
||||||
KW_SIZE,
|
KW_SIZE,
|
||||||
|
KW_DISPLAY_NAME,
|
||||||
|
|
||||||
// TYPES
|
// TYPES
|
||||||
INT_TYPE,
|
INT_TYPE,
|
||||||
|
|
|
@ -106,6 +106,7 @@ TokenTables::TokenTables() {
|
||||||
add(TokenType::KW_SCHEMA, "@schema", TOKENIZABLE | KEYWORD_NAME);
|
add(TokenType::KW_SCHEMA, "@schema", TOKENIZABLE | KEYWORD_NAME);
|
||||||
add(TokenType::KW_POSITION, "@position", TOKENIZABLE | KEYWORD_NAME);
|
add(TokenType::KW_POSITION, "@position", TOKENIZABLE | KEYWORD_NAME);
|
||||||
add(TokenType::KW_SIZE, "@size", TOKENIZABLE | KEYWORD_NAME);
|
add(TokenType::KW_SIZE, "@size", TOKENIZABLE | KEYWORD_NAME);
|
||||||
|
add(TokenType::KW_DISPLAY_NAME, "@displayName", TOKENIZABLE | KEYWORD_NAME);
|
||||||
|
|
||||||
// All types
|
// All types
|
||||||
add(TokenType::INT_TYPE, "int", TOKENIZABLE);
|
add(TokenType::INT_TYPE, "int", TOKENIZABLE);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@component FRISC processor {
|
@component FRISC processor {
|
||||||
|
@displayName "Frisc procesor"
|
||||||
@instanceName procesor
|
@instanceName procesor
|
||||||
@tooltip "Procesor FRISC, mora postojati jedan"
|
@tooltip "Procesor FRISC, mora postojati jedan"
|
||||||
@count (1, 1)
|
@count (1, 1)
|
||||||
|
@ -131,6 +132,7 @@
|
||||||
}
|
}
|
||||||
@attribute size int default 8
|
@attribute size int default 8
|
||||||
@attribute pocetnaAdresa int default 0 {
|
@attribute pocetnaAdresa int default 0 {
|
||||||
|
@displayName "Početna adresa"
|
||||||
@popup automatic {
|
@popup automatic {
|
||||||
@title "Početna adresa memorije"
|
@title "Početna adresa memorije"
|
||||||
@text "Zadajte početnu adresu memorije"
|
@text "Zadajte početnu adresu memorije"
|
||||||
|
@ -226,12 +228,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@component DMA {
|
@component DMA {
|
||||||
|
@displayName "DMA kontroler"
|
||||||
@instanceName dma
|
@instanceName dma
|
||||||
@tooltip "DMA-kontroler"
|
@tooltip "DMA-kontroler"
|
||||||
@count (0,1000)
|
@count (0,1000)
|
||||||
@source "dma.cdl"
|
@source "dma.cdl"
|
||||||
|
|
||||||
@attribute pocetnaAdresa int default 0 {
|
@attribute pocetnaAdresa int default 0 {
|
||||||
|
@displayName "Početna adresa"
|
||||||
@popup automatic {
|
@popup automatic {
|
||||||
@title "Početna adresa DMA-kontrolera"
|
@title "Početna adresa DMA-kontrolera"
|
||||||
@text "Zadajte početnu adresu DMA-kontrolera"
|
@text "Zadajte početnu adresu DMA-kontrolera"
|
||||||
|
@ -307,6 +311,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@bus glavnaSabirnica regular {
|
@bus glavnaSabirnica regular {
|
||||||
|
@displayName "Glavna sabirnica"
|
||||||
@instanceName glavnaSabirnica
|
@instanceName glavnaSabirnica
|
||||||
@tooltip "sabirnica za spajanje FRISC a s memorijama i UI/jedinicama"
|
@tooltip "sabirnica za spajanje FRISC a s memorijama i UI/jedinicama"
|
||||||
@count (1,1)
|
@count (1,1)
|
||||||
|
|
Loading…
Reference in New Issue