Compare commits
No commits in common. "d6c1023df218255ee94d46852b9643c0b38f585b" and "562b77ea0ad762195ab4d0af8dd1879be86b3e7c" have entirely different histories.
d6c1023df2
...
562b77ea0a
|
@ -1 +0,0 @@
|
||||||
{"buildTargets":[],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}}
|
|
|
@ -1,6 +0,0 @@
|
||||||
make --dry-run --always-make --keep-going --print-directory
|
|
||||||
make: Entering directory '/home/bbr/SchemeEditor'
|
|
||||||
make: Leaving directory '/home/bbr/SchemeEditor'
|
|
||||||
|
|
||||||
make: *** No targets specified and no makefile found. Stop.
|
|
||||||
|
|
|
@ -1,288 +0,0 @@
|
||||||
make all --print-data-base --no-builtin-variables --no-builtin-rules --question
|
|
||||||
make: *** No rule to make target 'all'. Stop.
|
|
||||||
|
|
||||||
# GNU Make 4.3
|
|
||||||
# Built for x86_64-pc-linux-gnu
|
|
||||||
# Copyright (C) 1988-2020 Free Software Foundation, Inc.
|
|
||||||
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
|
||||||
# This is free software: you are free to change and redistribute it.
|
|
||||||
# There is NO WARRANTY, to the extent permitted by law.
|
|
||||||
|
|
||||||
# Make data base, printed on Sun Apr 24 22:18:48 2022
|
|
||||||
|
|
||||||
# Variables
|
|
||||||
|
|
||||||
# environment
|
|
||||||
GDK_BACKEND = x11
|
|
||||||
# environment
|
|
||||||
LC_ALL = C
|
|
||||||
# environment
|
|
||||||
NO_AT_BRIDGE = 1
|
|
||||||
# environment
|
|
||||||
VSCODE_IPC_HOOK_EXTHOST = /run/user/1000/vscode-ipc-378bef37-635c-4f71-808d-af9f8b80a929.sock
|
|
||||||
# environment
|
|
||||||
LC_NAME = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
LC_NUMERIC = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
VSCODE_CWD = /home/bbr
|
|
||||||
# environment
|
|
||||||
LC_ADDRESS = hr_HR.UTF-8
|
|
||||||
# default
|
|
||||||
MAKE_COMMAND := make
|
|
||||||
# environment
|
|
||||||
GTK3_MODULES = xapp-gtk3-module
|
|
||||||
# automatic
|
|
||||||
@D = $(patsubst %/,%,$(dir $@))
|
|
||||||
# environment
|
|
||||||
VSCODE_HANDLES_UNCAUGHT_ERRORS = true
|
|
||||||
# default
|
|
||||||
.VARIABLES :=
|
|
||||||
# environment
|
|
||||||
PWD = /home/bbr/SchemeEditor
|
|
||||||
# automatic
|
|
||||||
%D = $(patsubst %/,%,$(dir $%))
|
|
||||||
# environment
|
|
||||||
MAIL = /var/spool/mail/bbr
|
|
||||||
# environment
|
|
||||||
XDG_DATA_DIRS = /usr/local/share:/usr/share:/var/lib/snapd/desktop
|
|
||||||
# automatic
|
|
||||||
^D = $(patsubst %/,%,$(dir $^))
|
|
||||||
# environment
|
|
||||||
VSCODE_LOG_STACK = false
|
|
||||||
# automatic
|
|
||||||
%F = $(notdir $%)
|
|
||||||
# environment
|
|
||||||
VSCODE_CODE_CACHE_PATH = /home/bbr/.config/Code - OSS/CachedData/e18005f0f1b33c29e81d732535d8c0e47cafb0b5
|
|
||||||
# environment
|
|
||||||
XDG_SESSION_PATH = /org/freedesktop/DisplayManager/Session0
|
|
||||||
# environment
|
|
||||||
LANG = C
|
|
||||||
# environment
|
|
||||||
XAUTHORITY = /home/bbr/.Xauthority
|
|
||||||
# default
|
|
||||||
.LOADED :=
|
|
||||||
# default
|
|
||||||
.INCLUDE_DIRS = /usr/include /usr/local/include /usr/include
|
|
||||||
# makefile
|
|
||||||
MAKEFLAGS = pqrR
|
|
||||||
# makefile
|
|
||||||
CURDIR := /home/bbr/SchemeEditor
|
|
||||||
# environment
|
|
||||||
VSCODE_PIPE_LOGGING = true
|
|
||||||
# environment
|
|
||||||
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = true
|
|
||||||
# automatic
|
|
||||||
*D = $(patsubst %/,%,$(dir $*))
|
|
||||||
# environment
|
|
||||||
MFLAGS = -pqrR
|
|
||||||
# environment
|
|
||||||
SSH_AUTH_SOCK = /run/user/1000/keyring/ssh
|
|
||||||
# default
|
|
||||||
.SHELLFLAGS := -c
|
|
||||||
# automatic
|
|
||||||
+D = $(patsubst %/,%,$(dir $+))
|
|
||||||
# environment
|
|
||||||
XDG_SESSION_DESKTOP = budgie-desktop
|
|
||||||
# makefile
|
|
||||||
MAKEFILE_LIST :=
|
|
||||||
# automatic
|
|
||||||
@F = $(notdir $@)
|
|
||||||
# environment
|
|
||||||
VSCODE_VERBOSE_LOGGING = true
|
|
||||||
# environment
|
|
||||||
VSCODE_PID = 1877190
|
|
||||||
# environment
|
|
||||||
XDG_SESSION_TYPE = x11
|
|
||||||
# automatic
|
|
||||||
?D = $(patsubst %/,%,$(dir $?))
|
|
||||||
# environment
|
|
||||||
SESSION_MANAGER = local/bbr:@/tmp/.ICE-unix/1465,unix/bbr:/tmp/.ICE-unix/1465
|
|
||||||
# automatic
|
|
||||||
*F = $(notdir $*)
|
|
||||||
# environment
|
|
||||||
QT_QPA_PLATFORMTHEME = qt5ct
|
|
||||||
# environment
|
|
||||||
CHROME_DESKTOP = code-oss.desktop
|
|
||||||
# environment
|
|
||||||
DBUS_SESSION_BUS_ADDRESS = unix:path=/run/user/1000/bus
|
|
||||||
# automatic
|
|
||||||
<D = $(patsubst %/,%,$(dir $<))
|
|
||||||
# environment
|
|
||||||
VSCODE_NLS_CONFIG = {"locale":"en-gb","availableLanguages":{},"_languagePackSupport":true}
|
|
||||||
# default
|
|
||||||
MAKE_HOST := x86_64-pc-linux-gnu
|
|
||||||
# makefile
|
|
||||||
SHELL = /bin/sh
|
|
||||||
# default
|
|
||||||
MAKECMDGOALS := all
|
|
||||||
# environment
|
|
||||||
DOTNET_BUNDLE_EXTRACT_BASE_DIR = /home/bbr/.cache/dotnet_bundle_extract
|
|
||||||
# environment
|
|
||||||
SHLVL = 0
|
|
||||||
# environment
|
|
||||||
MAKELEVEL := 0
|
|
||||||
# default
|
|
||||||
MAKE = $(MAKE_COMMAND)
|
|
||||||
# environment
|
|
||||||
PATH = /home/bbr/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/home/bbr/.dotnet/tools:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin
|
|
||||||
# default
|
|
||||||
MAKEFILES :=
|
|
||||||
# environment
|
|
||||||
LC_MONETARY = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
MOTD_SHOWN = pam
|
|
||||||
# automatic
|
|
||||||
^F = $(notdir $^)
|
|
||||||
# environment
|
|
||||||
LC_TIME = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
GRADLE_HOME = /usr/share/java/gradle
|
|
||||||
# environment
|
|
||||||
VSCODE_LOG_NATIVE = false
|
|
||||||
# environment
|
|
||||||
LC_TELEPHONE = hr_HR.UTF-8
|
|
||||||
# automatic
|
|
||||||
?F = $(notdir $?)
|
|
||||||
# environment
|
|
||||||
XDG_CURRENT_DESKTOP = Budgie:GNOME
|
|
||||||
# automatic
|
|
||||||
+F = $(notdir $+)
|
|
||||||
# environment
|
|
||||||
XDG_SEAT_PATH = /org/freedesktop/DisplayManager/Seat0
|
|
||||||
# environment
|
|
||||||
DESKTOP_SESSION = budgie-desktop
|
|
||||||
# environment
|
|
||||||
ORIGINAL_XDG_CURRENT_DESKTOP = Budgie:GNOME
|
|
||||||
# 'override' directive
|
|
||||||
GNUMAKEFLAGS :=
|
|
||||||
# environment
|
|
||||||
LOGNAME = bbr
|
|
||||||
# environment
|
|
||||||
GIO_LAUNCHED_DESKTOP_FILE = /usr/share/applications/code-oss.desktop
|
|
||||||
# makefile
|
|
||||||
.DEFAULT_GOAL :=
|
|
||||||
# environment
|
|
||||||
EDITOR = /usr/bin/nano
|
|
||||||
# environment
|
|
||||||
DISPLAY = :0
|
|
||||||
# environment
|
|
||||||
GTK_MODULES = canberra-gtk-module
|
|
||||||
# environment
|
|
||||||
USER = bbr
|
|
||||||
# default
|
|
||||||
MAKE_VERSION := 4.3
|
|
||||||
# environment
|
|
||||||
LC_MEASUREMENT = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
GIO_LAUNCHED_DESKTOP_FILE_PID = 1877159
|
|
||||||
# environment
|
|
||||||
_ = /usr/bin/make
|
|
||||||
# environment
|
|
||||||
LC_PAPER = hr_HR.UTF-8
|
|
||||||
# environment
|
|
||||||
XDG_RUNTIME_DIR = /run/user/1000
|
|
||||||
# environment
|
|
||||||
XDG_SESSION_CLASS = user
|
|
||||||
# environment
|
|
||||||
VSCODE_AMD_ENTRYPOINT = vs/workbench/api/node/extensionHostProcess
|
|
||||||
# environment
|
|
||||||
GTK2_RC_FILES = /home/bbr/.gtkrc-2.0
|
|
||||||
# environment
|
|
||||||
HOME = /home/bbr
|
|
||||||
# environment
|
|
||||||
ELECTRON_RUN_AS_NODE = 1
|
|
||||||
# environment
|
|
||||||
VSCODE_IPC_HOOK = /run/user/1000/vscode-bb99a93f-1.66.0-main.sock
|
|
||||||
# default
|
|
||||||
.RECIPEPREFIX :=
|
|
||||||
# automatic
|
|
||||||
<F = $(notdir $<)
|
|
||||||
# default
|
|
||||||
SUFFIXES :=
|
|
||||||
# environment
|
|
||||||
VSCODE_CLI = 1
|
|
||||||
# environment
|
|
||||||
ELECTRON_NO_ATTACH_CONSOLE = 1
|
|
||||||
# environment
|
|
||||||
XDG_GREETER_DATA_DIR = /var/lib/lightdm-data/bbr
|
|
||||||
# default
|
|
||||||
.FEATURES := target-specific order-only second-expansion else-if shortest-stem undefine oneshell nocomment grouped-target extra-prereqs archives jobserver output-sync check-symlink guile load
|
|
||||||
# environment
|
|
||||||
XDG_MENU_PREFIX = gnome-
|
|
||||||
# environment
|
|
||||||
DOTNET_ROOT = /usr/share/dotnet
|
|
||||||
# environment
|
|
||||||
GDMSESSION = budgie-desktop
|
|
||||||
# environment
|
|
||||||
LC_IDENTIFICATION = hr_HR.UTF-8
|
|
||||||
# variable set hash-table stats:
|
|
||||||
# Load=102/1024=10%, Rehash=0, Collisions=5/129=4%
|
|
||||||
|
|
||||||
# Pattern-specific Variable Values
|
|
||||||
|
|
||||||
# No pattern-specific variable values.
|
|
||||||
|
|
||||||
# Directories
|
|
||||||
|
|
||||||
# . (device 66306, inode 9380506): 17 files, no impossibilities.
|
|
||||||
|
|
||||||
# 17 files, no impossibilities in 1 directories.
|
|
||||||
|
|
||||||
# Implicit Rules
|
|
||||||
|
|
||||||
# No implicit rules.
|
|
||||||
|
|
||||||
# Files
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
Makefile:
|
|
||||||
# Implicit rule search has been done.
|
|
||||||
# File does not exist.
|
|
||||||
# File has been updated.
|
|
||||||
# Failed to be updated.
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
.DEFAULT:
|
|
||||||
# Implicit rule search has not been done.
|
|
||||||
# Modification time never checked.
|
|
||||||
# File has not been updated.
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
all:
|
|
||||||
# Command line target.
|
|
||||||
# Implicit rule search has been done.
|
|
||||||
# File does not exist.
|
|
||||||
# File has not been updated.
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
makefile:
|
|
||||||
# Implicit rule search has been done.
|
|
||||||
# File does not exist.
|
|
||||||
# File has been updated.
|
|
||||||
# Failed to be updated.
|
|
||||||
|
|
||||||
# Not a target:
|
|
||||||
GNUmakefile:
|
|
||||||
# Implicit rule search has been done.
|
|
||||||
# File does not exist.
|
|
||||||
# File has been updated.
|
|
||||||
# Failed to be updated.
|
|
||||||
|
|
||||||
# files hash-table stats:
|
|
||||||
# Load=6/1024=1%, Rehash=0, Collisions=0/15=0%
|
|
||||||
# VPATH Search Paths
|
|
||||||
|
|
||||||
# No 'vpath' search paths.
|
|
||||||
|
|
||||||
# No general ('VPATH' variable) search path.
|
|
||||||
|
|
||||||
# strcache buffers: 1 (0) / strings = 25 / storage = 264 B / avg = 10 B
|
|
||||||
# current buf: size = 8162 B / used = 264 B / count = 25 / avg = 10 B
|
|
||||||
|
|
||||||
# strcache performance: lookups = 28 / hit rate = 10%
|
|
||||||
# hash-table stats:
|
|
||||||
# Load=25/8192=0%, Rehash=0, Collisions=0/28=0%
|
|
||||||
# Finished Make data base on Sun Apr 24 22:18:48 2022
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ add_executable(SchemeEditor
|
||||||
comdel/domain/schemacreator.cpp
|
comdel/domain/schemacreator.cpp
|
||||||
comdel/parser/comdelparser.cpp
|
comdel/parser/comdelparser.cpp
|
||||||
comdel/parser/token.cpp
|
comdel/parser/token.cpp
|
||||||
comdel/parser/sourceerror.cpp
|
comdel/parser/parser_util.cpp
|
||||||
|
comdel/parser/sourceerror.cpp
|
||||||
comdel/parser/parsecontext.cpp
|
comdel/parser/parsecontext.cpp
|
||||||
comdel/parser/tokenstype.cpp
|
comdel/parser/tokenstype.cpp
|
||||||
comdel/parser/astnode.cpp
|
comdel/parser/astnode.cpp
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QGraphicsSceneContextMenuEvent>
|
#include <QGraphicsSceneContextMenuEvent>
|
||||||
#include <QGraphicsScene>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "dialogmanager.h"
|
#include "dialogmanager.h"
|
||||||
|
@ -35,27 +34,10 @@ ComponentWrapper *ComponentWrapper::ofBus(domain::BusInstance *instance) {
|
||||||
component->redraw();
|
component->redraw();
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
void ComponentWrapper::clear() {
|
|
||||||
for(auto item: childItems()) {
|
|
||||||
this->removeFromGroup(item);
|
|
||||||
item->scene()->removeItem(item);
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
if(componentInstance) {
|
|
||||||
componentItem->clear();
|
|
||||||
for(auto pinItem: pinItems) {
|
|
||||||
pinItem->clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComponentWrapper::redraw() {
|
void ComponentWrapper::redraw() {
|
||||||
|
|
||||||
if(componentInstance) {
|
if(componentInstance) {
|
||||||
addToGroup(componentItem);
|
|
||||||
componentItem->redraw();
|
componentItem->redraw();
|
||||||
for(auto pinItem: pinItems) {
|
for(auto pinItem: pinItems) {
|
||||||
addToGroup(pinItem);
|
|
||||||
pinItem->redraw();
|
pinItem->redraw();
|
||||||
}
|
}
|
||||||
this->addToGroup(new QGraphicsSimpleTextItem(QString::fromStdString(componentInstance->name)));
|
this->addToGroup(new QGraphicsSimpleTextItem(QString::fromStdString(componentInstance->name)));
|
||||||
|
@ -78,33 +60,17 @@ ComponentItem::ComponentItem(domain::ComponentInstance *instance, QGraphicsItem
|
||||||
void ComponentItem::redraw() {
|
void ComponentItem::redraw() {
|
||||||
componentInstance->component.getDisplay().render(this);
|
componentInstance->component.getDisplay().render(this);
|
||||||
}
|
}
|
||||||
void ComponentItem::clear() {
|
|
||||||
for(auto item: childItems()) {
|
|
||||||
this->removeFromGroup(item);
|
|
||||||
item->scene()->removeItem(item);
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComponentItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
void ComponentItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
auto instance = this->componentInstance;
|
auto componentInstance = this->componentInstance;
|
||||||
menu.addAction("Izmjeni ime", [instance, this](){
|
menu.addAction("Izmjeni ime", [componentInstance](){DialogManager::updateName(componentInstance);});
|
||||||
DialogManager::updateName(instance);
|
|
||||||
auto *wrapper = static_cast<ComponentWrapper*>(this->parentItem());
|
|
||||||
wrapper->clear();
|
|
||||||
wrapper->redraw();
|
|
||||||
});
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
for(auto attr: componentInstance->attributes) {
|
for(auto attr: componentInstance->attributes) {
|
||||||
bool enabled = attr->attribute.getPopup().has_value();
|
bool enabled = attr->attribute.getPopup().has_value();
|
||||||
|
|
||||||
auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name),
|
auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name),
|
||||||
[attr, this]() {
|
[attr](){DialogManager::updateAttribute(attr);});
|
||||||
DialogManager::updateAttribute(attr);
|
|
||||||
|
|
||||||
this->redraw();
|
|
||||||
});
|
|
||||||
action->setEnabled(enabled);
|
action->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
menu.exec(event->screenPos());
|
menu.exec(event->screenPos());
|
||||||
|
@ -118,12 +84,4 @@ PinItem::PinItem(domain::Pin pin, QGraphicsItem *parent): pin(pin) {
|
||||||
void PinItem::redraw() {
|
void PinItem::redraw() {
|
||||||
pin.getDisplay().render(this);
|
pin.getDisplay().render(this);
|
||||||
}
|
}
|
||||||
void PinItem::clear() {
|
|
||||||
for(auto item: childItems()) {
|
|
||||||
this->removeFromGroup(item);
|
|
||||||
item->scene()->removeItem(item);
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace display
|
} // namespace display
|
||||||
|
|
|
@ -13,7 +13,6 @@ class ComponentItem: public QGraphicsItemGroup
|
||||||
public:
|
public:
|
||||||
ComponentItem(domain::ComponentInstance *instance, QGraphicsItem *parent);
|
ComponentItem(domain::ComponentInstance *instance, QGraphicsItem *parent);
|
||||||
void redraw();
|
void redraw();
|
||||||
void clear();
|
|
||||||
private:
|
private:
|
||||||
domain::ComponentInstance *componentInstance;
|
domain::ComponentInstance *componentInstance;
|
||||||
|
|
||||||
|
@ -26,7 +25,6 @@ class PinItem: public QGraphicsItemGroup
|
||||||
public:
|
public:
|
||||||
PinItem(domain::Pin pin, QGraphicsItem *parent);
|
PinItem(domain::Pin pin, QGraphicsItem *parent);
|
||||||
void redraw();
|
void redraw();
|
||||||
void clear();
|
|
||||||
private:
|
private:
|
||||||
domain::Pin pin;
|
domain::Pin pin;
|
||||||
};
|
};
|
||||||
|
@ -42,23 +40,6 @@ public:
|
||||||
this->setHandlesChildEvents(false);
|
this->setHandlesChildEvents(false);
|
||||||
}
|
}
|
||||||
void redraw();
|
void redraw();
|
||||||
void clear();
|
|
||||||
|
|
||||||
|
|
||||||
QVariant itemChange( GraphicsItemChange change, const QVariant &value ) override
|
|
||||||
{
|
|
||||||
auto response = QGraphicsItem::itemChange(change, value);
|
|
||||||
if (change == ItemPositionChange){
|
|
||||||
if(componentInstance != nullptr) {
|
|
||||||
componentInstance->position.first = (int)scenePos().x();
|
|
||||||
componentInstance->position.second = (int)scenePos().y();
|
|
||||||
} else if(busInstance != nullptr) {
|
|
||||||
busInstance->position.first = (int)scenePos().x();
|
|
||||||
busInstance->position.second = (int)scenePos().y();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
domain::ComponentInstance *componentInstance = nullptr;
|
domain::ComponentInstance *componentInstance = nullptr;
|
||||||
|
|
|
@ -1,45 +1,23 @@
|
||||||
|
//
|
||||||
|
// Created by bbr on 18. 04. 2022..
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef NAME_DIALOG_H
|
#ifndef NAME_DIALOG_H
|
||||||
#define NAME_DIALOG_H
|
#define NAME_DIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLabel>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
#include <comdel/domain/instance.h>
|
#include <comdel/domain/instance.h>
|
||||||
|
|
||||||
namespace display {
|
namespace display {
|
||||||
|
|
||||||
class NameDialog: public QDialog {
|
class NameDialog: public QDialog {
|
||||||
|
|
||||||
QLineEdit *edit;
|
|
||||||
domain::ComponentInstance *instance;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
NameDialog(domain::ComponentInstance *instance) {
|
||||||
|
|
||||||
NameDialog(domain::ComponentInstance *instance): instance(instance) {
|
|
||||||
auto *layout = new QVBoxLayout(this);
|
|
||||||
layout->addWidget(new QLabel("Izmjeni ime", this));
|
|
||||||
|
|
||||||
edit = new QLineEdit(this);
|
|
||||||
edit->insert(instance->name.c_str());
|
|
||||||
layout->addWidget(edit);
|
|
||||||
this->setWindowTitle("Izmjeni ime");
|
|
||||||
auto *button = new QPushButton("Ažuriraj", this);
|
|
||||||
connect(button, &QPushButton::clicked, this, &NameDialog::onNameChange);
|
|
||||||
layout->addWidget(button);
|
|
||||||
this->setLayout(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void onNameChange() {
|
|
||||||
instance->name = this->edit->text().toStdString();
|
|
||||||
this->close();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif //NAME_DIALOG_H
|
#endif //sNAME_DIALOG_H
|
||||||
|
|
|
@ -9,10 +9,10 @@ AddressSpace::AddressSpace(std::string name, long long start, long long end):
|
||||||
std::string AddressSpace::getName() {
|
std::string AddressSpace::getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
long long AddressSpace::getStart() const {
|
long long AddressSpace::getStart() {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
long long AddressSpace::getEnd() const {
|
long long AddressSpace::getEnd() {
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ public:
|
||||||
AddressSpace(std::string name, long long start, long long end);
|
AddressSpace(std::string name, long long start, long long end);
|
||||||
|
|
||||||
std::string getName();
|
std::string getName();
|
||||||
long long getStart() const;
|
long long getStart();
|
||||||
long long getEnd() const;
|
long long getEnd();
|
||||||
|
|
||||||
bool contains(long long int address);
|
bool contains(long long int address);
|
||||||
bool contains(long long int start, long long int end);
|
bool contains(long long int start, long long int end);
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace domain {
|
namespace domain {
|
||||||
|
|
||||||
Wire::Wire(std::string name, WireType type, int width, bool hidden, bool hasTerminate, Value terminateWith)
|
Wire::Wire(std::string name, WireType type, int width, bool hidden, bool hasTermination, long long ifUnterminated)
|
||||||
: name(name), type(type), width(width), hidden(hidden), hasTerminate(hasTerminate), terminateWith(terminateWith)
|
: name(name), type(type), width(width), hidden(hidden), hasTermination(hasTermination), ifUnterminated(ifUnterminated)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string Wire::getName() {
|
std::string Wire::getName() {
|
||||||
|
@ -15,17 +15,18 @@ int Wire::getWidth() {
|
||||||
bool Wire::isHidden() {
|
bool Wire::isHidden() {
|
||||||
return hidden;
|
return hidden;
|
||||||
}
|
}
|
||||||
|
bool Wire::getHasTermination() {
|
||||||
bool Wire::hasTerminateWith() {
|
return hasTermination;
|
||||||
return hasTerminate;
|
|
||||||
}
|
}
|
||||||
Value Wire::getTerminateWith() {
|
long long Wire::getIfUnterminated() {
|
||||||
return terminateWith;
|
return ifUnterminated;
|
||||||
}
|
}
|
||||||
Wire::WireType Wire::getType() {
|
Wire::WireType Wire::getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Bus::Bus(std::string name, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires, std::optional<Display> display)
|
Bus::Bus(std::string name, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires, std::optional<Display> display)
|
||||||
: name(name), tooltip(tooltip), type(type), count(count), wires(wires), display(display)
|
: name(name), tooltip(tooltip), type(type), count(count), wires(wires), display(display)
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define DOMAIN_BUS_H
|
#define DOMAIN_BUS_H
|
||||||
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "value.h"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -27,17 +26,17 @@ private:
|
||||||
WireType type;
|
WireType type;
|
||||||
int width;
|
int width;
|
||||||
bool hidden;
|
bool hidden;
|
||||||
bool hasTerminate;
|
bool hasTermination;
|
||||||
Value terminateWith;
|
long long ifUnterminated;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Wire(std::string name, WireType type, int width, bool hidden, bool hasTerminate, Value terminateWith);
|
Wire(std::string name, WireType type, int width, bool hidden, bool hasTermination, long long ifUnterminated);
|
||||||
|
|
||||||
std::string getName();
|
std::string getName();
|
||||||
int getWidth();
|
int getWidth();
|
||||||
bool isHidden();
|
bool isHidden();
|
||||||
bool hasTerminateWith();
|
bool getHasTermination();
|
||||||
Value getTerminateWith();
|
long long getIfUnterminated();
|
||||||
WireType getType();
|
WireType getType();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@ public:
|
||||||
Connection connection;
|
Connection connection;
|
||||||
WireInstance *wire;
|
WireInstance *wire;
|
||||||
|
|
||||||
virtual ~ConnectionInstance() = default;
|
|
||||||
|
|
||||||
std::vector<InstanceAttribute*> attributes;
|
std::vector<InstanceAttribute*> attributes;
|
||||||
|
|
||||||
ConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute*> attributes, WireInstance *wire, Connection connection);
|
ConnectionInstance(ComponentInstance *instance, std::vector<InstanceAttribute*> attributes, WireInstance *wire, Connection connection);
|
||||||
|
|
|
@ -174,7 +174,7 @@ std::optional<Bus> SchemaCreator::loadBus(BusNode node)
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto type = toType(node.type.value);
|
auto type = toType(node.type);
|
||||||
|
|
||||||
if(!node.tooltip && type == Bus::REGULAR) {
|
if(!node.tooltip && type == Bus::REGULAR) {
|
||||||
errors.push_back(SourceError{node.span, "missing @tooltip"});
|
errors.push_back(SourceError{node.span, "missing @tooltip"});
|
||||||
|
@ -392,7 +392,7 @@ std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
|
||||||
}
|
}
|
||||||
std::string source = node.source->asString();
|
std::string source = node.source->asString();
|
||||||
|
|
||||||
Component::ComponentType type = toType(node.type.value);
|
Component::ComponentType type = toType(node.type);
|
||||||
|
|
||||||
std::vector<Attribute> attributes;
|
std::vector<Attribute> attributes;
|
||||||
for(auto& a: node.attributes) {
|
for(auto& a: node.attributes) {
|
||||||
|
@ -457,18 +457,18 @@ std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
|
||||||
std::optional<Wire> SchemaCreator::loadWire(WireNode node) {
|
std::optional<Wire> SchemaCreator::loadWire(WireNode node) {
|
||||||
return Wire(
|
return Wire(
|
||||||
node.name.value,
|
node.name.value,
|
||||||
toType(node.type.value),
|
toType(node.type),
|
||||||
node.size.value,
|
node.size.value,
|
||||||
node.hidden,
|
node.hidden,
|
||||||
node.hasTerminateWith,
|
node.hasTermination,
|
||||||
toType(node.terminateWith)
|
node.isUnterminated
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<Pin> SchemaCreator::loadPin(PinNode node)
|
optional<Pin> SchemaCreator::loadPin(PinNode node)
|
||||||
{
|
{
|
||||||
std::string name = node.name.value;
|
std::string name = node.name.value;
|
||||||
Pin::PinType type = toType(node.type.value);
|
Pin::PinType type = toType(node.type);
|
||||||
|
|
||||||
if(!node.tooltip) {
|
if(!node.tooltip) {
|
||||||
errors.push_back(SourceError{node.span, "missing @tooltip"});
|
errors.push_back(SourceError{node.span, "missing @tooltip"});
|
||||||
|
@ -559,7 +559,7 @@ std::optional<Display> SchemaCreator::loadDisplay(DisplayNode node)
|
||||||
PinConnection SchemaCreator::loadPinConnection(PinConnectionNode node)
|
PinConnection SchemaCreator::loadPinConnection(PinConnectionNode node)
|
||||||
{
|
{
|
||||||
std::string message = node.message.asString();
|
std::string message = node.message.asString();
|
||||||
PinConnection::ConnectionType type = toType(node.type.value);
|
PinConnection::ConnectionType type = toType(node.type);
|
||||||
return PinConnection(message, type);
|
return PinConnection(message, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +606,7 @@ std::optional<Attribute> SchemaCreator::loadAttribute(AttributeNode node)
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
auto popupType = toType(node.type.value().value);
|
auto popupType = toType(*node.type);
|
||||||
|
|
||||||
pushAdditional(name);
|
pushAdditional(name);
|
||||||
|
|
||||||
|
@ -678,7 +678,7 @@ std::optional<Rule> SchemaCreator::loadRule(RuleNode node)
|
||||||
for(auto& stmt: node.statements) {
|
for(auto& stmt: node.statements) {
|
||||||
auto condition = loadCondition(stmt.condition);
|
auto condition = loadCondition(stmt.condition);
|
||||||
if(condition) {
|
if(condition) {
|
||||||
statements.push_back(IfStatement(*condition, Action(toType(stmt.action.type.value), stmt.action.message.asString())));
|
statements.push_back(IfStatement(*condition, Action(toType(stmt.action.type), stmt.action.message.asString())));
|
||||||
} else {
|
} else {
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,23 +137,4 @@ Value Value::fromNull() {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Value::stringify() {
|
|
||||||
switch (type) {
|
|
||||||
case INT:
|
|
||||||
return std::to_string(intValue);
|
|
||||||
case BOOL:
|
|
||||||
return boolValue ? "true" : "false";
|
|
||||||
case STRING:
|
|
||||||
return "\"" + stringValue + "\"";
|
|
||||||
case NIL:
|
|
||||||
return "null";
|
|
||||||
case WIRE_REFERENCE:
|
|
||||||
case ADDRESS_SPACE_REFERENCE:
|
|
||||||
case ATTRIBUTE_REFERENCE:
|
|
||||||
return reference;
|
|
||||||
default:
|
|
||||||
throw std::exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace domain
|
} // namespace domain
|
||||||
|
|
|
@ -55,8 +55,6 @@ public:
|
||||||
void setBool(bool value);
|
void setBool(bool value);
|
||||||
void setReference(std::string value);
|
void setReference(std::string value);
|
||||||
|
|
||||||
std::string stringify();
|
|
||||||
|
|
||||||
static Value fromInt(long long value);
|
static Value fromInt(long long value);
|
||||||
static Value fromString(std::string value);
|
static Value fromString(std::string value);
|
||||||
static Value fromBool(bool value);
|
static Value fromBool(bool value);
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
#include "astnode.h"
|
#include "astnode.h"
|
||||||
|
|
||||||
/*************************** AST NODE ********************************/
|
|
||||||
|
|
||||||
AstNode::~AstNode() = default;
|
AstNode::~AstNode() = default;
|
||||||
|
|
||||||
/*************************** NUMBER NODE ********************************/
|
NumberNode::NumberNode(std::string expression) {
|
||||||
|
|
||||||
NumberNode::NumberNode(const std::string& expression) {
|
|
||||||
if(expression.size() > 2) {
|
if(expression.size() > 2) {
|
||||||
if(expression.substr(0, 2) == "0x") {
|
if(expression.substr(0, 2) == "0x") {
|
||||||
this->value = std::stoll(expression, 0, 16);
|
this->value = std::stoll(expression, 0, 16);
|
||||||
|
@ -19,84 +15,3 @@ NumberNode::NumberNode(const std::string& expression) {
|
||||||
this->value = std::stoll(expression, 0, 10);
|
this->value = std::stoll(expression, 0, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************** STRING NODE ********************************/
|
|
||||||
|
|
||||||
std::string StringNode::asString() {
|
|
||||||
return value.substr(1, value.length() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************** VALUE NODE ********************************/
|
|
||||||
|
|
||||||
long long ValueNode::asInt() {
|
|
||||||
if(is(INT)) {
|
|
||||||
return intValue.value();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ValueNode::asString() {
|
|
||||||
if(is(STRING)) {
|
|
||||||
return stringValue.value();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ValueNode::asIdentifier() {
|
|
||||||
if(is(IDENTIFIER) || is(WIRE)) {
|
|
||||||
return identifierValue.value();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValueNode::asBool() {
|
|
||||||
if(is(BOOL)) {
|
|
||||||
return boolValue.value();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValueNode::is(ValueNode::ValueType valueType) {
|
|
||||||
return type.value == valueType;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofBool(bool _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(BOOL);
|
|
||||||
value.boolValue = std::optional<bool>(_value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofInt(long long int _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(INT);
|
|
||||||
value.intValue = std::optional<long long>(_value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofString(std::string _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(STRING);
|
|
||||||
value.stringValue = std::optional<std::string>(_value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofIdentifier(std::string _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(IDENTIFIER);
|
|
||||||
value.identifierValue = std::optional<std::string>(_value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofNull() {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(NIL);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueNode ValueNode::ofWire(std::string _value) {
|
|
||||||
ValueNode value;
|
|
||||||
value.type = EnumNode(WIRE);
|
|
||||||
value.identifierValue = std::optional<std::string>(_value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
|
@ -16,27 +16,24 @@ public:
|
||||||
|
|
||||||
AstNode() = default;
|
AstNode() = default;
|
||||||
|
|
||||||
virtual ~AstNode();
|
virtual ~AstNode(); // this is defined in Ast.cpp just so that the
|
||||||
|
// compiler doesn't complain about not knowing which
|
||||||
|
// object file to include the vtable in
|
||||||
AstNode(AstNode&&) = default;
|
AstNode(AstNode&&) = default;
|
||||||
|
|
||||||
AstNode& operator=(AstNode&&) = default;
|
AstNode& operator=(AstNode&&) = default;
|
||||||
AstNode(const AstNode&) = default;
|
AstNode(const AstNode&) = default;
|
||||||
|
|
||||||
AstNode& operator=(const AstNode&) = default;
|
AstNode& operator=(const AstNode&) = default;
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct EnumNode: public AstNode
|
|
||||||
{
|
|
||||||
EnumNode() = default;
|
|
||||||
explicit EnumNode(T value): value(value) {}
|
|
||||||
|
|
||||||
T value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StringNode: public AstNode
|
struct StringNode: public AstNode
|
||||||
{
|
{
|
||||||
std::string value;
|
std::string value;
|
||||||
std::string asString();
|
std::string asString() {
|
||||||
|
return value.substr(1, value.length() - 2);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IdentifierNode: public AstNode
|
struct IdentifierNode: public AstNode
|
||||||
|
@ -46,7 +43,7 @@ struct IdentifierNode: public AstNode
|
||||||
|
|
||||||
struct NumberNode: public AstNode {
|
struct NumberNode: public AstNode {
|
||||||
long long int value;
|
long long int value;
|
||||||
explicit NumberNode(const std::string& expression);
|
NumberNode(std::string expression);
|
||||||
NumberNode(): value(0) {}
|
NumberNode(): value(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +54,7 @@ struct CountNode: public AstNode
|
||||||
NumberNode second;
|
NumberNode second;
|
||||||
|
|
||||||
CountNode(NumberNode first, NumberNode second): first(first), second(second) {}
|
CountNode(NumberNode first, NumberNode second): first(first), second(second) {}
|
||||||
CountNode() = default;
|
CountNode() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,6 +65,7 @@ struct AddressSpaceNode: public AstNode
|
||||||
NumberNode end;
|
NumberNode end;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ValueNode: public AstNode
|
class ValueNode: public AstNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -80,32 +78,89 @@ public:
|
||||||
NIL,
|
NIL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EnumNode<ValueType> type;
|
ValueType type;
|
||||||
std::optional<long long> intValue;
|
std::optional<long long> intValue;
|
||||||
std::optional<std::string> stringValue;
|
std::optional<std::string> stringValue;
|
||||||
std::optional<bool> boolValue;
|
std::optional<bool> boolValue;
|
||||||
std::optional<std::string> identifierValue;
|
std::optional<std::string> identifierValue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValueNode() = default;;
|
ValueNode() {};
|
||||||
|
|
||||||
ValueType getType() {
|
ValueType getType() {
|
||||||
return type.value;
|
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) || is(WIRE)) {
|
||||||
|
return identifierValue.value();
|
||||||
|
}
|
||||||
|
throw "cannot convert type to identifier";
|
||||||
|
}
|
||||||
|
bool asBool() {
|
||||||
|
if(is(BOOL)) {
|
||||||
|
return boolValue.value();
|
||||||
|
}
|
||||||
|
throw "cannot convert type to bool";
|
||||||
}
|
}
|
||||||
long long asInt();
|
|
||||||
std::string asString();
|
|
||||||
std::string asIdentifier();
|
|
||||||
bool asBool();
|
|
||||||
|
|
||||||
bool is(ValueType valueType);
|
bool is(ValueType type) {
|
||||||
|
return this->type == type;
|
||||||
|
}
|
||||||
|
|
||||||
static ValueNode ofBool(bool _value);
|
static ValueNode ofBool(bool _value) {
|
||||||
static ValueNode ofInt(long long _value);
|
ValueNode value;
|
||||||
static ValueNode ofString(std::string _value);
|
value.type = BOOL;
|
||||||
static ValueNode ofIdentifier(std::string _value);
|
value.boolValue = std::optional<bool>(_value);
|
||||||
static ValueNode ofNull();
|
return value;
|
||||||
static ValueNode ofWire(std::string _value);
|
}
|
||||||
|
|
||||||
|
static ValueNode ofInt(long long _value) {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = INT;
|
||||||
|
value.intValue = std::optional<long long>(_value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ValueNode ofString(std::string _value) {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = STRING;
|
||||||
|
value.stringValue = std::optional<std::string>(_value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ValueNode ofIdentifier(std::string _value) {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = IDENTIFIER;
|
||||||
|
value.identifierValue = std::optional<std::string>(_value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ValueNode ofNull() {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = NIL;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ValueNode ofWire(std::string _value) {
|
||||||
|
ValueNode value;
|
||||||
|
value.type = WIRE;
|
||||||
|
value.identifierValue = std::optional<std::string>(_value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConditionNode
|
struct ConditionNode
|
||||||
|
@ -122,7 +177,7 @@ public:
|
||||||
WARNING
|
WARNING
|
||||||
};
|
};
|
||||||
|
|
||||||
EnumNode<ActionType> type;
|
ActionType type;
|
||||||
StringNode message;
|
StringNode message;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -133,11 +188,14 @@ struct IfStatementNode: public AstNode
|
||||||
ActionNode action;
|
ActionNode action;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct RuleNode: public AstNode
|
struct RuleNode: public AstNode
|
||||||
{
|
{
|
||||||
std::vector<IfStatementNode> statements;
|
std::vector<IfStatementNode> statements;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct EnumerationNode: public AstNode
|
struct EnumerationNode: public AstNode
|
||||||
{
|
{
|
||||||
StringNode key;
|
StringNode key;
|
||||||
|
@ -151,7 +209,7 @@ struct PopupNode: public AstNode
|
||||||
ON_DEMAND
|
ON_DEMAND
|
||||||
};
|
};
|
||||||
|
|
||||||
std::optional<EnumNode<PopupType>> type;
|
std::optional<PopupType> type;
|
||||||
std::optional<StringNode> title;
|
std::optional<StringNode> title;
|
||||||
std::optional<StringNode> text;
|
std::optional<StringNode> text;
|
||||||
|
|
||||||
|
@ -167,17 +225,20 @@ struct PropertyNode: public AstNode
|
||||||
ValueNode value;
|
ValueNode value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct DisplayItemNode: public AstNode
|
struct DisplayItemNode: public AstNode
|
||||||
{
|
{
|
||||||
IdentifierNode type;
|
IdentifierNode type;
|
||||||
std::vector<PropertyNode> values;
|
std::vector<PropertyNode> values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct DisplayNode: public AstNode
|
struct DisplayNode: public AstNode
|
||||||
{
|
{
|
||||||
std::vector<DisplayItemNode> items;
|
std::vector<DisplayItemNode> items;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct PinConnectionNode: public AstNode
|
struct PinConnectionNode: public AstNode
|
||||||
{
|
{
|
||||||
enum ConnectionType {
|
enum ConnectionType {
|
||||||
|
@ -186,9 +247,10 @@ struct PinConnectionNode: public AstNode
|
||||||
};
|
};
|
||||||
|
|
||||||
StringNode message;
|
StringNode message;
|
||||||
EnumNode<ConnectionType> type;
|
ConnectionType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct PinNode: public AstNode
|
struct PinNode: public AstNode
|
||||||
{
|
{
|
||||||
enum PinType {
|
enum PinType {
|
||||||
|
@ -198,13 +260,14 @@ struct PinNode: public AstNode
|
||||||
};
|
};
|
||||||
|
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
EnumNode<PinType> type;
|
PinType type;
|
||||||
std::optional<StringNode> tooltip;
|
std::optional<StringNode> tooltip;
|
||||||
std::optional<PinConnectionNode> connection;
|
std::optional<PinConnectionNode> connection;
|
||||||
std::optional<DisplayNode> display;
|
std::optional<DisplayNode> display;
|
||||||
std::optional<std::vector<ValueNode>> wires;
|
std::optional<std::vector<ValueNode>> wires;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct WireNode: public AstNode
|
struct WireNode: public AstNode
|
||||||
{
|
{
|
||||||
enum WireType {
|
enum WireType {
|
||||||
|
@ -213,16 +276,17 @@ struct WireNode: public AstNode
|
||||||
WIRED_OR,
|
WIRED_OR,
|
||||||
R_WIRE
|
R_WIRE
|
||||||
};
|
};
|
||||||
EnumNode<WireType> type;
|
WireType type;
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
NumberNode size;
|
NumberNode size;
|
||||||
|
|
||||||
bool hidden;
|
bool hidden;
|
||||||
|
|
||||||
bool hasTerminateWith;
|
bool hasTermination;
|
||||||
ValueNode terminateWith;
|
long long isUnterminated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct AttributeNode: public AstNode
|
struct AttributeNode: public AstNode
|
||||||
{
|
{
|
||||||
ValueNode::ValueType type;
|
ValueNode::ValueType type;
|
||||||
|
@ -260,7 +324,7 @@ struct ComponentNode: public AstNode
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
std::optional<StringNode> tooltip;
|
std::optional<StringNode> tooltip;
|
||||||
std::optional<StringNode> source;
|
std::optional<StringNode> source;
|
||||||
EnumNode<ComponentType> type;
|
ComponentType type;
|
||||||
std::vector<RuleNode> rules;
|
std::vector<RuleNode> rules;
|
||||||
std::optional<StringNode> instanceName;
|
std::optional<StringNode> instanceName;
|
||||||
std::optional<CountNode> count;
|
std::optional<CountNode> count;
|
||||||
|
@ -269,6 +333,7 @@ struct ComponentNode: public AstNode
|
||||||
std::vector<AttributeNode> attributes;
|
std::vector<AttributeNode> attributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct BusNode: public AstNode
|
struct BusNode: public AstNode
|
||||||
{
|
{
|
||||||
enum BusType {
|
enum BusType {
|
||||||
|
@ -276,7 +341,7 @@ struct BusNode: public AstNode
|
||||||
REGULAR
|
REGULAR
|
||||||
};
|
};
|
||||||
|
|
||||||
EnumNode<BusType> type;
|
BusType type;
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
std::optional<StringNode> tooltip;
|
std::optional<StringNode> tooltip;
|
||||||
std::optional<CountNode> count;
|
std::optional<CountNode> count;
|
||||||
|
@ -302,6 +367,8 @@ struct LibraryNode: public AstNode
|
||||||
};
|
};
|
||||||
|
|
||||||
// SCHEMA models
|
// SCHEMA models
|
||||||
|
|
||||||
|
|
||||||
struct WireInstanceNode: public AstNode
|
struct WireInstanceNode: public AstNode
|
||||||
{
|
{
|
||||||
IdentifierNode name;
|
IdentifierNode name;
|
||||||
|
@ -326,8 +393,7 @@ struct InstanceNode: public AstNode
|
||||||
std::optional<NumberNode> size;
|
std::optional<NumberNode> size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConnectionComponentInstance: public AstNode
|
struct ConnectionComponentInstance {
|
||||||
{
|
|
||||||
IdentifierNode instance;
|
IdentifierNode instance;
|
||||||
IdentifierNode pin;
|
IdentifierNode pin;
|
||||||
};
|
};
|
||||||
|
|
|
@ -409,7 +409,15 @@ PResult<ComponentNode> ComdelParser::parseComponent()
|
||||||
|
|
||||||
ASSIGN_OR_RETURN_IF_ERR(component.name, parseIdentifier());
|
ASSIGN_OR_RETURN_IF_ERR(component.name, parseIdentifier());
|
||||||
|
|
||||||
auto type = parseComponentType();
|
if(check(TokenType::CT_PROCESSOR)) {
|
||||||
|
bump();
|
||||||
|
component.type = ComponentNode::PROCESSOR;
|
||||||
|
} else if(check(TokenType::CT_MEMORY)) {
|
||||||
|
bump();
|
||||||
|
component.type = ComponentNode::MEMORY;
|
||||||
|
} else {
|
||||||
|
component.type = ComponentNode::OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
|
@ -444,23 +452,6 @@ PResult<ComponentNode> ComdelParser::parseComponent()
|
||||||
return spanner(component);
|
return spanner(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
PResult<EnumNode<ComponentNode::ComponentType>> ComdelParser::parseComponentType() {
|
|
||||||
EnumNode<ComponentNode::ComponentType> type;
|
|
||||||
|
|
||||||
auto spanner = getSpanner();
|
|
||||||
|
|
||||||
if(check(TokenType::CT_PROCESSOR)) {
|
|
||||||
bump();
|
|
||||||
type = EnumNode(ComponentNode::PROCESSOR);
|
|
||||||
} else if(check(TokenType::CT_MEMORY)) {
|
|
||||||
bump();
|
|
||||||
type = EnumNode(ComponentNode::MEMORY);
|
|
||||||
} else {
|
|
||||||
type = EnumNode(ComponentNode::OTHER);
|
|
||||||
}
|
|
||||||
return spanner(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
|
@ -518,10 +509,18 @@ PResult<BusNode> ComdelParser::parseBus() {
|
||||||
|
|
||||||
ASSIGN_OR_RETURN_IF_ERR(bus.name, parseIdentifier());
|
ASSIGN_OR_RETURN_IF_ERR(bus.name, parseIdentifier());
|
||||||
|
|
||||||
auto type = parseBusType();
|
if(check(TokenType::IDENTIFIER)) {
|
||||||
RETURN_IF_ERR(type);
|
auto tokenType = parseIdentifier();
|
||||||
|
if(tokenType.value().value == "automatic") {
|
||||||
bus.type = *type;
|
bus.type = BusNode::AUTOMATIC;
|
||||||
|
} else if(tokenType.value().value == "regular") {
|
||||||
|
bus.type = BusNode::REGULAR;
|
||||||
|
} else {
|
||||||
|
return PError(SourceError{current().span, "expected 'automatic' or 'regular'"});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return PError(SourceError{current().span, "expected 'automatic' or 'regular'"});
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
|
@ -554,28 +553,10 @@ PResult<BusNode> ComdelParser::parseBus() {
|
||||||
return spanner(bus);
|
return spanner(bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
PResult<EnumNode<BusNode::BusType>> ComdelParser::parseBusType() {
|
|
||||||
PResult<EnumNode<BusNode::BusType>> type;
|
|
||||||
|
|
||||||
if(check(TokenType::IDENTIFIER)) {
|
|
||||||
auto tokenType = parseIdentifier();
|
|
||||||
if(tokenType.value().value == "automatic") {
|
|
||||||
type = EnumNode(BusNode::AUTOMATIC);
|
|
||||||
} else if(tokenType.value().value == "regular") {
|
|
||||||
type = EnumNode(BusNode::REGULAR);
|
|
||||||
} else {
|
|
||||||
type = PError(SourceError{current().span, "expected 'automatic' or 'regular'"});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
type = PError(SourceError{current().span, "expected 'automatic' or 'regular'"});
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* WireNode := NAME(<SIZE>){0,1} TYPE [hidden | terminated_with (#number | null)])*
|
* WireNode := NAME(<SIZE>){0,1} TYPE)*
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
PResult<WireNode> ComdelParser::parseWire() {
|
PResult<WireNode> ComdelParser::parseWire() {
|
||||||
|
@ -593,42 +574,20 @@ PResult<WireNode> ComdelParser::parseWire() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// default
|
// default
|
||||||
wire.type = EnumNode(WireNode::WIRE);
|
wire.type = WireNode::WIRE;
|
||||||
|
|
||||||
if(check(TokenType::WIRE_DEFAULT)) {
|
if(check(TokenType::WIRE_DEFAULT)) {
|
||||||
bump();
|
bump();
|
||||||
wire.type = EnumNode(WireNode::WIRE);
|
wire.type = WireNode::WIRE;
|
||||||
} else if(check(TokenType::WIRE_AND)) {
|
} else if(check(TokenType::WIRE_AND)) {
|
||||||
bump();
|
bump();
|
||||||
wire.type = EnumNode(WireNode::WIRED_AND);
|
wire.type = WireNode::WIRED_AND;
|
||||||
} else if(check(TokenType::WIRE_OR)) {
|
} else if(check(TokenType::WIRE_OR)) {
|
||||||
bump();
|
bump();
|
||||||
wire.type = EnumNode(WireNode::WIRED_OR);
|
wire.type = WireNode::WIRED_OR;
|
||||||
} else if(check(TokenType::R_WIRE)) {
|
} else if(check(TokenType::R_WIRE)) {
|
||||||
bump();
|
bump();
|
||||||
wire.type = EnumNode(WireNode::R_WIRE);
|
wire.type = WireNode::R_WIRE;
|
||||||
}
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
if(check(TokenType::HIDDEN)) {
|
|
||||||
bump();
|
|
||||||
wire.hidden = true;
|
|
||||||
} else if(check(TokenType::TERMINATE_WITH)) {
|
|
||||||
bump();
|
|
||||||
wire.hasTerminateWith = true;
|
|
||||||
if(check(TokenType::NIL)) {
|
|
||||||
bump();
|
|
||||||
wire.terminateWith = ValueNode::ofNull();
|
|
||||||
} else if(check(TokenType::NUMBER)) {
|
|
||||||
auto number = parseNumber();
|
|
||||||
wire.terminateWith = ValueNode::ofInt(number->value);
|
|
||||||
} else {
|
|
||||||
auto token = current();
|
|
||||||
return PError(SourceError{token.span, "unexpected token"});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return spanner(wire);
|
return spanner(wire);
|
||||||
|
@ -654,13 +613,13 @@ PResult<PinNode> ComdelParser::parsePin() {
|
||||||
|
|
||||||
if(check(TokenType::PIN_IN)) {
|
if(check(TokenType::PIN_IN)) {
|
||||||
bump();
|
bump();
|
||||||
pin.type = EnumNode(PinNode::IN);
|
pin.type = PinNode::IN;
|
||||||
} else if(check(TokenType::PIN_OUT)) {
|
} else if(check(TokenType::PIN_OUT)) {
|
||||||
bump();
|
bump();
|
||||||
pin.type = EnumNode(PinNode::OUT);
|
pin.type = PinNode::OUT;
|
||||||
} else if(check(TokenType::PIN_IN_OUT)) {
|
} else if(check(TokenType::PIN_IN_OUT)) {
|
||||||
bump();
|
bump();
|
||||||
pin.type = EnumNode(PinNode::IN_OUT);
|
pin.type = PinNode::IN_OUT;
|
||||||
} else {
|
} else {
|
||||||
return unexpected();
|
return unexpected();
|
||||||
}
|
}
|
||||||
|
@ -703,7 +662,18 @@ PResult<PinConnectionNode> ComdelParser::parsePinConnection() {
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::KW_CONNECTION);
|
RETURN_IF_NOT_TOKEN(TokenType::KW_CONNECTION);
|
||||||
|
|
||||||
ASSIGN_OR_RETURN_IF_ERR(connection.type, parseConnectionType());
|
if(check(TokenType::IDENTIFIER)) {
|
||||||
|
auto type = parseIdentifier();
|
||||||
|
if(type.value().value == "check_only") {
|
||||||
|
connection.type = PinConnectionNode::CHECK_ONLY;
|
||||||
|
} else if(type.value().value == "automatically") {
|
||||||
|
connection.type = PinConnectionNode::AUTOMATICALLY;
|
||||||
|
} else {
|
||||||
|
return PError(SourceError{current().span, "expected identifiers 'check_only' or 'automatically'"});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return PError(SourceError{current().span, "expected identifiers 'check_only' or 'automatically'"});
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LPAREN);
|
RETURN_IF_NOT_TOKEN(TokenType::LPAREN);
|
||||||
ASSIGN_OR_RETURN_IF_ERR(connection.message, parseString());
|
ASSIGN_OR_RETURN_IF_ERR(connection.message, parseString());
|
||||||
|
@ -712,26 +682,6 @@ PResult<PinConnectionNode> ComdelParser::parsePinConnection() {
|
||||||
return spanner(connection);
|
return spanner(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
PResult<EnumNode<PinConnectionNode::ConnectionType>> ComdelParser::parseConnectionType() {
|
|
||||||
auto spanner = getSpanner();
|
|
||||||
|
|
||||||
EnumNode<PinConnectionNode::ConnectionType> type;
|
|
||||||
|
|
||||||
if(check(TokenType::IDENTIFIER)) {
|
|
||||||
auto identifier = parseIdentifier();
|
|
||||||
if(identifier.value().value == "check_only") {
|
|
||||||
type = EnumNode(PinConnectionNode::CHECK_ONLY);
|
|
||||||
} else if(identifier.value().value == "automatically") {
|
|
||||||
type = EnumNode(PinConnectionNode::AUTOMATICALLY);
|
|
||||||
} else {
|
|
||||||
return PError(SourceError{current().span, "expected identifiers 'check_only' or 'automatically'"});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return PError(SourceError{current().span, "expected identifiers 'check_only' or 'automatically'"});
|
|
||||||
}
|
|
||||||
|
|
||||||
return spanner(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
|
@ -858,16 +808,16 @@ PResult<PopupNode> ComdelParser::parsePopup() {
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::KW_POPUP);
|
RETURN_IF_NOT_TOKEN(TokenType::KW_POPUP);
|
||||||
|
|
||||||
if(check(TokenType::IDENTIFIER)) {
|
if(check(TokenType::IDENTIFIER)) {
|
||||||
auto identifier = parseIdentifier();
|
auto type = parseIdentifier();
|
||||||
if(identifier.value().value == "automatic") {
|
if(type.value().value == "automatic") {
|
||||||
popup.type = EnumNode(PopupNode::AUTOMATIC);
|
popup.type = PopupNode::AUTOMATIC;
|
||||||
} else if(identifier.value().value == "on_demand") {
|
} else if(type.value().value == "on_demand") {
|
||||||
popup.type = EnumNode(PopupNode::ON_DEMAND);
|
popup.type = PopupNode::ON_DEMAND;
|
||||||
} else {
|
} else {
|
||||||
return PError(SourceError{current().span, "expected type 'automatic', 'on_demand'"});
|
return PError(SourceError{current().span, "expected type 'automatic', 'on_demand'"});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
popup.type = EnumNode(PopupNode::ON_DEMAND);
|
popup.type = PopupNode::ON_DEMAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
@ -1025,9 +975,9 @@ PResult<IfStatementNode> ComdelParser::parseIfStatement() {
|
||||||
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
|
||||||
|
|
||||||
if(check(TokenType::ERROR)) {
|
if(check(TokenType::ERROR)) {
|
||||||
ifStatement.action.type = EnumNode(ActionNode::ERROR);
|
ifStatement.action.type = ActionNode::ERROR;
|
||||||
} else if(check(TokenType::WARNING)) {
|
} else if(check(TokenType::WARNING)) {
|
||||||
ifStatement.action.type = EnumNode(ActionNode::WARNING);
|
ifStatement.action.type = ActionNode::WARNING;
|
||||||
} else {
|
} else {
|
||||||
return unexpected();
|
return unexpected();
|
||||||
}
|
}
|
||||||
|
@ -1079,21 +1029,21 @@ std::optional<SchemaNode> ComdelParser::parseSchema() {
|
||||||
auto source = parseString();
|
auto source = parseString();
|
||||||
schema.source = *source;
|
schema.source = *source;
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(current().span, "expected `@source`");
|
errors.push_back(SourceError{current().span, "expected `@source`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errors.emplace_back(current().span, "expected `@source`");
|
errors.push_back(SourceError{current().span, "expected `@source`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!check(TokenType::KW_SCHEMA)) {
|
if(!check(TokenType::KW_SCHEMA)) {
|
||||||
errors.emplace_back(current().span, "expected `@schema`");
|
errors.push_back(SourceError{current().span, "expected `@schema`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
bump();
|
bump();
|
||||||
if(!check(TokenType::LBRACE)) {
|
if(!check(TokenType::LBRACE)) {
|
||||||
errors.emplace_back(current().span, "expected `{`");
|
errors.push_back(SourceError{current().span, "expected `{`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
bump();
|
bump();
|
||||||
|
@ -1115,14 +1065,14 @@ std::optional<SchemaNode> ComdelParser::parseSchema() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!check(TokenType::RBRACE)) {
|
if(!check(TokenType::RBRACE)) {
|
||||||
errors.emplace_back(current().span, "expected `}`");
|
errors.push_back(SourceError{current().span, "expected `}`"});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
} else {
|
} else {
|
||||||
bump();
|
bump();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!check(TokenType::END_OF_FILE)) {
|
if(!check(TokenType::END_OF_FILE)) {
|
||||||
errors.emplace_back(current().span, "expected `EOF`");
|
errors.push_back(SourceError{current().span, "expected `EOF`"});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errors.size())
|
if (errors.size())
|
||||||
|
|
|
@ -97,12 +97,6 @@ public:
|
||||||
std::optional<SchemaNode> parseSchema();
|
std::optional<SchemaNode> parseSchema();
|
||||||
std::optional<LibraryNode> parse();
|
std::optional<LibraryNode> parse();
|
||||||
const std::vector<SourceError>& getErrors();
|
const std::vector<SourceError>& getErrors();
|
||||||
|
|
||||||
PResult<EnumNode<ComponentNode::ComponentType>> parseComponentType();
|
|
||||||
|
|
||||||
PResult<EnumNode<BusNode::BusType>> parseBusType();
|
|
||||||
|
|
||||||
PResult<EnumNode<PinConnectionNode::ConnectionType>> parseConnectionType();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COMDEL_PARSER_H
|
#endif // COMDEL_PARSER_H
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "parser_util.h"
|
||||||
|
|
||||||
|
parser_util::parser_util()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef PARSER_UTIL_H
|
||||||
|
#define PARSER_UTIL_H
|
||||||
|
|
||||||
|
|
||||||
|
class parser_util
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
parser_util();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PARSER_UTIL_H
|
|
@ -124,10 +124,6 @@ enum class TokenType {
|
||||||
ERROR,
|
ERROR,
|
||||||
WARNING,
|
WARNING,
|
||||||
|
|
||||||
// WIRE SETTINGS
|
|
||||||
HIDDEN,
|
|
||||||
TERMINATE_WITH,
|
|
||||||
|
|
||||||
// OTHER
|
// OTHER
|
||||||
END_OF_FILE
|
END_OF_FILE
|
||||||
};
|
};
|
||||||
|
|
|
@ -134,10 +134,10 @@ TokenTables::TokenTables() {
|
||||||
add( TokenType::WARNING, "warning", TOKENIZABLE),
|
add( TokenType::WARNING, "warning", TOKENIZABLE),
|
||||||
|
|
||||||
|
|
||||||
// WireNode settings types
|
// Built-in functions (they are also keywords)
|
||||||
add( TokenType::HIDDEN, "hidden", TOKENIZABLE),
|
/*
|
||||||
add( TokenType::TERMINATE_WITH, "terminate_with", TOKENIZABLE),
|
* TODO
|
||||||
|
*/
|
||||||
// Miscelaneous
|
// Miscelaneous
|
||||||
add( TokenType::END_OF_FILE, "eof" );
|
add( TokenType::END_OF_FILE, "eof" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
@source "frisc_library.csl"
|
|
||||||
|
|
||||||
@schema {
|
|
||||||
@instance proc FRISC {
|
|
||||||
@position (0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
@instance mem Memorija {
|
|
||||||
@position (0, 250)
|
|
||||||
@attribute kapacitet 1024
|
|
||||||
@attribute size 8
|
|
||||||
@attribute pocetnaAdresa 1023
|
|
||||||
}
|
|
||||||
|
|
||||||
@instance bus glavnaSabirnica {
|
|
||||||
@position (0, 200)
|
|
||||||
@size 100
|
|
||||||
}
|
|
||||||
|
|
||||||
@wire wire_001 {
|
|
||||||
@position (50, 116)
|
|
||||||
@display {}
|
|
||||||
}
|
|
||||||
@wire wire_002 {
|
|
||||||
@position (50, 220)
|
|
||||||
@display {}
|
|
||||||
}
|
|
||||||
@connection (proc.glavniPin, bus) {
|
|
||||||
@wire wire_001
|
|
||||||
}
|
|
||||||
@connection (mem.glavniPin, bus) {
|
|
||||||
@wire wire_002
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <comdel/domain/comdelvalidator.h>
|
#include <comdel/domain/comdelvalidator.h>
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
|
@ -36,7 +35,6 @@ void MainWindow::setupUi()
|
||||||
// setup toolbar
|
// setup toolbar
|
||||||
ui->toolBar->addAction("Load library", this, &MainWindow::onLoadLibrary);
|
ui->toolBar->addAction("Load library", this, &MainWindow::onLoadLibrary);
|
||||||
ui->toolBar->addAction("Load schema", this, &MainWindow::onLoadSchema);
|
ui->toolBar->addAction("Load schema", this, &MainWindow::onLoadSchema);
|
||||||
ui->toolBar->addAction("Save schema", this, &MainWindow::onStoreScheme);
|
|
||||||
|
|
||||||
connect(ui->actionValidate, &QAction::triggered, this, &MainWindow::onValidateSchema);
|
connect(ui->actionValidate, &QAction::triggered, this, &MainWindow::onValidateSchema);
|
||||||
|
|
||||||
|
@ -70,8 +68,6 @@ void MainWindow::onLoadLibrary() {
|
||||||
log->clear();
|
log->clear();
|
||||||
|
|
||||||
if(!filename.isEmpty()) {
|
if(!filename.isEmpty()) {
|
||||||
librarySource = filename.toStdString();
|
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
ParseContext parseContext;
|
ParseContext parseContext;
|
||||||
|
@ -81,7 +77,7 @@ void MainWindow::onLoadLibrary() {
|
||||||
library = generator.loadLibrary(*libraryNode);
|
library = generator.loadLibrary(*libraryNode);
|
||||||
|
|
||||||
for (auto& error : generator.getErrors()) {
|
for (auto& error : generator.getErrors()) {
|
||||||
parseContext.formatError(error, buffer, "ERROR: ");
|
parseContext.formatError(error, std::cout, "ERROR: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(generator.getErrors().empty()) {
|
if(generator.getErrors().empty()) {
|
||||||
|
@ -93,7 +89,7 @@ void MainWindow::onLoadLibrary() {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
buffer<<"Bad request"<<std::endl;
|
std::cout<<"Bad request"<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,17 +114,15 @@ void MainWindow::onLoadSchema() {
|
||||||
domain::SchemaCreator generator(signatures);
|
domain::SchemaCreator generator(signatures);
|
||||||
library = generator.loadLibrary(*schemaNode->library);
|
library = generator.loadLibrary(*schemaNode->library);
|
||||||
|
|
||||||
librarySource = schemaNode->source->value;
|
|
||||||
|
|
||||||
for (auto& error : generator.getErrors()) {
|
for (auto& error : generator.getErrors()) {
|
||||||
parseContext.formatError(error, buffer, "ERROR: ");
|
parseContext.formatError(error, std::cout, "ERROR: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(library) {
|
if(library) {
|
||||||
schema = generator.loadSchema(*schemaNode, *library);
|
schema = generator.loadSchema(*schemaNode, *library);
|
||||||
|
|
||||||
for (auto& error : generator.getErrors()) {
|
for (auto& error : generator.getErrors()) {
|
||||||
parseContext.formatError(error, buffer, "ERROR: ");
|
parseContext.formatError(error, std::cout, "ERROR: ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,67 +136,6 @@ void MainWindow::onLoadSchema() {
|
||||||
log->appendPlainText(QString::fromStdString(buffer.str()));
|
log->appendPlainText(QString::fromStdString(buffer.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onStoreScheme() {
|
|
||||||
if(schema == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto filename = QFileDialog::getSaveFileName(this,
|
|
||||||
tr("Save schema"), "/home", tr("Comdel schema (*.csl)"));
|
|
||||||
|
|
||||||
std::ostringstream buffer;
|
|
||||||
|
|
||||||
buffer << "@source " << this->librarySource << std::endl << std::endl;
|
|
||||||
|
|
||||||
buffer << "@schema {" << std::endl;
|
|
||||||
|
|
||||||
for(auto &instance: schema->instances) {
|
|
||||||
auto componentInstance = dynamic_cast<domain::ComponentInstance*>(instance);
|
|
||||||
if(componentInstance != NULL) {
|
|
||||||
buffer << "\t" << "@instance " << componentInstance->name << " " << componentInstance->component.getName() << " {" << std::endl;
|
|
||||||
buffer << "\t\t" << "@position (" << componentInstance->position.first << ", " << componentInstance->position.second << ")" << std::endl;
|
|
||||||
|
|
||||||
for(auto &attribute: instance->attributes) {
|
|
||||||
buffer << "\t\t" << "@attribute " << attribute->name << " " << attribute->value.stringify() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer << "\t}" << std::endl << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto busInstance = dynamic_cast<domain::BusInstance*>(instance);
|
|
||||||
if(busInstance != NULL) {
|
|
||||||
buffer << "\t" << "@instance " << busInstance->name << " " << busInstance->bus.getName() << " {" << std::endl;
|
|
||||||
buffer << "\t\t" << "@position (" << busInstance->position.first << ", " << busInstance->position.second << ")" << std::endl;
|
|
||||||
buffer << "\t\t" << "@size " << busInstance->size << std::endl;
|
|
||||||
buffer << "\t}" << std::endl << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto &wire: schema->wires) {
|
|
||||||
buffer << "\t" << "@wire " << wire->name << " {" << std::endl;
|
|
||||||
buffer << "\t\t" << "@position (" << wire->position.first << ", " << wire->position.second << ")" << std::endl;
|
|
||||||
buffer << "\t\t" << "@display {}" << std::endl;
|
|
||||||
buffer << "\t" << "}" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto &conn: schema->connections) {
|
|
||||||
auto busConn = dynamic_cast<domain::BusConnectionInstance*>(conn);
|
|
||||||
if(busConn) {
|
|
||||||
buffer << "\t" << "@connection (" << busConn->instance->name << "." << busConn->connection.getComponent().pin << ", " << busConn->bus->name << ") {" << std::endl;
|
|
||||||
buffer << "\t\t"<< "@wire " << busConn->wire->name << std::endl;
|
|
||||||
buffer << "\t" << "}" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer << "}" << std::endl;
|
|
||||||
|
|
||||||
auto value = buffer.str();
|
|
||||||
|
|
||||||
std::ofstream out(filename.toStdString(), std::ios::out | std::ios::binary);
|
|
||||||
out<<buffer.str();
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onValidateSchema(bool /*toggled*/) {
|
void MainWindow::onValidateSchema(bool /*toggled*/) {
|
||||||
if(schema == nullptr) {
|
if(schema == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -268,4 +201,4 @@ void MainWindow::clear() {
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,8 @@ private slots:
|
||||||
void onLoadLibrary();
|
void onLoadLibrary();
|
||||||
void onLoadSchema();
|
void onLoadSchema();
|
||||||
void onValidateSchema(bool toggled);
|
void onValidateSchema(bool toggled);
|
||||||
void onStoreScheme();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string librarySource;
|
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QPlainTextEdit *log;
|
QPlainTextEdit *log;
|
||||||
std::vector<domain::ValidationError> validationErrors;
|
std::vector<domain::ValidationError> validationErrors;
|
||||||
|
|
Loading…
Reference in New Issue