You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

69 line
1.4 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #pragma once
  11. #include <string>
  12. #ifndef __FLEX_LEXER_H
  13. # define yyFlexLexer LolFxFlexLexer
  14. # include "FlexLexer.h"
  15. # undef yyFlexLexer
  16. #endif
  17. #include "generated/lolfx-parser.h"
  18. class LolFx;
  19. namespace lol
  20. {
  21. class LolFxScanner : public LolFxFlexLexer
  22. {
  23. public:
  24. LolFxScanner(char const *command);
  25. virtual ~LolFxScanner();
  26. virtual int LexerInput(char* buf, int max_size);
  27. virtual LolFxParser::token_type lex(LolFxParser::semantic_type* yylval,
  28. LolFxParser::location_type* yylloc);
  29. private:
  30. bool IsExpressionTrue(char const *buf);
  31. map<String, String> m_pp_defines;
  32. enum
  33. {
  34. BlockIsFalse,
  35. BlockIsForeverFalse,
  36. BlockIsTrue,
  37. };
  38. array<int> m_pp_stack;
  39. char const *m_input;
  40. };
  41. class LolFxCompiler
  42. {
  43. public:
  44. LolFxCompiler(class LolFx &lolfx);
  45. bool ParseString(char const *command);
  46. void Error(const class location& l, const std::string& m);
  47. void Error(const std::string& m);
  48. class LolFxScanner *m_lexer;
  49. class LolFx &m_lolfx;
  50. };
  51. } /* namespace lol */