summaryrefslogtreecommitdiff
path: root/indra/llmath/llcalcparser.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2011-07-13 15:02:23 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2011-07-13 15:02:23 -0400
commitee0e23e77f10a5171899059ff157e8dab29ebd70 (patch)
treeb7fc84c515f7c03d31f48bc9d23d808400853cd4 /indra/llmath/llcalcparser.cpp
parentf0c7413e46aef65b995c1c48910526be6f27b35d (diff)
parentdd3069127bb437e95d106734e8a0ab95307e297c (diff)
merge
Diffstat (limited to 'indra/llmath/llcalcparser.cpp')
-rw-r--r--indra/llmath/llcalcparser.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/indra/llmath/llcalcparser.cpp b/indra/llmath/llcalcparser.cpp
new file mode 100644
index 0000000000..fd55376fa9
--- /dev/null
+++ b/indra/llmath/llcalcparser.cpp
@@ -0,0 +1,46 @@
+/*
+ * LLCalcParser.cpp
+ * SecondLife
+ *
+ * Created by Aimee Walton on 28/09/2008.
+ * Copyright 2008 Aimee Walton.
+ *
+ */
+
+#include "linden_common.h"
+
+#include "llcalcparser.h"
+using namespace boost::spirit::classic;
+
+F32 LLCalcParser::lookup(const std::string::iterator& start, const std::string::iterator& end) const
+{
+ LLCalc::calc_map_t::iterator iter;
+
+ std::string name(start, end);
+
+ if (mConstants)
+ {
+ iter = mConstants->find(name);
+ if (iter != mConstants->end())
+ {
+ return (*iter).second;
+ }
+ }
+ else
+ {
+ // This should never happen!
+ throw_(end, std::string("Missing constants table"));
+ }
+
+ if (mVariables)
+ {
+ iter = mVariables->find(name);
+ if (iter != mVariables->end())
+ {
+ return (*iter).second;
+ }
+ }
+
+ throw_(end, std::string("Unknown symbol " + name));
+ return 0.f;
+}