소스 검색

add of comments for new args parsing

Konstantin Ladutenko 10 년 전
부모
커밋
f8aaf2461e
2개의 변경된 파일11개의 추가작업 그리고 5개의 파일을 삭제
  1. 3 3
      go.sh
  2. 8 2
      standalone.cc

+ 3 - 3
go.sh

@@ -2,9 +2,9 @@
 echo Compile with gcc -O2
 rm -rf *.bin
 
-g++ -O2 -std=c++11 standalone.cc nmie.cc -lm -o scattnlay.bin
+# g++ -O2 -std=c++11 standalone.cc nmie.cc -lm -o scattnlay.bin
 
-clang++ -g -O1 -fsanitize=address  -fno-optimize-sibling-calls -fno-omit-frame-pointer -std=c++11 standalone.cc nmie.cc -lm -o scattnlay.bin
+# clang++ -g -O1 -fsanitize=address  -fno-optimize-sibling-calls -fno-omit-frame-pointer -std=c++11 standalone.cc nmie.cc -lm -o scattnlay.bin
 
 cp scattnlay.bin ../scattnlay
 cd tests/shell
@@ -15,7 +15,7 @@ cd tests/shell
 #     fi
 # done
 PROGRAM='../../../scattnlay'
-ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4 $PROGRAM -l 5 0.4642 1.8000 1.7000 0.7114 0.8000 0.7000 0.7393 1.2000 0.0900 0.9168 2.8000 0.2000 1.0000 1.5000 0.4000 -c test01
+ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4 $PROGRAM -l 5 0.4642 1.8000 1.7000 0.7114 0.8000 0.7000 0.7393 1.2000 0.0900 0.9168 2.8000 0.2000 1.0000 1.5000 0.4000  -t 0.0 90.0 5 -c test01
 
 
 # repeats=30

+ 8 - 2
standalone.cc

@@ -81,7 +81,11 @@ int main(int argc, char *argv[]) {
     int mode = -1; 
     double tmp_mr;
     for (auto arg : args) {
-      //std::cout<< arg << std::endl;
+      // For each arg in args list we detect the change of the current
+      // read mode or read the arg. The reading args algorithm works
+      // as a finite-state machine.
+
+      // Detecting new read mode (if it is a valid -key) 
       if (arg == "-l") {
 	mode = read_L;
 	continue;
@@ -99,6 +103,8 @@ int main(int argc, char *argv[]) {
 	mode = read_comment;
 	continue;
       }
+      // Reading data. For invalid date the exception will be thrown
+      // with the std:: and catched in the end.
       if (mode == read_L) {
 	L = std::stoi(arg);
 	mode = read_x;
@@ -179,7 +185,7 @@ int main(int argc, char *argv[]) {
       throw std::invalid_argument(std::string("Broken structure!\n")
 							 +error_msg);
     if ( (0 == m.size()) || ( 0 == x.size()) ) 
-      throw std::invalid_argument(std::string("Broken structure!\n")
+      throw std::invalid_argument(std::string("Empty structure!\n")
 							 +error_msg);
     
     if (nt < 0) {