本文整理汇总了C++中consume函数的典型用法代码示例。如果您正苦于以下问题:C++ consume函数的具体用法?C++ consume怎么用?C++ consume使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了consume函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consume_loop
void *
consume_loop(void *vptr)
{
int i, val;
printf("consume_loop thread, addr(stack) = %x\n", &i);
for (i = 0; i < NLOOP; i++) {
val = consume(&buf_t);
}
return(NULL);
}
示例2: NEW
/* [<id> [, <formals>]] */
static Formals *formals() {
Formals *p = 0;
if (isId()) {
p = NEW(Formals);
p->first = getId();
consume();
p->n = 1;
p->rest = 0;
if (isComma()) {
consume();
p->rest = formals();
if (p->rest) {
p->n = p->rest->n + 1;
}
}
}
return p;
}
示例3: compile_document
/*
* top-level compilation; break the document into
* style, html, and source blocks with footnote links
* weeded out.
*/
static Paragraph *
compile_document(Line *ptr, MMIOT *f)
{
ParagraphRoot d = { 0, 0 };
ANCHOR(Line) source = { 0, 0 };
Paragraph *p = 0;
struct kw *tag;
int eaten, unclosed;
while ( ptr ) {
if ( !(f->flags & MKD_NOHTML) && (tag = isopentag(ptr)) ) {
/* If we encounter a html/style block, compile and save all
* of the cached source BEFORE processing the html/style.
*/
if ( T(source) ) {
E(source)->next = 0;
p = Pp(&d, 0, SOURCE);
p->down = compile(T(source), 1, f);
T(source) = E(source) = 0;
}
p = Pp(&d, ptr, strcmp(tag->id, "STYLE") == 0 ? STYLE : HTML);
ptr = htmlblock(p, tag, &unclosed);
if ( unclosed ) {
p->typ = SOURCE;
p->down = compile(p->text, 1, f);
p->text = 0;
}
}
else if ( isfootnote(ptr) ) {
/* footnotes, like cats, sleep anywhere; pull them
* out of the input stream and file them away for
* later processing
*/
ptr = consume(addfootnote(ptr, f), &eaten);
}
else {
/* source; cache it up to wait for eof or the
* next html/style block
*/
ATTACH(source,ptr);
ptr = ptr->next;
}
}
if ( T(source) ) {
/* if there's any cached source at EOF, compile
* it now.
*/
E(source)->next = 0;
p = Pp(&d, 0, SOURCE);
p->down = compile(T(source), 1, f);
}
return T(d);
}
示例4: main
int main(int argc, char ** argv)
{
unsigned char * payload = malloc(PAYLOAD_LEN);
unsigned char tag = server(payload);
// Now consume the tag and the payload.
// This is not part of the model and in fact would violate secrecy if observable.
consume(tag, payload);
return 0;
}
示例5: FNTRACE
std::unique_ptr<Expr> FlowParser::interpolatedStr()
{
FNTRACE();
FlowLocation sloc(location());
std::unique_ptr<Expr> result = std::make_unique<StringExpr>(stringValue(), sloc.update(end()));
nextToken(); // interpolation start
std::unique_ptr<Expr> e(expr());
if (!e)
return nullptr;
result = asString(std::move(result));
if (!result) {
reportError("Cast error in string interpolation.");
return nullptr;
}
while (token() == FlowToken::InterpolatedStringFragment) {
FlowLocation tloc = sloc.update(end());
result = std::make_unique<BinaryExpr>(
Opcode::SADD,
std::move(result),
std::make_unique<StringExpr>(stringValue(), tloc)
);
nextToken();
e = expr();
if (!e)
return nullptr;
e = asString(std::move(e));
if (!e) {
reportError("Cast error in string interpolation.");
return nullptr;
}
result = std::make_unique<BinaryExpr>(Opcode::SADD, std::move(result), std::move(e));
}
if (!consume(FlowToken::InterpolatedStringEnd))
return nullptr;
if (!stringValue().empty()) {
result = std::make_unique<BinaryExpr>(
Opcode::SADD,
std::move(result),
std::make_unique<StringExpr>(stringValue(), sloc.update(end()))
);
}
nextToken();
return result;
}
示例6: D
void D()
{
//printf("\nEnter <D>");
if(!strcmp(token,"CONSTANT"))
consume();
if(!(strcmp(token,"FLT_TYP") && strcmp(token,"BOOL_TYP") && strcmp(token,"INT_TYP") && strcmp(token,"STR_TYP")))
{
consume();
V();
if(!strcmp(token,"STMNT_END"))
consume();
else
{
//error("Unterminated Declaration statement. Expecting ;");
}
}
//printf("\nExit <D>");
}
示例7: main
int main (int argc, char **argv)
{
printf("pong started.\n");
unsigned int i;
for (i = 0; i < 20; i++) {
if (i % 2 == 0)
consume();
}
return 0;
}
示例8: consume
Generator::ParenthesesType Parser::consumeParenthesesType()
{
if (peek() != '?')
return Generator::Capturing;
consume();
switch (consume()) {
case ':':
return Generator::NonCapturing;
case '=':
return Generator::Assertion;
case '!':
return Generator::InvertedAssertion;
default:
setError(ParenthesesTypeInvalid);
return Generator::Error;
}
}
示例9: consume
void Parser::forStat() {
consume(TK_for);
syms->enterBlock(false);
CERR(TOKEN != TK_NAME, E_FOR_NAME, VNIL);
Value name = lexer->info.name;
int slot = syms->localsTop();
advance();
consume(':'+TK_EQUAL);
patchOrEmitMove(slot+2, slot+2, expr(slot+2));
consume(':');
patchOrEmitMove(slot+3, slot+1, expr(slot+3));
int pos1 = emitHole();
int pos2 = HERE;
syms->set(name, slot);
syms->addLocalsTop(2);
insideBlock();
emitJump(HERE, LOOP, VAL_REG(slot), pos2);
emitJump(pos1, FOR, VAL_REG(slot), HERE);
syms->exitBlock(false);
}
示例10: consumer_loop
void consumer_loop(void *arg)
{
int rc = 0;
event_buffer_t *buffer = (event_buffer_t *)arg;
while (rc == 0 && exit_signal == 0)
{
rc = consume(buffer);
}
if (rc != 0)
printf("consumer problem\n");
}
示例11: dt
void dt()
{
//printf("\nEnter <dt>");
if(!strcmp(token,"ID"))
{
consume();
dt1();
}
else
error("Declaration syntax error. Expecting IDENTIFIER or TERMINATOR");
//printf("\nExit <dt>");
}
示例12: parse
boost::tuple<boost::tribool, InputIterator> parse(request& req,
InputIterator begin, InputIterator end)
{
while (begin != end)
{
boost::tribool result = consume(req, *begin++);
if (result || !result)
return boost::make_tuple(result, begin);
}
boost::tribool result = boost::indeterminate;
return boost::make_tuple(result, begin);
}
示例13: HexagonGOT
//===----------------------------------------------------------------------===//
// HexagonGOTPLT
//===----------------------------------------------------------------------===//
HexagonGOTPLT::HexagonGOTPLT(LDSection& pSection)
: HexagonGOT(pSection)
{
// Create GOT0 entries
reserve(HexagonGOTPLT0Num);
// Skip GOT0 entries
for (size_t i = 0; i < HexagonGOTPLT0Num; ++i) {
consume();
}
pSection.setAlign(8);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_frameworks_compile_mclinker,代码行数:15,代码来源:HexagonGOTPLT.cpp
示例14: forkSmokers
void forkSmokers()
{
printf("FORKING THREE SMOKERS!\n\n");
pid_t S1 = fork();
if (S1 == 0) {
//forked properly
printf("SMOKER S1:%d\n", getpid());
smoke();
fflush(stdout);
exit(0);
} else if (S1 < 0) {
perror("Failed to fork");
} else {
wait();
consume();
pid_t S2 = fork();
if (S2 == 0) {
printf("SMOKER S2:%d\n", getpid());
smoke();
fflush(stdout);
exit(0);
} else if (S2 < 0) {
perror("Failed to fork");
} else {
wait();
consume();
pid_t S3 = fork();
if (S3 == 0) {
printf("SMOKER S3:%d\n", getpid());
smoke();
fflush(stdout);
exit(0);
} else if (S3 < 0) {
perror("Failed to fork");
}
}
}
}
示例15: consume
// Fill a direct offer.
// @param offer the offer we are going to use.
// @param amount the amount to flow through the offer.
// @returns: tesSUCCESS if successful, or an error code otherwise.
TER
Taker::fill (Offer const& offer, Amounts const& amount)
{
consume (offer, amount);
// Pay the taker, then the owner
TER result = view ().accountSend (offer.account(), account(), amount.out);
if (result == tesSUCCESS)
result = view ().accountSend (account(), offer.account(), amount.in);
return result;
}