Skip to content
This repository
Browse code

Better error output in prolog exe.

  • Loading branch information...
commit 07f6b8d2361242cc2bdc17c1ff8f1abf103a35ee 1 parent ad17d13
Tristan Hume authored
30  turing/src/tprolog.c
@@ -366,7 +366,7 @@ int WINAPI	WinMain (HINSTANCE pmApplicationInstance,
366 366
     stTuringProgramPaused = FALSE;
367 367
     stTuringProgramHalting = FALSE;
368 368
     stQuittingEnvironment = FALSE;
369  
-
  369
+	if(myCompileFile || myUseSeparateFile) printf("Running Program...\n");
370 370
     do
371 371
     {
372 372
     	if (!stTuringProgramPaused)
@@ -452,12 +452,22 @@ int WINAPI	WinMain (HINSTANCE pmApplicationInstance,
452 452
 		  strlen (SYSEXIT_ERROR_STRING)) != 0))
453 453
     {
454 454
     	FilePath	myErrorPathName;
455  
-
456  
-	Language_GetFileName (stErrorPtr -> srcPos.fileNo, myErrorPathName);
457  
-    	EdGUI_Message ("Run Time Error", 
458  
-    	    "An run-time error has occurred in this program.\n\n"
459  
-    	    "Line %d of %s: %s", stErrorPtr -> srcPos.lineNo, 
460  
-    	    myErrorPathName, stErrorPtr -> text);
  455
+		if(myCompileFile) {
  456
+			FileManager_FileName (stErrorPtr -> srcPos.fileNo, myErrorPathName);
  457
+		} else {
  458
+			Language_GetFileName (stErrorPtr -> srcPos.fileNo, myErrorPathName);
  459
+		}
  460
+		if(myCompileFile || myUseSeparateFile) {
  461
+			SrcPosition	*mySrc = &(stErrorPtr -> srcPos);
  462
+			printf ("Run time error on line %d [%d-%d] of %s: %s\n",
  463
+					mySrc->lineNo, mySrc->linePos + 1,mySrc -> linePos + mySrc -> tokLen,
  464
+					myErrorPathName, stErrorPtr -> text);
  465
+		} else {
  466
+    		EdGUI_Message ("Run Time Error", 
  467
+    			"An run-time error has occurred in this program.\n\n"
  468
+    			"Line %d of %s: %s", stErrorPtr -> srcPos.lineNo, 
  469
+    			myErrorPathName, stErrorPtr -> text);
  470
+		}
461 471
     }
462 472
 
463 473
     DestroyWindow (myDummyWindow);
@@ -1427,7 +1437,7 @@ static BOOL MyInitializeRunFromFile(RunSettings *runSettings, RunArgs *runArgs,
1427 1437
     if (myError != NULL)
1428 1438
     {
1429 1439
 		int		myMessages = 0;
1430  
-		printf("Syntax Errors:\n");
  1440
+		printf("Compile Errors:\n");
1431 1441
 		while (myError != NULL)
1432 1442
 		{
1433 1443
 			WORD	myErrorTuringFileNo;
@@ -1440,7 +1450,7 @@ static BOOL MyInitializeRunFromFile(RunSettings *runSettings, RunArgs *runArgs,
1440 1450
 	    
1441 1451
 			if (mySrc -> tokLen > 0)
1442 1452
 			{
1443  
-			printf ("Line %d [%d - %d] of %s: %s\n",
  1453
+			printf ("Error on line %d [%d - %d] of %s: %s\n",
1444 1454
 				mySrc -> lineNo, mySrc -> linePos + 1,
1445 1455
 				mySrc -> linePos + 1 + mySrc -> tokLen, 
1446 1456
 				EdFile_GetFileName (myErrorPathName), myError -> text);
@@ -1448,7 +1458,7 @@ static BOOL MyInitializeRunFromFile(RunSettings *runSettings, RunArgs *runArgs,
1448 1458
 			else
1449 1459
 			{
1450 1460
 			printf ( 
1451  
-				"Line %d [%d] of %s: %s\n",
  1461
+				"Error on line %d [%d] of %s: %s\n",
1452 1462
 				mySrc -> lineNo, mySrc -> linePos + 1,
1453 1463
 				EdFile_GetFileName (myErrorPathName), myError -> text);
1454 1464
 			}
2  turing/test/BasicTest.t
@@ -7,7 +7,7 @@ fcn test (hi : int) : int
7 7
     end if
8 8
 end test
9 9
 
10  
-
  10
+put eeee
11 11
 fcn collatz (n : int) : int
12 12
     var prev := n
13 13
     loop
BIN  turing/test/support/bin/TuringEXEProlog.exe
Binary file not shown

0 notes on commit 07f6b8d

Please sign in to comment.
Something went wrong with that request. Please try again.