本文整理汇总了C++中Toker::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Toker::set方法的具体用法?C++ Toker::set怎么用?C++ Toker::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toker
的用法示例。
在下文中一共展示了Toker::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dealSemiExpressions
int dealSemiExpressions()
{
Toker tok;
std::string fileSpec1 = "../Tokenizer/test_tokenizer.txt";
std::fstream inn(fileSpec1);
if (!inn.good())
{
std::cout << "\n can't open file " << fileSpec1 << "\n\n";
return 1;
}
tok.attach(&inn);
tok.setComments(false);
tok.set("<,>,[,],(,),{,},:,=,+,-,*,\n", "<,<,>,>,:,:,+,+,-,-,=,=,+,=,-,=,*,=,/,=,-,>");
SemiExp semi(&tok);
semi.get();
while (semi.get())
{
std::cout << "\n -- semiExpression --";
std::string str = semi.show();
std::cout << str;
}
if (semi.length() > 0)
{
std::cout << "\n -- semiExpression --";
semi.show();
std::cout << "\n\n";
}
return 0;
}
示例2: dealTokenizer
int dealTokenizer(Toker& toker)
{
std::cout << "Input for Tokenizer" << std::endl;
std::string fileSpec = "../Tokenizer/test_tokenizer.txt";
std::ifstream file("../Tokenizer/test_tokenizer.txt");
std::string str;
while (std::getline(file, str))
{
std::cout << str << std::endl;
}
std::cout << "-----------------------------------------------------------------------------------------\n";
std::ifstream in(fileSpec);
if (!in.good())
{
std::cout << "\n can't open " << fileSpec << "\n\n";
return 1;
}
toker.attach(&in);
toker.setComments(true);
toker.set("<,>,[,],(,),{,},:,=,+,-,*,\n", "<,<,>,>,:,:,+,+,-,-,=,=,+,=,-,=,*,=,/,=,-,>");
std::cout << "OUPUT \n";
do
{
std::string tok = toker.getTok();
if (tok == "\n")
{
tok = "newline";
}
std::cout << "\n -- " << tok;
} while (in.good());
std::cout << "\n";
return 0;
}