schema_editor/main.cpp

51 lines
2.0 KiB
C++

#include "mainwindow.h"
#include <QApplication>
#include <iostream>
#include <comdel/parser/parsecontext.h>
#include <comdel/parser/parserutil.h>
#include <comdel/domain/comdelgenerator.h>
int main(int argc, char *argv[])
{
/*
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
*/
ParseContext parseContext;
auto schema = loadSchemaFromFile(&parseContext, "/home/bbr/Documents/personal/projects/modeler/schema.csl", std::cout);
if(schema) {
std::vector<domain::FunctionSignature> signatures;
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}));
domain::ComdelGenerator generator(signatures);
auto library = generator.loadLibrary(*schema->library);
for (auto& error : generator.getErrors()) {
parseContext.formatError(error, std::cout, "ERROR: ");
}
if(library) {
auto instance = generator.loadSchema(*schema, *library);
for (auto& error : generator.getErrors()) {
parseContext.formatError(error, std::cout, "ERROR: ");
}
}
}
}