本文整理汇总了C++中Scanner::Peek方法的典型用法代码示例。如果您正苦于以下问题:C++ Scanner::Peek方法的具体用法?C++ Scanner::Peek怎么用?C++ Scanner::Peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner::Peek方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: args
void args(Scanner & s)
{
if ((s.Peek().token_type == TOKENS::LABEL) || (s.Peek().token_type == TOKENS::NUMBER))
{
symbol(s);
x_5(s);
}
else{
oops("args", s, "LABEL or NUMBER");
}
}
示例2: x_5
void x_5(Scanner & s){
if (s.Peek().token_type == TOKENS::COMMA)
{
s.Match(TOKENS::COMMA);
args(s);
}
else if ((s.Peek().token_type == TOKENS::RIGHTPAREN)){
return;
}
else{
oops("x_5", s, "COMMA or RIGHTPAREN");
}
}
示例3: symbol
void symbol(Scanner & s)
{
if (s.Peek().token_type == TOKENS::LABEL)
{
s.Match(TOKENS::LABEL);
}
else if (s.Peek().token_type == TOKENS::NUMBER)
{
s.Match(TOKENS::NUMBER);
}
else
{
oops("symbol", s, "LABEL or NUMBER");
}
}
示例4: x_6
void x_6(Scanner & s){
if (s.Peek().token_type == TOKENS::AND)
{
s.Match((TOKENS::AND));
head(s);
}
else if (s.End() || s.Peek().token_type == TOKENS::SEPARATOR)
{
return;
}
else
{
oops("x_6", s, "AND or SEPARATOR");
}
}
示例5: x_4
void x_4(Scanner & s)
{
if (s.Peek().token_type == TOKENS::RIGHTPAREN)
{
s.Match(TOKENS::RIGHTPAREN);
Token temp_t;
s.SetValidIndex();
}
else if ((s.Peek().token_type == TOKENS::LABEL) || (s.Peek().token_type == TOKENS::NUMBER))
{
args(s);
s.Match(TOKENS::RIGHTPAREN);
s.SetValidIndex();
}
else
{
oops("x_4", s, "RIGHTPAREN, LABEL, or NUMBER");
}
}
示例6: name
void name(Scanner & s)
{
if (s.Peek().token_type == TOKENS::LABEL)
{
s.Match(TOKENS::LABEL);
}
else
{
oops("name", s, "LABEL");
}
}
示例7: x_1
void x_1(Scanner & s)
{
if (s.Peek().token_type == TOKENS::SEPARATOR)
{
s.Match(TOKENS::SEPARATOR);
body(s);
}
else
{
oops("x_1", s, "SEPARATOR");
}
}
示例8: hornclause
void hornclause(Scanner & s)
{
if (s.Peek().token_type == TOKENS::LABEL)
{
head(s);
x_1(s);
}
else
{
oops("hornclause", s, "LABEL");
}
}
示例9: oops
/*
The opps function is used to error out from the recursion ( for LL(1) parser) and prints out useful
erro message
*/
void oops(std::string s, Scanner & scanner, std::string expect)
{
cout << endl;
cout << "<-----Error Message----->" << std::endl;
cout << "From: " << s << " " << scanner.Peek().token_name << " is coming in. Delinquent token is: " << scanner.Peek().token_value << endl;
cout << "We expected " << expect << std::endl;
cout << "Production up until error: ";
scanner.PrintError();
cout << "<-----End Error Message----->" << std::endl;
cout << endl;
throw TOKEN_MISMATCH;
}
示例10: predicate
void predicate(Scanner & s)
{
if (s.Peek().token_type == TOKENS::LABEL)
{
name(s);
x_3(s);
}
else
{
oops("predicate", s, "LABEL");
}
}
示例11: body
void body(Scanner & s)
{
if (s.Peek().token_type == TOKENS::LABEL)
{
predicate(s);
x_2(s);
}
else
{
oops("body", s, "LABEL");
}
}
示例12: head
void head(Scanner & s)
{
if (s.Peek().token_type == TOKENS::LABEL)
{
predicate(s);
x_6(s);
}
else
{
oops("head", s, "LABEL");
}
}
示例13: x_3
void x_3(Scanner & s)
{
if (s.Peek().token_type == TOKENS::LEFTPAREN)
{
s.Match(TOKENS::LEFTPAREN);
x_4(s);
}
else
{
oops("x_3", s, "LEFTPAREN");
}
}
示例14: x_2
void x_2(Scanner & s)
{
if (s.Peek().token_type == TOKENS::AND)
{
s.Match((TOKENS::AND));
body(s);
}
else if (s.End() )
{
return;
}
else
{
oops("x_2", s, "AND");
}
}