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