本文整理汇总了C++中Lexer::ambiguity方法的典型用法代码示例。如果您正苦于以下问题:C++ Lexer::ambiguity方法的具体用法?C++ Lexer::ambiguity怎么用?C++ Lexer::ambiguity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer::ambiguity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compileExpression
void Eval::compileExpression (const std::string& e)
{
// Reduce e to a vector of tokens.
Lexer l (e);
l.ambiguity (_ambiguity);
std::string token;
Lexer::Type type;
while (l.token (token, type))
{
if (_debug)
context.debug ("Lexer '" + token + "' " + Lexer::type_name (type));
_compiled.push_back (std::pair <std::string, Lexer::Type> (token, type));
}
// Parse for syntax checking and operator replacement.
if (_debug)
context.debug ("[1;37;42mFILTER[0m Infix " + dump (_compiled));
infixParse (_compiled);
if (_debug)
context.debug ("[1;37;42mFILTER[0m Infix parsed " + dump (_compiled));
// Convert infix --> postfix.
infixToPostfix (_compiled);
if (_debug)
context.debug ("[1;37;42mFILTER[0m Postfix " + dump (_compiled));
}
示例2: evaluateInfixExpression
void Eval::evaluateInfixExpression (const std::string& e, Variant& v) const
{
// Reduce e to a vector of tokens.
Lexer l (e);
l.ambiguity (_ambiguity);
std::vector <std::pair <std::string, Lexer::Type> > tokens;
std::string token;
Lexer::Type type;
while (l.token (token, type))
tokens.push_back (std::pair <std::string, Lexer::Type> (token, type));
// Parse for syntax checking and operator replacement.
if (_debug)
context.debug ("[1;37;42mFILTER[0m Infix " + dump (tokens));
infixParse (tokens);
if (_debug)
context.debug ("[1;37;42mFILTER[0m Infix parsed " + dump (tokens));
// Convert infix --> postfix.
infixToPostfix (tokens);
if (_debug)
context.debug ("[1;37;42mFILTER[0m Postfix " + dump (tokens));
// Call the postfix evaluator.
evaluatePostfixStack (tokens, v);
}
示例3: evaluatePostfixExpression
void Eval::evaluatePostfixExpression (const std::string& e, Variant& v) const
{
// Reduce e to a vector of tokens.
Lexer l (e);
l.ambiguity (_ambiguity);
std::vector <std::pair <std::string, Lexer::Type> > tokens;
std::string token;
Lexer::Type type;
while (l.token (token, type))
tokens.push_back (std::pair <std::string, Lexer::Type> (token, type));
if (_debug)
context.debug ("[1;37;42mFILTER[0m Postfix " + dump (tokens));
// Call the postfix evaluator.
evaluatePostfixStack (tokens, v);
}