// ----------------------------------------------- Literal::getLiteralConTipo() std::string Literal::getLiteralConTipo() { std::string toret; if ( tipo != LitStr ) toret = getLiteral(); else toret = '"' + getLiteral() + '"'; return toret; }
std::string Clause::toString() const{ std::stringstream ss; int nbLiterals = getNbLiterals(); if (!nbLiterals) return std::string("()"); if (nbLiterals== 1){ss << "(" << getLiteral(0) << ")"; return ss.str();} ss << "(" << getLiteral(0) << " + "; for (int i = 1; i < nbLiterals-1; ++i){ ss << getLiteral(i) << " + "; } ss << getLiteral(nbLiterals - 1) << ")"; return ss.str(); }
void printfcall(){ ident_t tmp, id; if(sym->type!=LPAREN){ msg(ERR, "missing \'(\'", line); ERROR_STATUS = 1; } nextSym(); if(sym->type!=STRLIT){ tmp = expression(0); gen(OUT, tmp, 0, 0); }else{ readLiteral(); id = getLiteral(global, sym); gen(OUT, id, 0, 0); nextSym(); if(sym->type==COMMA){ nextSym(); tmp = expression(0); gen(OUT, tmp, 0, 0); } } if(sym->type!=RPAREN){ msg(ERR, "missing \')\'", line); ERROR_STATUS = 1; } nextSym(); }
ClauseFile MakeALUClause(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I) const { MachineBasicBlock::iterator ClauseHead = I; std::vector<MachineInstr *> ClauseContent; I++; for (MachineBasicBlock::instr_iterator E = MBB.instr_end(); I != E;) { if (IsTrivialInst(I)) { ++I; continue; } if (!I->isBundle() && !TII->isALUInstr(I->getOpcode())) break; std::vector<int64_t> Literals; if (I->isBundle()) { MachineInstr *DeleteMI = I; MachineBasicBlock::instr_iterator BI = I.getInstrIterator(); while (++BI != E && BI->isBundledWithPred()) { BI->unbundleFromPred(); for (unsigned i = 0, e = BI->getNumOperands(); i != e; ++i) { MachineOperand &MO = BI->getOperand(i); if (MO.isReg() && MO.isInternalRead()) MO.setIsInternalRead(false); } getLiteral(BI, Literals); ClauseContent.push_back(BI); } I = BI; DeleteMI->eraseFromParent(); } else { getLiteral(I, Literals); ClauseContent.push_back(I); I++; } for (unsigned i = 0, e = Literals.size(); i < e; i+=2) { unsigned literal0 = Literals[i]; unsigned literal2 = (i + 1 < e)?Literals[i + 1]:0; MachineInstr *MILit = BuildMI(MBB, I, I->getDebugLoc(), TII->get(AMDGPU::LITERALS)) .addImm(literal0) .addImm(literal2); ClauseContent.push_back(MILit); } } ClauseHead->getOperand(7).setImm(ClauseContent.size() - 1); return ClauseFile(ClauseHead, ClauseContent); }
Literal ClaspVmtf::doSelect(Solver& s) { decay_ += ((s.stats.solve.choices + 1) & 511) == 0; for (; s.value(*front_) != value_free; ++front_) {;} Literal c; if (s.numFreeVars() > 1) { VarList::iterator v2 = front_; uint32 distance = 0; do { ++v2; ++distance; } while (s.value(*v2) != value_free); c = (score_[*front_].activity(decay_) + (distance<<1)+ 3) > score_[*v2].activity(decay_) ? getLiteral(s, *front_) : getLiteral(s, *v2); } else { c = getLiteral(s, *front_); } return c; }
int ObjLexer::AddNewToken(Token::Type const& type, int i, std::string const& raw_object) { Token new_token; new_token.SetType(type); std::string str = getLiteral(i, raw_object); if (IsNumber(str)) new_token.SetFloat(StringToNumber<float>(str)); tokens_.push(new_token); return str.size(); }
// makeToken {{{ int CLexer::makeToken() { //if(isEOF()) return ILexer::RET_EOF; CToken* token=NULL; int ret = ILexer::RET_NORMAL; // トークンの作成 while(token == NULL) { skipBlanks(); if(isComment()) { skipLine(); continue; } if( (token = getEOF()) != NULL){ret = ILexer::RET_EOF; break;} if( (token = getEOL()) != NULL){ret = ILexer::RET_EOL; nowLine_++;break;} // トークン取得開始 if( (token = getKeyword()) != NULL) break; if( (token = getOperator()) != NULL) break; if( (token = getIdentifier()) != NULL) break; if( (token = getLiteral('\'',false)) != NULL) break; if( (token = getLiteral('"',true)) != NULL) break; if( (token = getConstant()) != NULL) break; if( (token = getSeparator()) != NULL) break; // エラー処理 onAnalyzeError(); } topToken_ = token; makeTokenRet_ = ret; return ret; }
//////////////////////////////////////////////////////////////////////////////// // Assumes that the options are sorted by decreasing length, so that if the // options contain 'fourteen' and 'four', the stream is first matched against // the longer entry. bool Nibbler::getOneOf ( const std::vector <std::string>& options, std::string& found) { for (auto& option : options) { if (getLiteral (option)) { found = option; return true; } } return false; }
void MultiAggregate::checkTrueInference( Solver& solver, Literal lit ) { trace_msg( multiaggregates, 3, "Checking true inference: max possible sum = " << maxPossibleSum ); unsigned int posInTrail = solver.getPositionInTrail( lit.getVariable() ); for( unsigned int i = 1; i < literals.size(); i++ ) { Literal current = getLiteral( i ); trace_msg( multiaggregates, 4, "Considering literal " << current ); if( solver.isTrue( current ) ) continue; if( solver.isUndefined( current ) || solver.getPositionInTrail( current.getVariable() ) > posInTrail ) { if( maxPossibleSum - getWeight( i ) >= getBound( w1 ) ) break; if( !inferLiteral( solver, current, false, i ) ) return; } } }
void jumpentry(ident_t expr, ident_t nextlab){ ident_t lit; readLiteral(); if(!isLiteral(sym)){ // error occur; } if(sym->type!=INTEGER && sym->type!=CHARLIT){ // error occur; } lit = getLiteral(global, sym); gen(CMP, expr, lit, 0); gen(JNE, nextlab, 0, 0); nextSym(); if(sym->type!=COLON){ // error occur; } nextSym(); statement(); }
ident_t factor(){ ident_t ret = 0; symbol_t id; if(sym->type==ID){ id = copySym(sym); nextSym(); if(sym->type!=LPAREN){ if(context) ret = findTable(context->local, (char*)(id->value)); if(!ret) ret = findTable(global, (char*)(id->value)); if(!ret){ msg(ERR, "undefined identifier", line); ERROR_STATUS = 1; } return ret; } nextSym(); if((ret = funccall(id))==0){ msg(ERR, "no value return from function", line); ERROR_STATUS = 1; } mfree(id); }else if(sym->type==LPAREN){ nextSym(); ret = expression(tn); if(sym->type!=RPAREN){ msg(ERR, "missing \')\'", line); ERROR_STATUS = 1; } nextSym(); }else if(isLiteral(sym) || isAddOperator(sym)){ readLiteral(); ret = getLiteral(global, sym); nextSym(); } return ret; }
void Real::print() { printf(" >> <NUMBER>\t\t %f (real)\n", getLiteral()); }
void GetFORTRANBlock( ss_block *ss_new, char *start, int text_col ) { int length = 0; if( start[0] == '\0' ) { if( text_col == 0 ) { // line is empty - // do not flag following line as having anything to do // with an unterminated string from previous line flags.inString = false; } getBeyondText( ss_new ); return; } if( iscomment( firstChar ) ) { getComment( ss_new, start ); return; } if( text_col <= 4 ) { getLabelOrWS( ss_new, start, text_col ); return; } if( text_col == 5 ) { getContinuationOrWS( ss_new, start ); return; } if( flags.inString ) { getLiteral( ss_new, start, 0 ); return; } if( isspace( start[0] ) ) { getWhiteSpace( ss_new, start ); return; } switch( start[0] ) { case '!': getComment( ss_new, start ); return; case '\'': getLiteral( ss_new, start, 1 ); return; case '.': if( isdigit( start[1] ) ) { getFloat( ss_new, start, 1, AFTER_DOT ); return; } length = islogical( start ); if( length > 0 ) { getSymbol( ss_new, length ); return; } } if( issymbol( start[0] ) ) { getSymbol( ss_new, 1 ); return; } if( isdigit( *start ) ) { getNumber( ss_new, start ); return; } if( isalpha( *start ) || (*start == '_') || (*start == '$') ) { getText( ss_new, start ); return; } getInvalidChar( ss_new ); }
void xml::lex::getDTD(xml::token *tok) { static const char* s_system = "SYSTEM"; static const char* s_public = "PUBLIC"; static const char* s_markupDeclStart = "["; static const char* s_markupDeclEnd = "]"; static const char* s_entityDecl = "<!ENTITY"; static const char* s_entityEnd = ">"; static const char* s_parsedEntityRef = "%"; dtdTop:; switch (m_sstate) { case _xml_dtd_name : if (handleWhitespace() == false) { throw GException("XML Parser", 20, m_line, m_byte); } if (getName(tok) == false) { throw GException("XML Parser", 0, m_line, m_byte); } m_documentType = new char[tok->length() + 1]; memcpy(m_documentType, tok->get(), tok->length()); m_documentType[tok->length()] = 0; tok->release(); handleWhitespace(); // check for external identifiers if (handleReserved(s_system) != false) m_sstate = _xml_system_literal; else if (handleReserved(s_public) != false) m_sstate = _xml_public_literal; else m_sstate = _xml_pre_markup; goto dtdTop; case _xml_system_literal : if (handleWhitespace() == false) { throw GException("XML Parser", 20, m_line, m_byte); } getQuote(); tok->m_type = _systemLiteral; getLiteral(tok); getQuote(); // load the external DTD using the // DTD callback function if (m_state == xml::_xml_dtd) loadExternal(m_lpfnExternalDTD, tok); m_sstate = _xml_pre_markup; break; case _xml_public_literal : if (handleWhitespace() == false) { throw GException("XML Parser", 20, m_line, m_byte); } getQuote(); tok->m_type = _publicLiteral; getLiteral(tok); getQuote(); m_sstate = _xml_system_literal; break; case _xml_pre_markup : handleWhitespace(); if (handleReserved(s_markupDeclStart) != false) { m_sstate = _xml_markup; goto dtdTop; } m_sstate = _xml_post_markup; break; case _xml_markup : handleWhitespace(); if (handleReserved(s_markupDeclEnd) != false) { m_sstate = _xml_post_markup; goto dtdTop; } getMisc(tok); // look for elements, attribute lists, entities, and notation if (tok->m_type == xml::_unknown) { if (handleReserved(s_entityDecl) != false) { m_parameterEntity = false; if (handleWhitespace() == false) { throw GException("XML Parser", 20, m_line, m_byte); } // declaration of a parameter entity if (handleReserved(s_parsedEntityRef) != false) { m_parameterEntity = true; if (handleWhitespace() == false) { throw GException("XML Parser", 20, m_line, m_byte); } } tok->m_type = _entityName; if (getName(tok) == false) { throw GException("XML Parser", 11, m_line, m_byte); } xml::entity *p = new xml::entity(); p->setTag(tok); if (m_parameterEntity == false) { if (m_generalEntities != 0) m_generalEntities->AddLast(p); } else { if (m_parameterEntities != 0) m_parameterEntities->AddLast(p); } m_sstate = _xml_entity; } else if (handleReserved(s_parsedEntityRef) != false) { handleEntityReference(); goto dtdTop; } } break; case _xml_entity : if (handleWhitespace() == false) { throw GException("XML Parser", 20, m_line, m_byte); } getQuote(); tok->m_type = xml::_entityValue; if (getEntity(tok) != false) { xml::entity *p = 0; if (m_parameterEntity == false) { if (m_generalEntities != 0) p = (xml::entity *)m_generalEntities->Last(); } else { if (m_parameterEntities != 0) p = (xml::entity *)m_parameterEntities->Last(); } p->setValue(tok); } else { throw GException("XML Parser", 9, m_line, m_byte); } getQuote(); m_sstate = _xml_entity_end; break; case _xml_entity_end : handleWhitespace(); if (handleReserved(s_entityEnd) == false) { throw GException("XML Parser", 7, m_line, m_byte); } m_sstate = _xml_markup; goto dtdTop; case _xml_post_markup : handleWhitespace(); if ((handleReserved(s_entityEnd) == false) && (m_postmarkup != false)) { throw GException("XML Parser", 1, m_line, m_byte); } m_state = _misc; m_nextState = _content; m_sstate = _xml_element_start; } if ((m_state == _xml_dtd) && (tok->m_type == xml::_unknown)) { m_sstate = _xml_post_markup; goto dtdTop; } }
void Integer::print() { //cout << " >> <NUMBER>\t\t" << getLiteral() << " (integer)\n"; printf(" >> <NUMBER>\t\t %d (integer)\n", getLiteral()); }