* Copyright 2006-2014 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <superstippi@gmx.de>
* Rene Gollent <rene@gollent.com>
* John Scipione <jscipione@gmail.com>
* Ingo Weinhold <bonefish@cs.tu-berlin.de>
*/
#ifndef C_LANGUAGE_EXPRESSION_EVALUATOR_H
#define C_LANGUAGE_EXPRESSION_EVALUATOR_H
#include <String.h>
namespace CLanguage {
struct Token;
class Tokenizer;
}
class BVariant;
class TeamTypeInformation;
class Type;
class ValueNode;
class ValueNodeChild;
class ValueNodeManager;
class Variable;
class ValueNeededException {
public:
ValueNeededException(ValueNode* node)
:
value(node)
{
}
ValueNode* value;
};
class ExpressionResult;
class Number;
class CLanguageExpressionEvaluator {
public:
CLanguageExpressionEvaluator();
~CLanguageExpressionEvaluator();
ExpressionResult* Evaluate(const char* expressionString,
ValueNodeManager* manager,
TeamTypeInformation* info);
private:
class InternalVariableID;
class Operand;
private:
Operand _ParseSum();
Operand _ParseProduct();
Operand _ParseUnary();
Operand _ParseIdentifier(ValueNode* parentNode = NULL);
Operand _ParseAtom();
void _EatToken(int32 type);
Operand _ParseType(Type* baseType);
void _RequestValueIfNeeded(
const CLanguage::Token& token,
ValueNodeChild* child);
void _GetNodeChildForPrimitive(
const CLanguage::Token& token,
const BVariant& value,
ValueNodeChild*& _output) const;
private:
CLanguage::Tokenizer* fTokenizer;
TeamTypeInformation* fTypeInfo;
ValueNodeManager* fNodeManager;
};
#endif