Skip to content

Commit

Permalink
Merge pull request #1614 from GillesDuvert/close_1604
Browse files Browse the repository at this point in the history
closes #1604
  • Loading branch information
GillesDuvert authored Aug 13, 2023
2 parents 3ed14fa + 10d18c1 commit 5343845
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/GDLInterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ class CUSTOM_API GDLInterpreter : public antlr::TreeParser, public GDLInterprete

static EnvStackT callStack;
static bool noInteractive;
static bool InBatchProcedureAtMain;
static DLong stepCount;
static std::string MyProName;

Expand Down
5 changes: 5 additions & 0 deletions src/basic_pro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,11 @@ namespace lib {
}

void stop(EnvT* e) {
if ( e->Interpreter()->IsInBatchProcedureAtMain() ) {
debugMode = DEBUG_STOP;
e->Throw("Prematurely closing batch file:");
return;
}
if (e->NParam() > 0) {
print(e);
debugMode = DEBUG_STOP_SILENT;
Expand Down
4 changes: 3 additions & 1 deletion src/dinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ EnvStackT GDLInterpreter::callStack;
DLong GDLInterpreter::stepCount;
std::string GDLInterpreter::MyProName;
bool GDLInterpreter::noInteractive; // To exit on error or stop in line execution mode (gdl -e do_something)
bool GDLInterpreter::InBatchProcedureAtMain; // To exit on error or stop in interactive batch file (@file at MAIN level)
ProgNode GDLInterpreter::NULLProgNode;
ProgNodeP GDLInterpreter::NULLProgNodeP = &GDLInterpreter::NULLProgNode;

Expand Down Expand Up @@ -1115,8 +1116,9 @@ DInterpreter::CommandCode DInterpreter::ExecuteLine( istream* in, SizeT lineOffs
file = fileRaw;
CompleteFileName( file);
}

InBatchProcedureAtMain=true;
ExecuteFile( file);
InBatchProcedureAtMain=false;
return CC_OK;
}

Expand Down
1 change: 1 addition & 0 deletions src/dinterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class DInterpreter: public GDLInterpreter
// called within InterpreterLoop()
RetCode InnerInterpreterLoop(SizeT lineOffset);

bool IsInBatchProcedureAtMain(){return InBatchProcedureAtMain;}
};

#endif
1 change: 1 addition & 0 deletions src/gdlc.i.g
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ protected:
static EnvStackT callStack;
static bool noInteractive;
static bool InBatchProcedureAtMain;
static DLong stepCount;
static std::string MyProName;
Expand Down

0 comments on commit 5343845

Please sign in to comment.