bool ReadString(char *str, int size) { char ch; if (bufpoint >= bufsize) { FillBuf(); } do // remove non symbolic data { if (PopFromBuf(&ch) == false) { return false; } } while (!IsLiteral(ch)); do { if (IsLiteral(ch)) { *str = ch; str++; } else // packet end { *str = 0; // add end of string return true; } } while (PopFromBuf(&ch) == true); return false; }
ExpressionNode* Parser::Factors() { if(currenttoken->type == Id) return Variable(); else if(currenttoken->type == OpenParenthesis){ ConsumeToken(); ExpressionNode * value = Expresion(); if(currenttoken->type != CloseParenthesis) throw invalid_argument("Se esperaba ). Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column)); ConsumeToken(); return value; } else if(IsLiteral(currenttoken)) { return Literal(); } else if(currenttoken->type == Verdadero) { ConsumeToken(); return new ConstantBooleanNode(true); } else if(currenttoken->type == Falso) { ConsumeToken(); return new ConstantBooleanNode(false); } }
vector<CasoLineNode*> Parser::CasoListPrime() { if(IsLiteral(currenttoken)) { return CasoList(); } else { vector<CasoLineNode*> cases; return cases; } }
// { dg-options -std=c++11 } struct IsLiteral {}; constexpr auto ab = IsLiteral(); constexpr IsLiteral bar(IsLiteral x) { return x; } constexpr auto xy = bar(ab);