@@ -71,11 +71,19 @@ struct RawToken {
7171 type = RawTokenType::STR;
7272 return *this ;
7373 }
74+ /*
7475 RawToken& operator=(const double v) {
7576 dvalue = v;
7677 type = RawTokenType::CONS;
7778 return *this;
7879 }
80+ */
81+ RawToken& operator =(const std::pair<double , std::string> vs) {
82+ dvalue = vs.first ;
83+ svalue = vs.second ;
84+ type = RawTokenType::CONS;
85+ return *this ;
86+ }
7987};
8088
8189enum class ProcessedTokenType {
@@ -875,7 +883,32 @@ void Reader::splittokens() {
875883
876884void Reader::processtokens () {
877885 std::string svalue_lc;
886+ int pass_n = 0 ;
887+ const bool report_tokens = true ;
888+ printf (" RawTokenType::NONE = %d\n " , int (RawTokenType::NONE));
889+ printf (" RawTokenType::STR = %d\n " , int (RawTokenType::STR));
890+ printf (" RawTokenType::CONS = %d\n " , int (RawTokenType::CONS));
878891 while (!rawtokens[0 ].istype (RawTokenType::FLEND)) {
892+ if (report_tokens) {
893+ pass_n++;
894+ if (pass_n == 9 ) {
895+ printf (" pass_n = 9\n " );
896+ }
897+ printf (" \n Pass %d\n " , pass_n);
898+ /*
899+ if (rawtokens[2].dvalue == 55) {
900+ rawtokens[2].type = RawTokenType(1);
901+ rawtokens[2].dvalue = 0;
902+ rawtokens[2].svalue = "55";
903+ }
904+ */
905+ for (int i = 0 ; i < NRAWTOKEN; i++) {
906+ printf (" Token %d: type = %2d; dvalue = %d; svalue = %s\n " , i,
907+ int (rawtokens[i].type ),
908+ int (rawtokens[i].dvalue ),
909+ rawtokens[i].svalue .c_str ());
910+ }
911+ }
879912 fflush (stdout);
880913
881914 // Slash + asterisk: comment, skip everything up to next asterisk + slash
@@ -954,6 +987,17 @@ void Reader::processtokens() {
954987 continue ;
955988 }
956989
990+ // constraint identifier - with numeric constant value as name?
991+ if (rawtokens[0 ].istype (RawTokenType::CONS) &&
992+ rawtokens[1 ].istype (RawTokenType::COLON)) {
993+ printf (" rawtokens[0] - CONS; rawtokens[1] - COLON; rawtokens[0].dvalue = %g; rawtokens[0].svalue = %s\n " , rawtokens[0 ].dvalue , rawtokens[0 ].svalue .c_str ());
994+ // rawtokens[0].svalue = std::to_string(rawtokens[0].dvalue);
995+ processedtokens.emplace_back (ProcessedTokenType::CONID,
996+ rawtokens[0 ].svalue );
997+ nextrawtoken (2 );
998+ continue ;
999+ }
1000+
9571001 // check if free
9581002 if (rawtokens[0 ].istype (RawTokenType::STR) &&
9591003 iskeyword (svalue_lc, LP_KEYWORD_FREE, LP_KEYWORD_FREE_N)) {
@@ -1113,6 +1157,14 @@ void Reader::processtokens() {
11131157 // FILEEND should have been handled in condition of while()
11141158 assert (!rawtokens[0 ].istype (RawTokenType::FLEND));
11151159
1160+ if (report_tokens) {
1161+ for (int i = 0 ; i < NRAWTOKEN; i++) {
1162+ printf (" Token %d: type = %2d; dvalue = %d; svalue = %s\n " , i,
1163+ int (rawtokens[i].type ),
1164+ int (rawtokens[i].dvalue ),
1165+ rawtokens[i].svalue .c_str ());
1166+ }
1167+ }
11161168 // catch all unknown symbols
11171169 lpassert (false );
11181170 break ;
@@ -1184,7 +1236,12 @@ bool Reader::readnexttoken(RawToken& t) {
11841236
11851237 // check single character tokens
11861238 char nextchar = this ->linebuffer [this ->linebufferpos ];
1187-
1239+ printf (" Reader::readnexttoken: nextchar = %c\n " , nextchar);
1240+ char char_1 = ' 1' ;
1241+ char char_r = ' r' ;
1242+ if (nextchar == char_1 || nextchar == char_r) {
1243+ printf (" Reader::readnexttoken: nextchar = %c!\n " , nextchar);
1244+ }
11881245 switch (nextchar) {
11891246 // check for comment
11901247 case ' \\ ' :
@@ -1280,7 +1337,13 @@ bool Reader::readnexttoken(RawToken& t) {
12801337 char * endptr;
12811338 double constant = strtod (startptr, &endptr);
12821339 if (endptr != startptr) {
1283- t = constant;
1340+ // Extract the string corresponding to the double, in case the
1341+ // double is a constraint name
1342+ size_t double_len = endptr - startptr;
1343+ std::string double_name = this ->linebuffer .substr (this ->linebufferpos , double_len);
1344+ printf (" double_len = %d; double_name = %s\n " , int (double_len), double_name.c_str ());
1345+ // t = constant;
1346+ t = std::make_pair (constant, double_name);
12841347 this ->linebufferpos += endptr - startptr;
12851348 return true ;
12861349 }
0 commit comments