feature/read_file #13
@ -1,3 +1,10 @@
|
||||
conf_data = configuration_data()
|
||||
conf_data.set('version', meson.project_version())
|
||||
configure_file(input : 'version.h.in',
|
||||
output : 'version.h',
|
||||
configuration : conf_data
|
||||
)
|
||||
|
||||
obelisk_sources = files(
|
||||
'obelisk.cpp',
|
||||
'lexer.cpp',
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "lexer.h"
|
||||
#include "obelisk.h"
|
||||
#include "parser.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
@ -73,38 +74,62 @@ static int obelisk::mainLoop()
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void obelisk::showUsage()
|
||||
{
|
||||
std::cout << obelisk::usageMessage << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
for (int i = 1; i < argc; i++)
|
||||
std::vector<std::string> sourceFiles;
|
||||
std::string kbFile = "obelisk.kb";
|
||||
|
||||
while (true)
|
||||
{
|
||||
std::cout << argv[i] << std::endl;
|
||||
int option_index = 0;
|
||||
switch (getopt_long(argc, argv, "k:hv", obelisk::long_options, &option_index))
|
||||
{
|
||||
case 'k' :
|
||||
kbFile = std::string(optarg);
|
||||
continue;
|
||||
case 'h' :
|
||||
obelisk::showUsage();
|
||||
return EXIT_SUCCESS;
|
||||
break;
|
||||
case 'v' :
|
||||
std::cout << "obelisk " << obelisk::version << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
break;
|
||||
default :
|
||||
obelisk::showUsage();
|
||||
return EXIT_FAILURE;
|
||||
break;
|
||||
|
||||
case -1 :
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// This can be used to store a double as 2 floats in the database, then restore it back to a double.
|
||||
// Inspired by Godot's double precision on the GPU to render large worlds.
|
||||
/*try
|
||||
if (optind < argc)
|
||||
{
|
||||
float first;
|
||||
float second;
|
||||
double var = 0.123456789012345;
|
||||
|
||||
obelisk::KnowledgeBase* kb = new obelisk::KnowledgeBase("cromer.kb");
|
||||
kb->getFloat(first, second, var);
|
||||
std::cout << std::setprecision(std::numeric_limits<double>::digits10)
|
||||
<< "Double: " << var << std::endl
|
||||
<< "First: " << first << std::endl
|
||||
<< "Second: " << second << std::endl;
|
||||
var = 0.0;
|
||||
kb->getDouble(var, first, second);
|
||||
std::cout << std::setprecision(std::numeric_limits<double>::digits10)
|
||||
<< "Double: " << var << std::endl
|
||||
<< "First: " << first << std::endl
|
||||
<< "Second: " << second << std::endl;
|
||||
while (optind < argc)
|
||||
{
|
||||
sourceFiles.push_back(argv[optind++]);
|
||||
}
|
||||
}
|
||||
catch (obelisk::KnowledgeBaseException& exception)
|
||||
|
||||
if (sourceFiles.size() == 0)
|
||||
{
|
||||
obelisk::showUsage();
|
||||
return EXIT_FAILURE;
|
||||
}*/
|
||||
}
|
||||
|
||||
std::cout << sourceFiles[0] << std::endl;
|
||||
std::cout << kbFile << std::endl;
|
||||
|
||||
return 0;
|
||||
|
||||
return obelisk::mainLoop();
|
||||
}
|
||||
|
@ -1,10 +1,41 @@
|
||||
#include <getopt.h>
|
||||
|
||||
/**
|
||||
* @brief The obelisk namespace contains everything needed to compile obelisk
|
||||
* @brief The obelisk namespace contains everything needed to compile obelisk.
|
||||
* code.
|
||||
*
|
||||
*/
|
||||
namespace obelisk
|
||||
{
|
||||
/**
|
||||
* @brief The usage messsage displayed during help or incorrect usage.
|
||||
*
|
||||
*/
|
||||
std::string usageMessage = R"(Usage: obelisk [OPTION]... [FILE]...
|
||||
Compile the obelisk source FILE(s) into knoweldge base and library.
|
||||
|
||||
Options:
|
||||
-h, --help shows this help/usage message
|
||||
-k, --kb=FILENAME output knowldege base filename
|
||||
-v, --version shows the version of obelisk)";
|
||||
|
||||
/**
|
||||
* @brief The command line arguments that obelisk accepts.
|
||||
*
|
||||
*/
|
||||
static struct option long_options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"kb", required_argument, 0, 'k'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Prints out the usage of obelisk to the stdin.
|
||||
*
|
||||
*/
|
||||
static void showUsage();
|
||||
|
||||
/**
|
||||
* @brief This is the main loop for obelisk.
|
||||
* This loop handles lexing and parsing of obelisk source code.
|
||||
|
8
src/version.h.in
Normal file
8
src/version.h.in
Normal file
@ -0,0 +1,8 @@
|
||||
namespace obelisk
|
||||
{
|
||||
/**
|
||||
* @brief The current version of obelisk.
|
||||
*
|
||||
*/
|
||||
std::string version = "@version@";
|
||||
} // namespace obelisk
|
Loading…
Reference in New Issue
Block a user