schema_editor/main.cpp

51 lines
2.0 KiB
C++
Raw Normal View History

2022-03-29 19:31:45 +00:00
#include "mainwindow.h"
#include <QApplication>
#include <iostream>
#include <comdel/parser/parsecontext.h>
#include <comdel/parser/parserutil.h>
2022-03-31 21:20:41 +00:00
#include <comdel/domain/comdelgenerator.h>
2022-03-29 19:31:45 +00:00
int main(int argc, char *argv[])
{
/*
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
*/
ParseContext parseContext;
2022-03-31 21:20:41 +00:00
auto schema = loadSchemaFromFile(&parseContext, "/home/bbr/Documents/personal/projects/modeler/schema.csl", std::cout);
if(schema) {
std::vector<domain::FunctionSignature> signatures;
2022-04-05 21:48:07 +00:00
signatures.push_back(domain::FunctionSignature("divisible", std::vector<domain::Value::ValueType>{domain::Value::INT, domain::Value::INT}));
signatures.push_back(domain::FunctionSignature("less_then", std::vector<domain::Value::ValueType>{domain::Value::INT, domain::Value::INT}));
signatures.push_back(domain::FunctionSignature("greater_then", std::vector<domain::Value::ValueType>{domain::Value::INT, domain::Value::INT}));
signatures.push_back(domain::FunctionSignature("contains_address", std::vector<domain::Value::ValueType>{domain::Value::ADDRESS_SPACE, domain::Value::INT}));
signatures.push_back(domain::FunctionSignature("contains", std::vector<domain::Value::ValueType>{domain::Value::ADDRESS_SPACE, domain::Value::INT, domain::Value::INT}));
signatures.push_back(domain::FunctionSignature("unique", std::vector<domain::Value::ValueType>{domain::Value::ADDRESS_SPACE, domain::Value::INT, domain::Value::INT}));
2022-03-31 21:20:41 +00:00
domain::ComdelGenerator generator(signatures);
2022-04-05 21:48:07 +00:00
auto library = generator.loadLibrary(*schema->library);
2022-03-31 21:20:41 +00:00
for (auto& error : generator.getErrors()) {
parseContext.formatError(error, std::cout, "ERROR: ");
}
2022-04-05 21:48:07 +00:00
if(library) {
auto instance = generator.loadSchema(*schema, *library);
for (auto& error : generator.getErrors()) {
parseContext.formatError(error, std::cout, "ERROR: ");
}
}
2022-03-31 21:20:41 +00:00
}
2022-03-29 19:31:45 +00:00
}