Skip to content

Commit

Permalink
Better error output in prolog exe.
Browse files Browse the repository at this point in the history
  • Loading branch information
trishume committed Jun 14, 2012
1 parent ad17d13 commit 07f6b8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
30 changes: 20 additions & 10 deletions turing/src/tprolog.c
Expand Up @@ -366,7 +366,7 @@ int WINAPI WinMain (HINSTANCE pmApplicationInstance,
stTuringProgramPaused = FALSE;
stTuringProgramHalting = FALSE;
stQuittingEnvironment = FALSE;

if(myCompileFile || myUseSeparateFile) printf("Running Program...\n");
do
{
if (!stTuringProgramPaused)
Expand Down Expand Up @@ -452,12 +452,22 @@ int WINAPI WinMain (HINSTANCE pmApplicationInstance,
strlen (SYSEXIT_ERROR_STRING)) != 0))
{
FilePath myErrorPathName;

Language_GetFileName (stErrorPtr -> srcPos.fileNo, myErrorPathName);
EdGUI_Message ("Run Time Error",
"An run-time error has occurred in this program.\n\n"
"Line %d of %s: %s", stErrorPtr -> srcPos.lineNo,
myErrorPathName, stErrorPtr -> text);
if(myCompileFile) {
FileManager_FileName (stErrorPtr -> srcPos.fileNo, myErrorPathName);
} else {
Language_GetFileName (stErrorPtr -> srcPos.fileNo, myErrorPathName);
}
if(myCompileFile || myUseSeparateFile) {
SrcPosition *mySrc = &(stErrorPtr -> srcPos);
printf ("Run time error on line %d [%d-%d] of %s: %s\n",
mySrc->lineNo, mySrc->linePos + 1,mySrc -> linePos + mySrc -> tokLen,
myErrorPathName, stErrorPtr -> text);
} else {
EdGUI_Message ("Run Time Error",
"An run-time error has occurred in this program.\n\n"
"Line %d of %s: %s", stErrorPtr -> srcPos.lineNo,
myErrorPathName, stErrorPtr -> text);
}
}

DestroyWindow (myDummyWindow);
Expand Down Expand Up @@ -1427,7 +1437,7 @@ static BOOL MyInitializeRunFromFile(RunSettings *runSettings, RunArgs *runArgs,
if (myError != NULL)
{
int myMessages = 0;
printf("Syntax Errors:\n");
printf("Compile Errors:\n");
while (myError != NULL)
{
WORD myErrorTuringFileNo;
Expand All @@ -1440,15 +1450,15 @@ static BOOL MyInitializeRunFromFile(RunSettings *runSettings, RunArgs *runArgs,

if (mySrc -> tokLen > 0)
{
printf ("Line %d [%d - %d] of %s: %s\n",
printf ("Error on line %d [%d - %d] of %s: %s\n",
mySrc -> lineNo, mySrc -> linePos + 1,
mySrc -> linePos + 1 + mySrc -> tokLen,
EdFile_GetFileName (myErrorPathName), myError -> text);
}
else
{
printf (
"Line %d [%d] of %s: %s\n",
"Error on line %d [%d] of %s: %s\n",
mySrc -> lineNo, mySrc -> linePos + 1,
EdFile_GetFileName (myErrorPathName), myError -> text);
}
Expand Down
2 changes: 1 addition & 1 deletion turing/test/BasicTest.t
Expand Up @@ -7,7 +7,7 @@ fcn test (hi : int) : int
end if
end test


put eeee
fcn collatz (n : int) : int
var prev := n
loop
Expand Down
Binary file modified turing/test/support/bin/TuringEXEProlog.exe
Binary file not shown.

0 comments on commit 07f6b8d

Please sign in to comment.