当前位置: 首页>>代码示例>>C++>>正文


C++ Expect函数代码示例

本文整理汇总了C++中Expect函数的典型用法代码示例。如果您正苦于以下问题:C++ Expect函数的具体用法?C++ Expect怎么用?C++ Expect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Expect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: typeName

 void Parser::ParseTypeDecl()
 {
     if (MatchSkip(TYPE, -1))
     {
         do
         {
             sptr<SymType> buff;
             string typeName(currToken->lexeme);
             NextToken(); // Skip ident
             Expect(EQUAL, -1);
             if (MatchSkip(ARRAY, -1))
             {
                 Expect(OF, -1);
                 currSymTable->PushType(new SymTypeArray(typeName, currSymTable->GetType(currToken->lexeme)));
             }
             else if (MatchSkip(POINTER, -1))
             {
                 currSymTable->PushType(new SymTypePointer(typeName, currSymTable->GetType(currToken->lexeme)));
             }
             else if (MatchSkip(RECORD, -1))
             {
                 sptr<SymTable> fields(new SymTable(currSymTable));
                 ParseVarSymbols(fields, true);
                 currSymTable->PushType(new SymTypeRecord(typeName, fields));
             }
             else if (buff = currSymTable->GetType(currToken->lexeme))
             {
                 currSymTable->PushAliasType(typeName, buff);
             }
             else throw ParserException(GetPos() + "expected type");
             NextToken();
         } while (MatchSkip(SEMICOLON, -1));
     }
 }
开发者ID:Arkm4n,项目名称:Syntaxer,代码行数:34,代码来源:Parser.cpp

示例2: Expect

    void TcpClient::connect(const IpAddress& address, NetPort port, const Duration& timeout, const Duration& pause)
    {
        Expect(address.isValid(), Throw(InvalidParameter, "Invalid IpAddress"));
        Expect(port != NetPort_Any, Throw(InvalidParameter, "Invalid NetPort"));

        int ret;
        Clock clock;

        Socket::create(address.getProtocol());

        prv::SockAddrBuffer buffer(address, port);

        clock.start();

        do
        {
            ret = ::connect(getHandler(), buffer.getSockAddr(), buffer.getLength());

            if(ret != 0)
            {
                std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<long long>(pause.asMilliseconds())));
            }
        }while(ret != 0 && clock.getElapsedTime() < timeout);

        Expect(ret == 0, Throw(InternalError, "Failed to connect to the remote host"));
    }
开发者ID:siliace,项目名称:Bull,代码行数:26,代码来源:TcpClient.cpp

示例3: Parse4DWORDS

