mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
Update main.cpp
This commit is contained in:
parent
661b2033f9
commit
93be8d7a7b
15
src/main.cpp
15
src/main.cpp
@ -4,7 +4,6 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include "pocketpy.h"
|
#include "pocketpy.h"
|
||||||
|
|
||||||
//#define PK_DEBUG
|
|
||||||
//#define PK_DEBUG_TIME
|
//#define PK_DEBUG_TIME
|
||||||
|
|
||||||
struct Timer{
|
struct Timer{
|
||||||
@ -35,9 +34,6 @@ VM* newVM(){
|
|||||||
void REPL(){
|
void REPL(){
|
||||||
std::cout << "pocketpy 0.1.0" << std::endl;
|
std::cout << "pocketpy 0.1.0" << std::endl;
|
||||||
std::cout << "https://github.com/blueloveTH/pocketpy" << std::endl;
|
std::cout << "https://github.com/blueloveTH/pocketpy" << std::endl;
|
||||||
#ifdef PK_DEBUG
|
|
||||||
std::cout << "[DEBUG MODE ENABLED]" << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int need_more_lines = 0;
|
int need_more_lines = 0;
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
@ -89,10 +85,7 @@ int main(int argc, char** argv){
|
|||||||
|
|
||||||
if(argc == 2){
|
if(argc == 2){
|
||||||
std::string filename = argv[1];
|
std::string filename = argv[1];
|
||||||
if(filename == "-h" || filename == "--help"){
|
if(filename == "-h" || filename == "--help") goto __HELP;
|
||||||
std::cout << "Usage: pocketpy [filename]" << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
if(!file.is_open()){
|
if(!file.is_open()){
|
||||||
@ -107,12 +100,14 @@ int main(int argc, char** argv){
|
|||||||
code = compile(vm, src.c_str(), filename);
|
code = compile(vm, src.c_str(), filename);
|
||||||
});
|
});
|
||||||
if(code == nullptr) return 1;
|
if(code == nullptr) return 1;
|
||||||
|
|
||||||
//std::cout << code->toString() << std::endl;
|
//std::cout << code->toString() << std::endl;
|
||||||
|
|
||||||
Timer("Running time").run([=]{
|
Timer("Running time").run([=]{
|
||||||
vm->exec(code);
|
vm->exec(code);
|
||||||
});
|
});
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__HELP:
|
||||||
|
std::cout << "Usage: pocketpy [filename]" << std::endl;
|
||||||
|
return 0;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user