diff --git a/recursiveDescentParsers/cplusplus/interpreter/Makefile b/recursiveDescentParsers/cplusplus/interpreter/Makefile index bd7ef7e88e247a88d55389f2b540acddb4d21cce..fe0642aeaa4e3182afc4b7a026aad39b8aee3f2c 100644 --- a/recursiveDescentParsers/cplusplus/interpreter/Makefile +++ b/recursiveDescentParsers/cplusplus/interpreter/Makefile @@ -13,8 +13,10 @@ TESTINPUT := goodTest.input badTest.input CC := clang++ ## Add your own CFLAGS if you find them necessary... such as -O3 or so... -CFLAGS := -g -std=c++17 -Wall +CFLAGS := -g -std=c++20 -Wall +# By the way, it should also work with -std=c++17 +# (there's nothing here that requires c++20. ## More preliminaries # See https://www.gnu.org/software/make/manual/html_node/Special-Targets.html diff --git a/recursiveDescentParsers/cplusplus/interpreter/badTest.reference b/recursiveDescentParsers/cplusplus/interpreter/badTest.reference index c2830f438a0a2c2b578318af9ab27b7a2795083b..bb25339d222d00790e9f3fbf5771d8a9ef48fcab 100644 --- a/recursiveDescentParsers/cplusplus/interpreter/badTest.reference +++ b/recursiveDescentParsers/cplusplus/interpreter/badTest.reference @@ -1,33 +1,42 @@ 0:42? INTERPRETER: 42 ERROR on line 0, column 3 : Bad Character(s) found. -42?--^ +42? +--^ 1:42^2 INTERPRETER: 42 ERROR on line 1, column 3 : Bad Character(s) found. -42^2--^ +42^2 +--^ 1:42^2 INTERPRETER: 2 2:(42)) INTERPRETER: 42 2:(42)) ERROR on line 2, column 5 : Expected Left Parenthesis or number -(42))----^ +(42)) +----^ INTERPRETER: 0 3:((42 ERROR on line 4, column 1 : Expected Right Parenthesis -(42 / 0)^ +(42 / 0) +^ ERROR on line 4, column 3 : Expected Right Parenthesis -(42 / 0)--^ +(42 / 0) +--^ ERROR on line 4, column 8 : Division by zero! -(42 / 0)-------^ +(42 / 0) +-------^ INTERPRETER: 0 5:(42 / (1-1)) ERROR on line 5, column 12 : Division by zero! -(42 / (1-1))-----------^ +(42 / (1-1)) +-----------^ ERROR on line 6, column 2 : Expected Right Parenthesis -42 +/- 3.14159-^ +42 +/- 3.14159 +-^ ERROR on line 6, column 5 : Expected Left Parenthesis or number -42 +/- 3.14159----^ +42 +/- 3.14159 +----^ INTERPRETER: -3.14159 End Of File! diff --git a/recursiveDescentParsers/cplusplus/interpreter/interpreter.cpp b/recursiveDescentParsers/cplusplus/interpreter/interpreter.cpp index 6753b12a6161b16e6e25a9c10ff184d657a8545c..8f24ace81530adb14c81cd9f5036552882b25520 100644 --- a/recursiveDescentParsers/cplusplus/interpreter/interpreter.cpp +++ b/recursiveDescentParsers/cplusplus/interpreter/interpreter.cpp @@ -114,7 +114,7 @@ static void printErrorMsg( const std::string Error ) std::cout << "ERROR on line " << currentLineNumber << ", column " << currentColumnNumber << " : " << Error << std::endl; - std::cout << currentLine; + std::cout << currentLine << std::endl; for ( int col = 0; col < currentColumnNumber-1; col++ ) std::cout << '-'; std::cout << '^' << std::endl;