/indra/llmath/llcalcparser.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 63 lines · 30 code · 7 blank · 26 comment · 6 complexity · aa5cfbb077bdfe44667301d33a523839 MD5 · raw file

  1. /*
  2. * LLCalcParser.cpp
  3. * Copyright 2008 Aimee Walton.
  4. * $LicenseInfo:firstyear=2008&license=viewerlgpl$
  5. * Second Life Viewer Source Code
  6. * Copyright (C) 2008, Linden Research, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation;
  11. * version 2.1 of the License only.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  23. * $/LicenseInfo$
  24. *
  25. */
  26. #include "linden_common.h"
  27. #include "llcalcparser.h"
  28. using namespace boost::spirit::classic;
  29. F32 LLCalcParser::lookup(const std::string::iterator& start, const std::string::iterator& end) const
  30. {
  31. LLCalc::calc_map_t::iterator iter;
  32. std::string name(start, end);
  33. if (mConstants)
  34. {
  35. iter = mConstants->find(name);
  36. if (iter != mConstants->end())
  37. {
  38. return (*iter).second;
  39. }
  40. }
  41. else
  42. {
  43. // This should never happen!
  44. throw_(end, std::string("Missing constants table"));
  45. }
  46. if (mVariables)
  47. {
  48. iter = mVariables->find(name);
  49. if (iter != mVariables->end())
  50. {
  51. return (*iter).second;
  52. }
  53. }
  54. throw_(end, std::string("Unknown symbol " + name));
  55. return 0.f;
  56. }