sql_1.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the mingw-w64 runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  5. */
  6. #ifndef _SQL_1_H_
  7. #define _SQL_1_H_
  8. struct SQL_LEVEL_1_TOKEN {
  9. enum { OP_EXPRESSION = 1,TOKEN_AND,TOKEN_OR,TOKEN_NOT };
  10. enum { IFUNC_NONE = 0,IFUNC_UPPER = 1,IFUNC_LOWER = 2 };
  11. int nTokenType;
  12. enum { OP_EQUAL = 1,OP_NOT_EQUAL,OP_EQUALorGREATERTHAN,OP_EQUALorLESSTHAN,OP_LESSTHAN,OP_GREATERTHAN,OP_LIKE };
  13. BSTR pPropertyName;
  14. int nOperator;
  15. WINBOOL bConstIsStrNumeric;
  16. VARIANT vConstValue;
  17. BSTR pPropName2;
  18. DWORD dwPropertyFunction;
  19. DWORD dwConstFunction;
  20. SQL_LEVEL_1_TOKEN();
  21. SQL_LEVEL_1_TOKEN(SQL_LEVEL_1_TOKEN&);
  22. ~SQL_LEVEL_1_TOKEN();
  23. SQL_LEVEL_1_TOKEN& operator=(SQL_LEVEL_1_TOKEN &Src);
  24. void Dump(FILE *);
  25. };
  26. struct SQL_LEVEL_1_RPN_EXPRESSION {
  27. int nNumTokens;
  28. int nCurSize;
  29. SQL_LEVEL_1_TOKEN *pArrayOfTokens;
  30. BSTR bsClassName;
  31. int nNumberOfProperties;
  32. int nCurPropSize;
  33. BSTR *pbsRequestedPropertyNames;
  34. SQL_LEVEL_1_RPN_EXPRESSION();
  35. ~SQL_LEVEL_1_RPN_EXPRESSION();
  36. void AddToken(SQL_LEVEL_1_TOKEN *pTok);
  37. void AddToken(SQL_LEVEL_1_TOKEN &pTok);
  38. void AddProperty(LPWSTR pProp);
  39. void Dump(const char *pszTextFile);
  40. };
  41. class SQL1_Parser {
  42. CGenLexer *m_pLexer;
  43. int m_nLine;
  44. wchar_t *m_pTokenText;
  45. int m_nCurrentToken;
  46. SQL_LEVEL_1_RPN_EXPRESSION *m_pExpression;
  47. void Cleanup();
  48. void Init(CGenLexSource *pSrc);
  49. VARIANT m_vTypedConst;
  50. int m_nRelOp;
  51. DWORD m_dwConstFunction;
  52. DWORD m_dwPropFunction;
  53. LPWSTR m_pIdent;
  54. LPWSTR m_pPropComp;
  55. WINBOOL m_bConstIsStrNumeric;
  56. WINBOOL Next();
  57. int parse();
  58. int prop_list();
  59. int class_name();
  60. int opt_where();
  61. int expr();
  62. int property_name();
  63. int prop_list_2();
  64. int term();
  65. int expr2();
  66. int simple_expr();
  67. int term2();
  68. int leading_ident_expr();
  69. int finalize();
  70. int rel_operator();
  71. int equiv_operator();
  72. int comp_operator();
  73. int is_operator();
  74. int trailing_prop_expr();
  75. int trailing_prop_expr2();
  76. int trailing_or_null();
  77. int trailing_const_expr();
  78. int unknown_func_expr();
  79. int typed_constant();
  80. public:
  81. enum {
  82. SUCCESS,SYNTAX_ERROR,LEXICAL_ERROR,FAILED,BUFFER_TOO_SMALL
  83. };
  84. SQL1_Parser(CGenLexSource *pSrc);
  85. ~SQL1_Parser();
  86. int GetQueryClass(LPWSTR pBuf,int nBufSize);
  87. int Parse(SQL_LEVEL_1_RPN_EXPRESSION **pOutput);
  88. int CurrentLine() { return m_nLine; }
  89. LPWSTR CurrentToken() { return m_pTokenText; }
  90. void SetSource(CGenLexSource *pSrc);
  91. };
  92. #endif