void BlockParams::Read(NxsToken &token) { DemandEndSemicolon(token, "PARAMS"); nat idCtr = 0; auto catsFound = std::unordered_set<Category>{}; while(true) { token.GetNextToken(); NxsBlock::NxsCommandResult res = HandleBasicBlockCommands(token); if (res == NxsBlock::NxsCommandResult(STOP_PARSING_BLOCK)) return; if (res != NxsBlock::NxsCommandResult(HANDLED_COMMAND)) { auto str = token.GetToken(false); auto cat = CategoryFuns::getCategoryFromLinkLabel(str); parseScheme(token, cat, idCtr); if(catsFound.find(cat) != catsFound.end()) { cerr << "parsing error: found a linking scheme for category " << CategoryFuns::getShortName(cat) << " twice. Aborting." ; exitFunction(-1, true); } if( cat == Category::TOPOLOGY) { cerr << "not implemented"; assert(0); } } } }
/*---------------------------------------------------------------------------------------------------------------------- | This function provides the ability to read everything following the block name (which is read by the NxsReader | object) to the end or endblock statement. Characters are read from the input stream in. Overrides the abstract | virtual function in the base class. */ void NxsTaxaBlock::Read( NxsToken &token) /* the token used to read from in */ { ntax = 0; unsigned nominal_ntax = 0; isEmpty = false; isUserSupplied = true; DemandEndSemicolon(token, "BEGIN TAXA"); for (;;) { token.GetNextToken(); if (token.Equals("DIMENSIONS")) { // This should be the NTAX keyword // token.GetNextToken(); if (!token.Equals("NTAX")) { errormsg = "Expecting NTAX keyword, but found "; errormsg += token.GetToken(); errormsg += " instead"; throw NxsException(errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn()); } DemandEquals(token, "after NTAX"); nominal_ntax = DemandPositiveInt(token, "NTAX"); DemandEndSemicolon(token, "DIMENSIONS"); } // if (token.Equals("DIMENSIONS")) else if (token.Equals("TAXLABELS")) { if (nominal_ntax <= 0) { errormsg = "NTAX must be specified before TAXLABELS command"; throw NxsException(errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn()); } for (unsigned i = 0; i < nominal_ntax; i++) { token.GetNextToken(); //@pol should check to make sure this is not punctuation AddTaxonLabel(token.GetToken()); } DemandEndSemicolon(token, "TAXLABELS"); } // if (token.Equals("TAXLABELS")) else if (token.Equals("END") || token.Equals("ENDBLOCK")) { DemandEndSemicolon(token, "ENDBLOCK"); break; } // if (token.Equals("END") || token.Equals("ENDBLOCK")) else { SkippingCommand(token.GetToken()); do { token.GetNextToken(); } while (!token.AtEOF() && !token.Equals(";")); if (token.AtEOF()) { errormsg = "Unexpected end of file encountered"; throw NxsException(errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn()); } } // token not END, ENDBLOCK, TAXLABELS, or DIMENSIONS } // GetNextToken loop }