JetCore/jet-2.0.cpp

39 lines
1.1 KiB
C++
Raw Permalink Normal View History

2024-09-25 17:15:03 -07:00
#include <iostream>
#include <sstream>
#include "File.h"
#include "Global.h"
#include "Exception.h"
#include "__jet.h"
2024-11-18 12:44:41 -08:00
int main(int argc, char **argv, char **envp) {
2024-09-25 17:15:03 -07:00
coreutils::File script(argv[1]);
script.read();
coreutils::ZString data = script.asZString();
data.goeol();
2024-11-18 12:44:41 -08:00
jet::Global global(envp);
2024-09-25 17:15:03 -07:00
try {
coreutils::MString out;
global.errorCursor = data.getCursor();
jet::__jet *jet = new jet::__jet(data, out, global, NULL, NULL);
delete jet;
global.outputHeaders();
std::cout << out;
2024-09-25 17:15:03 -07:00
}
catch(coreutils::Exception e) {
data.setCursor(global.errorCursor);
data.moveBackToLineStart();
std::cout << "-----------------------------" << std::endl;
std::cout << "Error in jet script '" << argv[1] << "' at line " << data.getLineNumberAtCursor() << std::endl;
std::cout << "Error text: " << e.text << std::endl;
std::cout << "-----------------------------" << std::endl;
2024-11-18 16:59:32 -08:00
std::cout << data.parsed() << std::endl;
std::cout << "******** Error caught: " << e.text << std::endl;
std::cout << data.unparsed() << std::endl;
global.dump();
2024-12-21 20:26:46 -08:00
}
2024-09-25 17:15:03 -07:00
}