bool Parse4DWORDS(char** sIn, unsigned long* p1, unsigned long* p2, unsigned long* p3, unsigned long* p4)
{
    if (Expect(sIn, '('))
    {
        if (GetDWORD(sIn, p1))
        {
            if (Expect(sIn, ','))
            {
                if (GetDWORD(sIn, p2))
                {
                    if (Expect(sIn, ','))
                    {
                        if (GetDWORD(sIn, p3))
                        {
                            if (Expect(sIn, ','))
                            {
                                if (GetDWORD(sIn, p4))
                                {
                                    if (Expect(sIn, ')'))
                                    {
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    return false;
}
开发者ID:davidlee80,项目名称:amd-gpuperfstudio-dx12,代码行数:33,代码来源:parser.cpp

示例4: rule

//=========================================================
bool Parser::Function () {
    PrintRule rule("Function");
    if (Accept(TokenType::Function) == false) {
        return false;
    }
    Expect(TokenType::Identifier);
    Expect(TokenType::OpenParentheses);

    if (Parameter()) {
        while (Accept(TokenType::Comma)) {
            if (!Parameter()) {
                throw ParsingException("Expected parameter after comma in function sig");
            }
        }
    }

    Expect(TokenType::CloseParentheses);

    SpecifiedType();

    if (!Scope()) {
        throw ParsingException("Expected scope after function");
    }

    return rule.Accept();
}
开发者ID:heftyfunseeker,项目名称:cs375,代码行数:27,代码来源:User2.cpp

示例5: Expect

void Parser::ProcDecl() {
    wchar_t* name;
    Obj *obj;
    int adr;
    Expect(9);
    Ident(name);
    obj = tab->NewObj(name, proc, undef);
    obj->adr = gen->pc;
    if (coco_string_equal(name, L"Main")) gen->progStart = gen->pc;
    tab->OpenScope();
    Expect(10);
    Expect(11);
    Expect(12);
    gen->Emit(ENTER, 0);
    adr = gen->pc - 2;
    while (StartOf(1)) {
        if (la->kind == 28 || la->kind == 29) {
            VarDecl();
        } else {
            Stat();
        }
    }
    Expect(13);
    gen->Emit(LEAVE);
    gen->Emit(RET);
    gen->Patch(adr, tab->topScope->nextAdr);
    tab->CloseScope();
}
开发者ID:Newky,项目名称:3rdYear,代码行数:28,代码来源:Parser.cpp

示例6: TEST

TEST(SyncEngineTest, TestBatch)
{
	vector<SyncEngine::EmailStub> batch1, batch2;
	vector<UID> remote;

	for(int i = 10; i < 100; i += 10) {
		remote.push_back(i);
	}

	TestSyncEngine engine(remote);

	batch1.push_back(MakeStub(5, "id5"));
	batch1.push_back(MakeStub(15, "id15"));
	batch1.push_back(MakeStub(20, "id20"));

	engine.Diff(batch1, true);
	// Local:  5  N 15 20 ...
	// Remote: D 10  D 20 30
	Expect(engine, 1, 2);

	engine.Clear();

	batch2.push_back(MakeStub(40, "id45"));
	batch2.push_back(MakeStub(45, "id45"));
	batch2.push_back(MakeStub(50, "id50"));
	batch2.push_back(MakeStub(65, "id65"));

	engine.Diff(batch2, false);
	// Local:   N 40 45 50  N 65  N  N  N
	// Remote: 30 40  D 50 60  D 70 80 90
	Expect(engine, 5, 2);
}
开发者ID:Garfonso,项目名称:app-services,代码行数:32,代码来源:SyncEngineTest.cpp

示例7: Token

void Parser::Parse() {
	t = NULL;
	la = dummyToken = new Token();
	la->val = coco_string_create(L"Dummy Token");
	Get();
	Calc();
	Expect(0);
	Expect(0);
}
开发者ID:Divo,项目名称:twominutestomidnightIMPORT,代码行数:9,代码来源:Parser.cpp

示例8: ParsePJL

bool Disasm::ParsePJL() {
	if (!Expect("\033%-12345X") || !SkipTo(") HP-PCL XL;")) return false;
	// version";"minor";" ... \n
	int32 version, minor;
	if (ReadNumber(version) && Expect(";") && ReadNumber(minor) && Expect(";") && SkipTo("\n")) {
		printf("PCL XL %d ; %d\n", (int)version, (int)minor);
		return true;
	}
	return false;	
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:10,代码来源:disasm.cpp

示例9: Expect

 sptr<Node> Parser::ParseBlock(bool begin)
 {
     begin && Expect(BEGIN, -1);
     sptr<Node> list(new BlockNode(ParseStatement(), "Block node"));
     while (MatchSkip(SEMICOLON, -1))
     {
         list->PushChild(ParseStatement());
     }
     begin && Expect(END, -1);
     return list;
 }
开发者ID:Arkm4n,项目名称:Syntaxer,代码行数:11,代码来源:Parser.cpp

示例10: Expect

CForStatement::CForStatement(tokenItor &itor)
{
	Expect(For, *itor++);
	m_init = StatementPtr(new CAssignmentStatement(itor));			//초기식
	Expect(To, *itor++);
	m_condition = CExpression::Parse(itor);					//조건식
	Expect(Step, *itor++);
	m_increment = StatementPtr(new CAssignmentStatement(itor));			//증감문

	m_statement = StatementPtr(CStatement::Create(itor));
}
开发者ID:SilverJun,项目名称:SilverJunInterpreter,代码行数:11,代码来源:StatementImpl.cpp

示例11: root

 sptr<Node> Parser::ParseForLoop()
 {
     sptr<StmntNode> root(new StmntNode(currToken));
     NextToken();
     root->PushChild(ParseIdent());
     Expect(ASSIGN, -1);
     root->PushChild(ParseExp());
     root->PushChild(sptr<KeywordNode>(new KeywordNode(currToken)));
     Expect(TO, DOWNTO, -1);
     root->PushChild(ParseExp());
     Expect(DO, -1);
     root->PushChild(ParseStatement());
     return root;
 }
开发者ID:Arkm4n,项目名称:Syntaxer,代码行数:14,代码来源:Parser.cpp

示例12: ClearSmsMemory

// Private SMS methods
bool Modem::ClearSmsMemory(){
	if(debug) Serial.println("Clearing all sms records");
	serial->println("AT+CMGD=1,4"); // delete all SMS -- ik vertrouw die 4 niet.. is dit niet verwijder 1 tot en met 4.. wat nou als er vijf zijn..?

	if(!Expect("OK")) return false;
	return true;
}
开发者ID:Lordsauron,项目名称:CarDuino,代码行数:8,代码来源:Modem.cpp

示例13: vcc_regexp

const char *
vcc_regexp(struct vcc *tl)
{
	char buf[BUFSIZ], *p;
	vre_t *t;
	const char *error;
	int erroroffset;
	struct inifin *ifp;

	Expect(tl, CSTR);
	if (tl->err)
		return (NULL);
	t = VRE_compile(tl->t->dec, 0, &error, &erroroffset);
	if (t == NULL) {
		VSB_printf(tl->sb,
		    "Regexp compilation error:\n\n%s\n\n", error);
		vcc_ErrWhere(tl, tl->t);
		return (NULL);
	}
	VRE_free(&t);
	bprintf(buf, "VGC_re_%u", tl->unique++);
	p = TlAlloc(tl, strlen(buf) + 1);
	strcpy(p, buf);

	Fh(tl, 0, "static void *%s;\n", buf);
	ifp = New_IniFin(tl);
	VSB_printf(ifp->ini, "\tVRT_re_init(&%s, ",buf);
	EncToken(ifp->ini, tl->t);
	VSB_printf(ifp->ini, ");");
	VSB_printf(ifp->fin, "\t\tVRT_re_fini(%s);", buf);
	vcc_NextToken(tl);
	return (p);
}
开发者ID:slimhazard,项目名称:varnish-cache,代码行数:33,代码来源:vcc_utils.c

示例14: while

bool Modem::ReadSms(){
	if(debug) Serial.println("Set modem to text mode.");
	serial->println("AT+CMGF=1");
	if(!Expect("OK")) return false;

	if(debug) Serial.println("requesting all stored sms messages.");
	serial->println("AT+CMGL=\"ALL\"");

	String s = "";
	while(true){
		/* Hier moeten we dus loopen door de regels die we binnen krijgen totdat we een OK ontvangen.. dan hebben we alle messages... */

		if(serial->available() > 0) {
			char c = (char)serial->read();
			s = s + c;
			Serial.print(c);
		}

		// if(debug){
		// 	Serial.println(GetMessage());
		// }

		//if(Expect("OK")) break;
	}
	Serial.println(s);

	if(debug) Serial.println("All messages read.");

	//if(debug) Serial.println("All messages processed, clearing memory.");
	//ClearSmsMemory();
	return true;
}
开发者ID:Lordsauron,项目名称:CarDuino,代码行数:32,代码来源:Modem.cpp

示例15: InitDeclarations

void Parser::Taste() {
    wchar_t* name;
    InitDeclarations();
    Expect(27);
    Ident(name);
    tab->OpenScope();
    Expect(12);
    while (la->kind == 28 || la->kind == 29) {
        VarDecl();
    }
    while (la->kind == 9) {
        ProcDecl();
    }
    Expect(13);
    tab->CloseScope();
}
开发者ID:Newky,项目名称:3rdYear,代码行数:16,代码来源:Parser.cpp


注:本文中的Expect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。