本文整理汇总了C++中Expect函数的典型用法代码示例。如果您正苦于以下问题:C++ Expect函数的具体用法?C++ Expect怎么用?C++ Expect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Expect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: vcc_NumVal
static void
vcc_NumVal(struct vcc *tl, double *d, int *frac)
{
double e = 0.1;
const char *p;
*frac = 0;
*d = 0.0;
Expect(tl, CNUM);
if (tl->err) {
*d = NAN;
return;
}
for (p = tl->t->b; p < tl->t->e; p++) {
*d *= 10;
*d += *p - '0';
}
vcc_NextToken(tl);
if (tl->t->tok != '.')
return;
*frac = 1;
vcc_NextToken(tl);
if (tl->t->tok != CNUM)
return;
for (p = tl->t->b; p < tl->t->e; p++) {
*d += (*p - '0') * e;
e *= 0.1;
}
vcc_NextToken(tl);
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:30,代码来源:vcc_expr.c
示例17: ParseConditionalExpression
/**
* conditional-expression:
* logical-OR-expression
* logical-OR-expression ? expression : conditional-expression
*/
static AstExpression ParseConditionalExpression(void)
{
AstExpression expr;
expr = ParseBinaryExpression(Prec[OP_OR]);
if (CurrentToken == TK_QUESTION)
{
AstExpression condExpr;
CREATE_AST_NODE(condExpr, Expression);
condExpr->op = OP_QUESTION;
condExpr->kids[0] = expr;
NEXT_TOKEN;
CREATE_AST_NODE(condExpr->kids[1], Expression);
condExpr->kids[1]->op = OP_COLON;
condExpr->kids[1]->kids[0] = ParseExpression();
Expect(TK_COLON);
condExpr->kids[1]->kids[1] = ParseConditionalExpression();
return condExpr;
}
return expr;
}
开发者ID:M-ike,项目名称:work,代码行数:32,代码来源:expr.c
示例18: IpAddress
IpAddressV6::IpAddressV6(const ByteArray& bytes) :
IpAddress(16, true)
{
Expect(bytes.getCapacity() == 16, Throw(InvalidParameter, "Invalid buffer size"));
m_bytes = bytes;
}
开发者ID:siliace,项目名称:Bull,代码行数:7,代码来源:IpAddressV6.cpp
示例19: Parse
Value Parse()
{
Value v = ParseFactor();
Gobble('LF');
Expect('EOF');
return v;
}
开发者ID:CheshireSwift,项目名称:lobster,代码行数:7,代码来源:lobsterreader.cpp
示例20: main
int main()
{
SomeStruct myThing;
myThing.expect()->to->be->equal();
Expect().to->be->equal();
}
开发者ID:CCJY,项目名称:coliru,代码行数:7,代码来源:main.cpp
注:本文中的Expect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论