inttoktype yylex() { register ptrall bufptr; register inttoktype val; register struct exp *locxp; /* * No local variables to be allocated; this saves * one piddling instruction.. */ static int Lastjxxx; bufptr = tokptr; /*copy in the global value*/ top: if (bufptr < tokub){ gtoken(val, bufptr); switch(yylval = val){ case PARSEEOF: yylval = val = PARSEEOF; break; case BFINT: case INT: if (xp >= &explist[NEXP]) yyerror("Too many expressions; try simplyfing"); else locxp = xp++; locxp->e_number = Znumber; locxp->e_number.num_tag = TYPL; glong(locxp->e_xvalue, bufptr); makevalue: locxp->e_xtype = XABS; locxp->e_xloc = 0; locxp->e_xname = NULL; yylval = (int)locxp; break; case BIGNUM: if (xp >= &explist[NEXP]) yyerror("Too many expressions; try simplyfing"); else locxp = xp++; gnumber(locxp->e_number, bufptr); goto makevalue; case NAME: gptr(yylval, bufptr); lastnam = (struct symtab *)yylval; break; case SIZESPEC: case REG: gchar(yylval, bufptr); break; case INSTn: case INST0: gopcode(yyopcode, bufptr); break; case IJXXX: gopcode(yyopcode, bufptr); /* We can't cast Lastjxxx into (int *) here.. */ gptr(Lastjxxx, bufptr); lastjxxx = (struct symtab *)Lastjxxx; break; case ILINESKIP: gint(yylval, bufptr); lineno += yylval; goto top; case SKIP: eatskiplg(bufptr); goto top; case VOID: goto top; case STRING: case ISTAB: case ISTABSTR: case ISTABNONE: case ISTABDOT: case IALIGN: gptr(yylval, bufptr); break; } #ifdef DEBUG if (toktrace){ char *tok_to_name(); printf("P: %d T#: %4d, %s ", passno, bufptr - firsttoken, tok_to_name(val)); switch(val){ case INT: printf("val %d", ((struct exp *)yylval)->e_xvalue); break; case BFINT: printf("val %d", ((struct exp *)yylval)->e_xvalue); break; case BIGNUM: bignumprint(((struct exp*)yylval)->e_number); break; case NAME: printf("\"%.8s\"", FETCHNAME((struct symtab *)yylval)); break; case REG: printf(" r%d", yylval); break; case IJXXX: case INST0: case INSTn: printf("%.8s", FETCHNAME(ITABFETCH(yyopcode))); break; case STRING: printf("length %d, seekoffset %d, place 0%o ", ((struct strdesc *)yylval)->sd_strlen, ((struct strdesc *)yylval)->sd_stroff, ((struct strdesc *)yylval)->sd_place ); if (((struct strdesc *)yylval)->sd_place & STR_CORE) printf("value\"%*s\"", ((struct strdesc *)yylval)->sd_strlen, ((struct strdesc *)yylval)->sd_string); break; } /*end of the debug switch*/ printf("\n"); } #endif DEBUG } else { /* start a new buffer */ if (useVM){ if (passno == 2){ tok_temp = emptybuf->tok_next; emptybuf->tok_next = tok_free; tok_free = emptybuf; emptybuf = tok_temp; } else { emptybuf = emptybuf->tok_next; } bufno += 1; if (emptybuf == 0){ struct tokbufdesc *newdallop; int i; if (passno == 2) goto badread; emptybuf = newdallop = (struct tokbufdesc *) Calloc(TOKDALLOP, sizeof (struct tokbufdesc)); for (i=0; i < TOKDALLOP; i++){ buftail->tok_next = newdallop; buftail = newdallop; newdallop += 1; } buftail->tok_next = 0; } /*end of need to get more buffers*/ (bytetoktype *)bufptr = &(emptybuf->toks[0]); if (passno == 1) scan_dot_s(emptybuf); } else { /*don't use VM*/ bufno ^= 1; emptybuf = &tokbuf[bufno]; ((bytetoktype *)bufptr) = &(emptybuf->toks[0]); if (passno == 1){ /* * First check if there are things to write * out at all */ if (emptybuf->tok_count >= 0){ if (writeTEST((char *)emptybuf, sizeof *emptybuf, 1, tokfile)){ yyerror("Unexpected end of file writing the interpass tmp file"); exit(2); } } scan_dot_s(emptybuf); } else { /*pass 2*/ if (readTEST((char *)emptybuf, sizeof *emptybuf, 1, tokfile)){ badread: yyerror("Unexpected end of file while reading the interpass tmp file"); exit(1); } } } /*end of using a real live file*/ (char *)tokub = (char *)bufptr + emptybuf->tok_count; #ifdef DEBUG firsttoken = bufptr; if (debug) printf("created buffernumber %d with %d tokens\n", bufno, emptybuf->tok_count); #endif DEBUG goto top; } /*end of reading/creating a new buffer*/ tokptr = bufptr; /*copy back the global value*/ return(val); } /*end of yylex*/
// Method to store satellite data in this class' data map void SatDataReader::loadData(void) throw(FFStreamError, gpstk::StringUtils::StringException) { // Do this until end-of-file reached or something else happens while(1) { try { std::string line; formattedGetLine(line, true); // If line is too long, we throw an exception if (line.size()>255) { FFStreamError e("Line too long"); GPSTK_THROW(e); } // Let's find and strip comments, wherever they are if( StringUtils::firstWord(line)[0] == '#' ) { formattedGetLine(line, true); } std::string::size_type idx = line.find('#'); if( !(idx == std::string::npos) ) { line = line.substr(0, idx); } // We erase the header (first line) if( StringUtils::firstWord(line) == "Launch" ) { formattedGetLine(line, true); } // Remove trailing and leading blanks line = StringUtils::strip(line); // Skip blank lines if (line.size()==0) { continue; } // Let's start to get data out of file // Launch date string ldate(StringUtils::stripFirstWord(line)); // Deactivation date string ddate(StringUtils::stripFirstWord(line)); // GPS number string gnumber(StringUtils::stripFirstWord(line)); // PRN number string prn(StringUtils::stripFirstWord(line)); // Block tipe string block(StringUtils::upperCase( StringUtils::stripFirstWord(line))); // Get satellite id. If it doesn't fit GPS or Glonass, it is // marked as unknown SatID sat(StringUtils::asInt(prn),SatID::systemUnknown); // Let's identify satellite system if(block[0] == 'I') { sat.system = SatID::systemGPS; } else { if (block.substr(0, 3) == "GLO") { sat.system = SatID::systemGlonass; } } // Declare the structure to store data SatDataReader::svData data; data.block = block; data.gpsNumber = StringUtils::asInt(gnumber); // Get launch date in a proper format if(ldate[0] != '0') { ldate = StringUtils::translate(ldate, "-", " "); scanTime(data.launchDate, ldate, "%Y %m %d"); } // Get deactivation date in a proper format if(ddate[0] != '0') { ddate = StringUtils::translate(ddate, "-", " "); scanTime(data.deactivationDate, ddate, "%Y %m %d"); } // It's not a good way!!! data.launchDate.setTimeSystem(TimeSystem::Any); data.deactivationDate.setTimeSystem(TimeSystem::Any); // Insert data in data map setData(sat, data); } // End of try block catch (EndOfFile& e) { // Close this data stream (*this).close(); return; } catch (...) { // Close this data stream (*this).close(); return; } } // End of while(1) } // End of method 'SatDataReader::loadData()'