Leaked source code of windows server 2003
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.

2381 lines
82 KiB

  1. #ifndef lint
  2. static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
  3. #endif
  4. #define YYBYACC 1
  5. #define YYMAJOR 1
  6. #define YYMINOR 9
  7. #define yyclearin (yychar=(-1))
  8. #define yyerrok (yyerrflag=0)
  9. #define YYRECOVERING (yyerrflag!=0)
  10. #include <pch.cxx>
  11. #pragma hdrstop
  12. #define yyparse tripparse
  13. #define yylex triplex
  14. #define yyerror triperror
  15. #define yychar tripchar
  16. #define yyval tripval
  17. #define yylval triplval
  18. #define yydebug tripdebug
  19. #define yynerrs tripnerrs
  20. #define yyerrflag triperrflag
  21. #define yyss tripss
  22. #define yyssp tripssp
  23. #define yyvs tripvs
  24. #define yyvsp tripvsp
  25. #define yylhs triplhs
  26. #define yylen triplen
  27. #define yydefred tripdefred
  28. #define yydgoto tripdgoto
  29. #define yysindex tripsindex
  30. #define yyrindex triprindex
  31. #define yygindex tripgindex
  32. #define yytable triptable
  33. #define yycheck tripcheck
  34. #define yyname tripname
  35. #define yyrule triprule
  36. #define YYPREFIX "trip"
  37. class CValueParser;
  38. #if 0
  39. typedef union
  40. {
  41. WCHAR * pwszChar;
  42. DBCOMMANDOP dbop;
  43. CDbRestriction * pRest;
  44. CStorageVariant * pStorageVar;
  45. CValueParser *pPropValueParser;
  46. int iInt;
  47. int iEmpty;
  48. } YYSTYPE;
  49. #endif
  50. #define YYDEBUG CIDBG
  51. #include <malloc.h>
  52. #include "yybase.hxx"
  53. #include "parser.h" // defines yystype
  54. #include "parsepl.h"
  55. #include "flexcpp.h"
  56. #if CIDBG == 1
  57. #define AssertReq(x) Assert(x != NULL)
  58. #else
  59. #define AssertReq(x)
  60. #endif
  61. const GUID guidSystem = PSGUID_STORAGE;
  62. static CDbColId psContents( guidSystem, PID_STG_CONTENTS );
  63. //+---------------------------------------------------------------------------
  64. //
  65. // Function: TreeFromText, public
  66. //
  67. // Synopsis: Create a CDbRestriction from a restriction string
  68. //
  69. // Arguments: [wcsRestriction] -- restriction
  70. // [ColumnMapper] -- property list
  71. // [lcid] -- locale id of the query
  72. //
  73. // History: 01-Oct-97 emilyb created
  74. // 26-Aug-98 KLam No longer need to lower case
  75. //
  76. //----------------------------------------------------------------------------
  77. CDbContentRestriction * TreeFromText(
  78. WCHAR const * wcsRestriction,
  79. IColumnMapper & ColumnMapper,
  80. LCID lcid )
  81. {
  82. unsigned cwc = 1 + wcslen( wcsRestriction );
  83. XGrowable<WCHAR> xRestriction( cwc );
  84. WCHAR * pwc = xRestriction.Get();
  85. RtlCopyMemory( pwc, wcsRestriction, cwc * sizeof WCHAR );
  86. cwc--;
  87. // The parser can't deal with trailing space so strip it off
  88. while ( cwc > 0 && L' ' == pwc[cwc-1] )
  89. cwc--;
  90. pwc[cwc] = 0;
  91. TripLexer Lexer;
  92. XPtr<YYPARSER> xParser( new TripParser( ColumnMapper, lcid, Lexer ) );
  93. xParser->yyprimebuffer( pwc );
  94. #if 0 // YYDEBUG == 1
  95. // Set this to 1 if you want command line output. to 0 otherwise.
  96. xParser->SetDebug();
  97. #endif
  98. // Actually parse the text producing a tree
  99. SCODE hr = xParser->Parse();
  100. if (FAILED(hr))
  101. THROW( CException( hr ) );
  102. // return the DBCOMMANDTREE
  103. return (CDbContentRestriction *)( xParser->GetParseTree() );
  104. } //TextFromTree
  105. void StripQuotes(WCHAR *wcsPhrase)
  106. {
  107. ULONG cChars = wcslen(wcsPhrase);
  108. LPWSTR pLast = wcsPhrase + cChars - 1;
  109. if (L'"' == *wcsPhrase && L'"' == *pLast)
  110. {
  111. *pLast = L'\0';
  112. MoveMemory(wcsPhrase, wcsPhrase+1, sizeof(WCHAR) * (cChars-1) );
  113. }
  114. }
  115. //+---------------------------------------------------------------------------
  116. //
  117. // Member: CValueParser::CValueParser, public
  118. //
  119. // Synopsis: Allocs CStorageVariant of correct type
  120. //
  121. // History: 01-Oct-97 emilyb created
  122. // 02-Sep-98 KLam Added locale
  123. //
  124. //----------------------------------------------------------------------------
  125. CValueParser::CValueParser(
  126. BOOL fVectorElement,
  127. DBTYPE PropType,
  128. LCID locale ) :
  129. _pStgVariant( 0 ),
  130. _fVector(fVectorElement),
  131. _PropType (PropType),
  132. _cElements ( 0 ),
  133. _locale ( locale )
  134. {
  135. if ( _fVector )
  136. {
  137. // this is a vector
  138. if ( DBTYPE_VECTOR != ( _PropType & DBTYPE_VECTOR ) )
  139. THROW( CParserException( QPARSE_E_EXPECTING_PHRASE ) );
  140. VARENUM ve = (VARENUM ) _PropType;
  141. if ( _PropType == ( DBTYPE_VECTOR | DBTYPE_WSTR ) )
  142. ve = (VARENUM) (VT_VECTOR | VT_LPWSTR);
  143. else if ( _PropType == ( DBTYPE_VECTOR | DBTYPE_STR ) )
  144. ve = (VARENUM) (VT_VECTOR | VT_LPSTR);
  145. _pStgVariant.Set( new CStorageVariant( ve, _cElements ) );
  146. }
  147. else
  148. {
  149. _pStgVariant.Set( new CStorageVariant() );
  150. }
  151. if ( _pStgVariant.IsNull() )
  152. THROW( CException( E_OUTOFMEMORY ) );
  153. }
  154. //+---------------------------------------------------------------------------
  155. //
  156. // Member: CValueParser::AddValue, public
  157. //
  158. // Synopsis: Adds value to CStorageVariant
  159. //
  160. // Arguments: [pwszValue] -- value
  161. //
  162. // History: 01-Oct-97 emilyb code moved here from CPropertyValueParser
  163. //
  164. //----------------------------------------------------------------------------
  165. void CValueParser::AddValue(WCHAR const * pwszValue)
  166. {
  167. if ( _pStgVariant.IsNull() )
  168. THROW( CException( E_OUTOFMEMORY ) );
  169. switch ( _PropType & ~DBTYPE_VECTOR )
  170. {
  171. case DBTYPE_WSTR :
  172. case DBTYPE_WSTR | DBTYPE_BYREF :
  173. {
  174. if ( _PropType & DBTYPE_VECTOR )
  175. _pStgVariant->SetLPWSTR( pwszValue, _cElements );
  176. else
  177. _pStgVariant->SetLPWSTR( pwszValue );
  178. break;
  179. }
  180. case DBTYPE_BSTR :
  181. {
  182. BSTR bstr = SysAllocString( pwszValue );
  183. if ( 0 == bstr )
  184. THROW( CException( E_OUTOFMEMORY ) );
  185. if ( _PropType & DBTYPE_VECTOR )
  186. _pStgVariant->SetBSTR( bstr, _cElements );
  187. else
  188. _pStgVariant->SetBSTR( bstr );
  189. SysFreeString( bstr );
  190. break;
  191. }
  192. case DBTYPE_STR :
  193. case DBTYPE_STR | DBTYPE_BYREF :
  194. {
  195. // make sure there's enough room to translate
  196. unsigned cbBuffer = 1 + 3 * wcslen( pwszValue );
  197. XArray<char> xBuf( cbBuffer );
  198. int cc = WideCharToMultiByte( CP_ACP,
  199. 0,
  200. pwszValue,
  201. -1,
  202. xBuf.Get(),
  203. cbBuffer,
  204. NULL,
  205. NULL );
  206. if ( 0 == cc )
  207. {
  208. #if CIDBG
  209. ULONG ul = GetLastError();
  210. #endif
  211. THROW( CParserException( QPARSE_E_EXPECTING_PHRASE ) );
  212. }
  213. if ( _PropType & DBTYPE_VECTOR )
  214. _pStgVariant->SetLPSTR( xBuf.Get(), _cElements );
  215. else
  216. _pStgVariant->SetLPSTR( xBuf.Get() );
  217. break;
  218. }
  219. case DBTYPE_I1 :
  220. {
  221. CQueryScanner scan( pwszValue, FALSE, _locale );
  222. LONG l = 0;
  223. BOOL fAtEndOfString;
  224. if ( ! ( scan.GetNumber( l, fAtEndOfString ) &&
  225. fAtEndOfString ) )
  226. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  227. if ( ( l > SCHAR_MAX ) ||
  228. ( l < SCHAR_MIN ) )
  229. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  230. if ( _PropType & DBTYPE_VECTOR )
  231. _pStgVariant->SetI1( (CHAR) l, _cElements );
  232. else
  233. _pStgVariant->SetI1( (CHAR) l );
  234. break;
  235. }
  236. case DBTYPE_UI1 :
  237. {
  238. CQueryScanner scan( pwszValue, FALSE, _locale );
  239. ULONG ul = 0;
  240. BOOL fAtEndOfString;
  241. if ( ! ( scan.GetNumber( ul, fAtEndOfString ) &&
  242. fAtEndOfString ) )
  243. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  244. if ( ul > UCHAR_MAX )
  245. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  246. if ( _PropType & DBTYPE_VECTOR )
  247. _pStgVariant->SetUI1( (BYTE) ul, _cElements );
  248. else
  249. _pStgVariant->SetUI1( (BYTE) ul );
  250. break;
  251. }
  252. case DBTYPE_I2 :
  253. {
  254. CQueryScanner scan( pwszValue, FALSE, _locale );
  255. LONG l = 0;
  256. BOOL fAtEndOfString;
  257. if ( ! ( scan.GetNumber( l, fAtEndOfString ) &&
  258. fAtEndOfString ) )
  259. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  260. if ( ( l > SHRT_MAX ) ||
  261. ( l < SHRT_MIN ) )
  262. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  263. if ( _PropType & DBTYPE_VECTOR )
  264. _pStgVariant->SetI2( (short) l, _cElements );
  265. else
  266. _pStgVariant->SetI2( (short) l );
  267. break;
  268. }
  269. case DBTYPE_UI2 :
  270. {
  271. CQueryScanner scan( pwszValue, FALSE, _locale );
  272. ULONG ul = 0;
  273. BOOL fAtEndOfString;
  274. if ( ! ( scan.GetNumber( ul, fAtEndOfString ) &&
  275. fAtEndOfString ) )
  276. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  277. if ( ul > USHRT_MAX )
  278. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  279. if ( _PropType & DBTYPE_VECTOR )
  280. _pStgVariant->SetUI2( (USHORT) ul, _cElements );
  281. else
  282. _pStgVariant->SetUI2( (USHORT) ul );
  283. break;
  284. }
  285. case DBTYPE_I4 :
  286. {
  287. CQueryScanner scan( pwszValue, FALSE, _locale );
  288. LONG l = 0;
  289. BOOL fAtEndOfString;
  290. if ( ! ( scan.GetNumber( l, fAtEndOfString ) &&
  291. fAtEndOfString ) )
  292. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  293. if ( _PropType & DBTYPE_VECTOR )
  294. _pStgVariant->SetI4( l, _cElements );
  295. else
  296. _pStgVariant->SetI4( l );
  297. break;
  298. }
  299. case DBTYPE_UI4 :
  300. {
  301. CQueryScanner scan( pwszValue, FALSE, _locale );
  302. ULONG ul = 0;
  303. BOOL fAtEndOfString;
  304. if ( ! ( scan.GetNumber( ul, fAtEndOfString ) &&
  305. fAtEndOfString ) )
  306. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  307. if ( _PropType & DBTYPE_VECTOR )
  308. _pStgVariant->SetUI4( ul, _cElements );
  309. else
  310. _pStgVariant->SetUI4( ul );
  311. break;
  312. }
  313. case DBTYPE_ERROR :
  314. {
  315. // SCODE/HRESULT are typedefed as long (signed)
  316. CQueryScanner scan( pwszValue, FALSE, _locale );
  317. SCODE sc = 0;
  318. BOOL fAtEndOfString;
  319. if ( ! ( scan.GetNumber( sc, fAtEndOfString ) &&
  320. fAtEndOfString ) )
  321. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  322. if ( _PropType & DBTYPE_VECTOR )
  323. _pStgVariant->SetERROR( sc, _cElements );
  324. else
  325. _pStgVariant->SetERROR( sc );
  326. break;
  327. }
  328. case DBTYPE_I8 :
  329. {
  330. CQueryScanner scan( pwszValue, FALSE, _locale );
  331. _int64 ll = 0;
  332. BOOL fAtEndOfString;
  333. if ( ! ( scan.GetNumber( ll, fAtEndOfString ) &&
  334. fAtEndOfString ) )
  335. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  336. LARGE_INTEGER LargeInt;
  337. LargeInt.QuadPart = ll;
  338. if ( _PropType & DBTYPE_VECTOR )
  339. _pStgVariant->SetI8( LargeInt , _cElements );
  340. else
  341. _pStgVariant->SetI8( LargeInt );
  342. break;
  343. }
  344. case DBTYPE_UI8 :
  345. {
  346. CQueryScanner scan( pwszValue, FALSE, _locale );
  347. unsigned _int64 ull = 0;
  348. BOOL fAtEndOfString;
  349. if ( ! ( scan.GetNumber( ull, fAtEndOfString ) &&
  350. fAtEndOfString ) )
  351. THROW( CParserException( QPARSE_E_EXPECTING_INTEGER ) );
  352. ULARGE_INTEGER LargeInt;
  353. LargeInt.QuadPart = ull;
  354. if ( _PropType & DBTYPE_VECTOR )
  355. _pStgVariant->SetUI8( LargeInt , _cElements );
  356. else
  357. _pStgVariant->SetUI8( LargeInt );
  358. break;
  359. }
  360. case DBTYPE_BOOL :
  361. {
  362. if ( pwszValue[0] == 'T' ||
  363. pwszValue[0] == 't' )
  364. if ( _PropType & DBTYPE_VECTOR )
  365. _pStgVariant->SetBOOL( VARIANT_TRUE, _cElements );
  366. else
  367. _pStgVariant->SetBOOL( VARIANT_TRUE );
  368. else
  369. if ( _PropType & DBTYPE_VECTOR )
  370. _pStgVariant->SetBOOL( VARIANT_FALSE, _cElements );
  371. else
  372. _pStgVariant->SetBOOL( VARIANT_FALSE );
  373. break;
  374. }
  375. case DBTYPE_R4 :
  376. {
  377. WCHAR *pwcEnd = 0;
  378. float Float = (float)( wcstod( pwszValue, &pwcEnd ) );
  379. if ( *pwcEnd != 0 && !iswspace( *pwcEnd ) )
  380. THROW( CParserException( QPARSE_E_EXPECTING_REAL ) );
  381. if ( _PropType & DBTYPE_VECTOR )
  382. _pStgVariant->SetR4( Float, _cElements );
  383. else
  384. _pStgVariant->SetR4( Float );
  385. break;
  386. }
  387. case DBTYPE_R8 :
  388. {
  389. WCHAR *pwcEnd = 0;
  390. double Double = ( double )( wcstod( pwszValue, &pwcEnd ) );
  391. if ( *pwcEnd != 0 && !iswspace( *pwcEnd ) )
  392. THROW( CParserException( QPARSE_E_EXPECTING_REAL ) );
  393. if ( _PropType & DBTYPE_VECTOR )
  394. _pStgVariant->SetR8( Double, _cElements );
  395. else
  396. _pStgVariant->SetR8( Double );
  397. break;
  398. }
  399. case DBTYPE_DECIMAL :
  400. {
  401. WCHAR *pwcEnd = 0;
  402. double Double = ( double )( wcstod( pwszValue, &pwcEnd ) );
  403. if( *pwcEnd != 0 && !iswspace( *pwcEnd ) )
  404. THROW( CParserException( QPARSE_E_EXPECTING_REAL ) );
  405. // Vectors are not supported by OLE for VT_DECIMAL (yet)
  406. Win4Assert( 0 == ( _PropType & DBTYPE_VECTOR ) );
  407. PROPVARIANT * pPropVar = (PROPVARIANT *) _pStgVariant.GetPointer();
  408. VarDecFromR8( Double, &(pPropVar->decVal) );
  409. pPropVar->vt = VT_DECIMAL;
  410. break;
  411. }
  412. case DBTYPE_DATE :
  413. {
  414. FILETIME ftValue;
  415. ParseDateTime( pwszValue, ftValue );
  416. SYSTEMTIME stValue;
  417. BOOL fOK = FileTimeToSystemTime( &ftValue, &stValue );
  418. if ( !fOK )
  419. THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
  420. DATE dosDate;
  421. fOK = SystemTimeToVariantTime( &stValue, &dosDate );
  422. if ( !fOK )
  423. THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
  424. if ( _PropType & DBTYPE_VECTOR )
  425. _pStgVariant->SetDATE( dosDate, _cElements );
  426. else
  427. _pStgVariant->SetDATE( dosDate );
  428. break;
  429. }
  430. case VT_FILETIME :
  431. {
  432. FILETIME ftValue;
  433. ParseDateTime( pwszValue, ftValue );
  434. if ( _PropType & DBTYPE_VECTOR )
  435. _pStgVariant->SetFILETIME( ftValue, _cElements );
  436. else
  437. _pStgVariant->SetFILETIME( ftValue );
  438. break;
  439. }
  440. case DBTYPE_CY :
  441. {
  442. double dbl;
  443. if ( swscanf( pwszValue,
  444. L"%lf",
  445. &dbl ) < 1 )
  446. THROW( CParserException( QPARSE_E_EXPECTING_CURRENCY ) );
  447. CY cyCurrency;
  448. VarCyFromR8( dbl, &cyCurrency );
  449. if ( _PropType & DBTYPE_VECTOR )
  450. _pStgVariant->SetCY( cyCurrency, _cElements );
  451. else
  452. _pStgVariant->SetCY( cyCurrency );
  453. break;
  454. }
  455. case DBTYPE_GUID :
  456. case DBTYPE_GUID | DBTYPE_BYREF:
  457. {
  458. CLSID clsid;
  459. if ( swscanf( pwszValue,
  460. L"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
  461. &clsid.Data1,
  462. &clsid.Data2,
  463. &clsid.Data3,
  464. &clsid.Data4[0], &clsid.Data4[1],
  465. &clsid.Data4[2], &clsid.Data4[3],
  466. &clsid.Data4[4], &clsid.Data4[5],
  467. &clsid.Data4[6], &clsid.Data4[7] ) < 11 )
  468. THROW( CParserException( QPARSE_E_EXPECTING_GUID ) );
  469. if ( _PropType & DBTYPE_VECTOR )
  470. _pStgVariant->SetCLSID( clsid, _cElements );
  471. else
  472. _pStgVariant->SetCLSID( &clsid );
  473. break;
  474. }
  475. default:
  476. {
  477. THROW( CParserException( QPARSE_E_UNSUPPORTED_PROPERTY_TYPE ) );
  478. }
  479. } // switch
  480. // make sure memory allocations succeeded
  481. if ( !_pStgVariant->IsValid() )
  482. THROW( CException( E_OUTOFMEMORY ) );
  483. if ( _fVector )
  484. {
  485. _cElements++;
  486. }
  487. }
  488. //+---------------------------------------------------------------------------
  489. //
  490. // Member: CValueParser::ParseDateTime, private
  491. //
  492. // Synopsis: Attempts to parse a date expression.
  493. //
  494. // Arguments: phrase -- pointer to the phrase to parse
  495. // ft -- reference to the FILETIME structure to fill in
  496. // with the result
  497. //
  498. // History: 31-May-96 dlee Created
  499. // 23-Jan-97 KyleP Better Year 2000 support
  500. // 02-Sep-98 KLam Use user settings for Y2K support
  501. //
  502. //----------------------------------------------------------------------------
  503. void CValueParser::ParseDateTime(
  504. WCHAR const * phrase,
  505. FILETIME & ft )
  506. {
  507. if( !CheckForRelativeDate( phrase, ft ) )
  508. {
  509. SYSTEMTIME stValue = { 0, 0, 0, 0, 0, 0, 0, 0 };
  510. int cItems = swscanf( phrase,
  511. L"%4hd/%2hd/%2hd %2hd:%2hd:%2hd:%3hd",
  512. &stValue.wYear,
  513. &stValue.wMonth,
  514. &stValue.wDay,
  515. &stValue.wHour,
  516. &stValue.wMinute,
  517. &stValue.wSecond,
  518. &stValue.wMilliseconds );
  519. if ( 1 == cItems )
  520. cItems = swscanf( phrase,
  521. L"%4hd-%2hd-%2hd %2hd:%2hd:%2hd:%3hd",
  522. &stValue.wYear,
  523. &stValue.wMonth,
  524. &stValue.wDay,
  525. &stValue.wHour,
  526. &stValue.wMinute,
  527. &stValue.wSecond,
  528. &stValue.wMilliseconds );
  529. if( cItems != 3 && cItems != 6 && cItems != 7)
  530. THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
  531. //
  532. // Make a sensible split for Year 2000 using the user's system settings
  533. //
  534. if ( stValue.wYear < 100 )
  535. {
  536. DWORD dwYearHigh = 0;
  537. if ( 0 == GetCalendarInfo ( _locale,
  538. CAL_GREGORIAN,
  539. CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
  540. 0,
  541. 0,
  542. &dwYearHigh ) )
  543. {
  544. THROW ( CException () );
  545. }
  546. if ( ( dwYearHigh < 99 ) || ( dwYearHigh > 9999 ) )
  547. dwYearHigh = 2029;
  548. WORD wMaxDecade = (WORD) dwYearHigh % 100;
  549. WORD wMaxCentury = (WORD) dwYearHigh - wMaxDecade;
  550. if ( stValue.wYear <= wMaxDecade )
  551. stValue.wYear += wMaxCentury;
  552. else
  553. stValue.wYear += ( wMaxCentury - 100 );
  554. }
  555. if( !SystemTimeToFileTime( &stValue, &ft ) )
  556. THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
  557. }
  558. } //ParseDateTime
  559. //+---------------------------------------------------------------------------
  560. //
  561. // Member: CValueParser::CheckForRelativeDate, private
  562. //
  563. // Synopsis: Attempts to parse a relative date expression. If successful,
  564. // it fills in the FILETIME structure with the calculated
  565. // absolute date.
  566. //
  567. // Notes: Returns TRUE if the phrase is recognized as a relative
  568. // date (i.e., it begins with a '-'). Otherwise, returns FALSE.
  569. // The format of a relative date is
  570. // "-"{INTEGER("h"|"n"|"s"|"y"|"q"|"m"|"d"|"w")}*
  571. // Case is not significant.
  572. //
  573. // Arguments: phrase -- pointer to the phrase to parse
  574. // ft -- reference to the FILETIME structure to fill in
  575. // with the result
  576. //
  577. // History: 26-May-94 t-jeffc Created
  578. // 02-Mar-95 t-colinb Moved from CQueryParser to
  579. // be more accessible
  580. // 22-Jan-97 KyleP Fix local/UTC discrepancy
  581. //
  582. //----------------------------------------------------------------------------
  583. BOOL CValueParser::CheckForRelativeDate(
  584. WCHAR const * phrase,
  585. FILETIME & ft )
  586. {
  587. if( *phrase++ == L'-' )
  588. {
  589. SYSTEMTIME st;
  590. LARGE_INTEGER liLocal;
  591. LONGLONG llTicksInADay = ((LONGLONG)10000000) * ((LONGLONG)3600)
  592. * ((LONGLONG) 24);
  593. LONGLONG llTicksInAHour = ((LONGLONG) 10000000) * ((LONGLONG)3600);
  594. int iMonthDays[12] = {1,-1,1,0,1,0,1,1,0,1,0,1};
  595. int iLoopValue, iPrevMonth, iPrevQuarter, iQuarterOffset;
  596. WORD wYear, wDayOfMonth, wStartDate;
  597. //
  598. //Obtain local time and convert it to file time
  599. //Copy the filetime to largeint data struct
  600. //
  601. GetSystemTime(&st);
  602. if(!SystemTimeToFileTime(&st, &ft))
  603. THROW( CParserException( QPARSE_E_INVALID_LITERAL ));
  604. liLocal.LowPart = ft.dwLowDateTime;
  605. liLocal.HighPart = ft.dwHighDateTime;
  606. LONGLONG llRelDate = (LONGLONG)0;
  607. for( ;; )
  608. {
  609. // eat white space
  610. while( iswspace( *phrase ) )
  611. phrase++;
  612. if( *phrase == 0 ) break;
  613. // parse the number
  614. WCHAR * pwcEnd;
  615. LONG lValue = wcstol( phrase, &pwcEnd, 10 );
  616. if( lValue < 0 )
  617. THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
  618. // eat white space
  619. phrase = pwcEnd;
  620. while( iswspace( *phrase ) )
  621. phrase++;
  622. // grab the unit char & subtract the appropriate amount
  623. WCHAR wcUnit = *phrase++;
  624. switch( wcUnit )
  625. {
  626. case L'y':
  627. case L'Y':
  628. lValue *= 4;
  629. // Fall through and handle year like 4 quarters
  630. case L'q':
  631. case L'Q':
  632. lValue *= 3;
  633. // Fall through and handle quarters like 3 months
  634. case L'm':
  635. case L'M':
  636. // Getting the System time to determine the day and month.
  637. if(!FileTimeToSystemTime(&ft, &st))
  638. {
  639. THROW(CParserException(QPARSE_E_INVALID_LITERAL));
  640. }
  641. wStartDate = st.wDay;
  642. wDayOfMonth = st.wDay;
  643. iLoopValue = lValue;
  644. while(iLoopValue)
  645. {
  646. // Subtracting to the end of previous month
  647. llRelDate = llTicksInADay * ((LONGLONG)(wDayOfMonth));
  648. liLocal.QuadPart -= llRelDate;
  649. ft.dwLowDateTime = liLocal.LowPart;
  650. ft.dwHighDateTime = liLocal.HighPart;
  651. SYSTEMTIME stTemp;
  652. if(!FileTimeToSystemTime(&ft, &stTemp))
  653. {
  654. THROW(CParserException(QPARSE_E_INVALID_LITERAL));
  655. }
  656. //
  657. // if the end of previous month is greated then start date then we subtract to back up to the
  658. // start date. This will take care of 28/29 Feb(backing from 30/31 by 1 month).
  659. //
  660. if(stTemp.wDay > wStartDate)
  661. {
  662. llRelDate = llTicksInADay * ((LONGLONG)(stTemp.wDay - wStartDate));
  663. liLocal.QuadPart -= llRelDate;
  664. ft.dwLowDateTime = liLocal.LowPart;
  665. ft.dwHighDateTime = liLocal.HighPart;
  666. // Getting the date into stTemp for further iteration
  667. if(!FileTimeToSystemTime(&ft, &stTemp))
  668. {
  669. THROW( CParserException( QPARSE_E_INVALID_LITERAL ));
  670. }
  671. }
  672. wDayOfMonth = stTemp.wDay;
  673. iLoopValue--;
  674. } //End While
  675. break;
  676. case L'w':
  677. case L'W':
  678. lValue *= 7;
  679. case L'd':
  680. case L'D':
  681. llRelDate = llTicksInADay * ((LONGLONG)lValue);
  682. liLocal.QuadPart -= llRelDate;
  683. ft.dwLowDateTime = liLocal.LowPart;
  684. ft.dwHighDateTime = liLocal.HighPart;
  685. break;
  686. case L'h':
  687. case L'H':
  688. llRelDate = llTicksInAHour * ((LONGLONG)lValue);
  689. liLocal.QuadPart -= llRelDate;
  690. ft.dwLowDateTime = liLocal.LowPart;
  691. ft.dwHighDateTime = liLocal.HighPart;
  692. break;
  693. case L'n':
  694. case L'N':
  695. llRelDate = ((LONGLONG)10000000) * ((LONGLONG)60) * ((LONGLONG)lValue) ;
  696. liLocal.QuadPart -= llRelDate;
  697. ft.dwLowDateTime = liLocal.LowPart;
  698. ft.dwHighDateTime = liLocal.HighPart;
  699. break;
  700. case L's':
  701. case L'S':
  702. llRelDate = ((LONGLONG)10000000) * ((LONGLONG)lValue);
  703. liLocal.QuadPart -= llRelDate;
  704. ft.dwLowDateTime = liLocal.LowPart;
  705. ft.dwHighDateTime = liLocal.HighPart;
  706. break;
  707. default:
  708. THROW( CParserException( QPARSE_E_EXPECTING_DATE ) );
  709. }
  710. } // for( ;; )
  711. return TRUE;
  712. }
  713. else
  714. {
  715. return FALSE;
  716. }
  717. }
  718. #define _OR 257
  719. #define _AND 258
  720. #define _NEAR 259
  721. #define _NEARDIST 260
  722. #define _NOT 261
  723. #define _CONTAINS 262
  724. #define _LT 263
  725. #define _GT 264
  726. #define _LTE 265
  727. #define _GTE 266
  728. #define _EQ 267
  729. #define _NE 268
  730. #define _ALLOF 269
  731. #define _SOMEOF 270
  732. #define _OPEN 271
  733. #define _CLOSE 272
  734. #define _VECTOR_END 273
  735. #define _VE 274
  736. #define _VE_END 275
  737. #define _PROPEND 276
  738. #define _NEAR_END 277
  739. #define _LTSOME 278
  740. #define _GTSOME 279
  741. #define _LTESOME 280
  742. #define _GTESOME 281
  743. #define _EQSOME 282
  744. #define _NESOME 283
  745. #define _ALLOFSOME 284
  746. #define _SOMEOFSOME 285
  747. #define _LTALL 286
  748. #define _GTALL 287
  749. #define _LTEALL 288
  750. #define _GTEALL 289
  751. #define _EQALL 290
  752. #define _NEALL 291
  753. #define _ALLOFALL 292
  754. #define _SOMEOFALL 293
  755. #define _COERCE 294
  756. #define _SHGENPREFIX 295
  757. #define _SHGENINFLECT 296
  758. #define _GENPREFIX 297
  759. #define _GENINFLECT 298
  760. #define _GENNORMAL 299
  761. #define _PHRASE 300
  762. #define _PROPNAME 301
  763. #define _NEARUNIT 302
  764. #define _WEIGHT 303
  765. #define _REGEX 304
  766. #define _FREETEXT 305
  767. #define _VECTORELEMENT 306
  768. #define _VEMETHOD 307
  769. #define _PHRASEORREGEX 308
  770. #define YYERRCODE 256
  771. short triplhs[] = { -1,
  772. 0, 0, 0, 21, 21, 21, 21, 20, 20, 20,
  773. 19, 19, 19, 12, 12, 12, 13, 13, 18, 18,
  774. 18, 22, 23, 23, 10, 11, 16, 16, 16, 16,
  775. 16, 16, 17, 17, 8, 8, 14, 14, 6, 6,
  776. 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
  777. 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
  778. 6, 6, 7, 7, 1, 1, 1, 2, 2, 2,
  779. 4, 3, 3, 5, 5, 9, 9, 15, 15, 15,
  780. };
  781. short triplen[] = { 2,
  782. 1, 3, 2, 1, 2, 3, 4, 1, 3, 5,
  783. 3, 5, 5, 0, 1, 1, 0, 1, 1, 1,
  784. 3, 2, 3, 3, 1, 1, 1, 5, 4, 6,
  785. 3, 5, 4, 4, 0, 1, 0, 1, 1, 1,
  786. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  787. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  788. 1, 1, 0, 1, 1, 1, 1, 1, 1, 2,
  789. 2, 3, 3, 2, 2, 0, 1, 0, 1, 1,
  790. };
  791. short tripdefred[] = { 0,
  792. 0, 15, 16, 0, 0, 8, 0, 0, 36, 3,
  793. 0, 5, 0, 25, 0, 0, 0, 0, 0, 20,
  794. 27, 0, 19, 0, 0, 0, 0, 43, 41, 44,
  795. 42, 0, 40, 45, 46, 51, 49, 52, 50, 47,
  796. 48, 53, 54, 59, 57, 60, 58, 55, 56, 61,
  797. 62, 0, 0, 0, 0, 0, 0, 0, 77, 0,
  798. 0, 18, 11, 22, 0, 9, 0, 0, 6, 0,
  799. 65, 66, 0, 0, 67, 69, 68, 0, 0, 0,
  800. 0, 0, 0, 0, 0, 0, 26, 21, 0, 0,
  801. 7, 71, 0, 0, 74, 38, 34, 70, 75, 33,
  802. 12, 13, 79, 80, 29, 0, 0, 0, 10, 72,
  803. 73, 28, 32, 0, 30,
  804. };
  805. short tripdgoto[] = { 4,
  806. 74, 75, 76, 77, 78, 52, 53, 18, 60, 19,
  807. 88, 5, 63, 97, 106, 20, 21, 22, 6, 7,
  808. 8, 23, 24,
  809. };
  810. short tripsindex[] = { -234,
  811. -256, 0, 0, -243, 218, 0, -241, -249, 0, 0,
  812. 312, 0, -148, 0, -275, -275, -258, 281, -234, 0,
  813. 0, -279, 0, -248, -275, -274, -102, 0, 0, 0,
  814. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  815. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  816. 0, -15, -265, -253, -249, -54, -54, -234, 0, -43,
  817. -242, 0, 0, 0, -234, 0, -225, -275, 0, -100,
  818. 0, 0, -247, -172, 0, 0, 0, -251, -172, -279,
  819. -279, -243, -170, -263, -243, 215, 0, 0, -243, -275,
  820. 0, 0, -167, -163, 0, 0, 0, 0, 0, 0,
  821. 0, 0, 0, 0, 0, -172, -172, -279, 0, 0,
  822. 0, 0, 0, -172, 0,
  823. };
  824. short triprindex[] = { -147,
  825. -101, 0, 0, 0, 125, 0, 38, 10, 0, 0,
  826. -177, 0, -147, 0, -193, -193, 0, -254, -147, 0,
  827. 0, 66, 0, 0, -193, 0, -147, 0, 0, 0,
  828. 0, -269, 0, 0, 0, 0, 0, 0, 0, 0,
  829. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  830. 0, 0, 0, 213, 29, 80, 80, -147, 0, -55,
  831. 0, 0, 0, 0, -147, 0, 0, -193, 0, 0,
  832. 0, 0, 0, 6, 0, 0, 0, 0, 6, 66,
  833. 66, -194, 6, 1, 34, 170, 0, 0, -192, -193,
  834. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  835. 0, 0, 0, 0, 0, 6, 6, 58, 0, 0,
  836. 0, 0, 0, 6, 0,
  837. };
  838. short tripgindex[] = { 2,
  839. 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
  840. 0, -4, 22, 428, 44, 0, 7, 27, -25, -14,
  841. 116, 0, 0,
  842. };
  843. #define YYTABLESIZE 605
  844. short triptable[] = { 66,
  845. 78, 39, 10, 11, 1, 37, 76, 12, 27, 1,
  846. 56, 57, 69, 13, 13, 58, 76, 25, 26, 62,
  847. 61, 2, 3, 98, 64, 65, 1, 67, 2, 87,
  848. 39, 103, 104, 31, 64, 39, 39, 4, 79, 76,
  849. 2, 3, 76, 76, 9, 76, 76, 9, 76, 63,
  850. 76, 90, 76, 91, 99, 86, 11, 17, 95, 82,
  851. 12, 85, 2, 3, 109, 17, 89, 14, 14, 14,
  852. 14, 14, 14, 14, 14, 14, 14, 14, 23, 23,
  853. 24, 24, 80, 81, 14, 14, 14, 14, 14, 14,
  854. 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
  855. 14, 101, 102, 96, 110, 96, 14, 14, 111, 14,
  856. 14, 14, 54, 14, 14, 14, 14, 14, 14, 14,
  857. 14, 14, 14, 14, 103, 104, 63, 107, 55, 114,
  858. 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
  859. 14, 14, 14, 14, 14, 14, 14, 0, 2, 3,
  860. 0, 0, 14, 14, 0, 14, 14, 14, 68, 14,
  861. 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
  862. 0, 92, 0, 0, 0, 0, 14, 14, 14, 14,
  863. 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
  864. 14, 14, 14, 0, 2, 3, 0, 0, 14, 93,
  865. 0, 14, 14, 14, 94, 14, 14, 14, 14, 14,
  866. 14, 14, 14, 14, 14, 14, 14, 1, 0, 0,
  867. 0, 0, 14, 14, 14, 14, 14, 14, 14, 14,
  868. 14, 14, 14, 14, 14, 14, 14, 14, 14, 0,
  869. 0, 0, 0, 0, 0, 14, 9, 14, 14, 0,
  870. 0, 14, 17, 2, 3, 70, 83, 78, 78, 78,
  871. 78, 84, 37, 37, 37, 37, 1, 0, 1, 1,
  872. 0, 0, 78, 78, 78, 0, 78, 37, 37, 37,
  873. 0, 1, 1, 1, 71, 2, 0, 2, 2, 72,
  874. 73, 31, 31, 31, 4, 4, 0, 0, 0, 78,
  875. 2, 2, 2, 0, 37, 31, 31, 31, 1, 4,
  876. 4, 4, 0, 0, 17, 17, 17, 17, 0, 0,
  877. 0, 0, 17, 17, 17, 17, 0, 2, 0, 17,
  878. 17, 17, 31, 17, 0, 0, 4, 17, 17, 17,
  879. 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
  880. 0, 0, 0, 0, 0, 0, 0, 35, 35, 35,
  881. 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
  882. 35, 35, 35, 35, 0, 0, 35, 35, 0, 35,
  883. 0, 0, 35, 35, 35, 35, 35, 35, 35, 35,
  884. 35, 35, 35, 35, 35, 0, 0, 0, 0, 0,
  885. 0, 0, 35, 35, 35, 35, 35, 35, 35, 35,
  886. 35, 35, 35, 35, 35, 35, 35, 35, 0, 0,
  887. 0, 35, 35, 0, 35, 0, 0, 0, 35, 35,
  888. 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
  889. 0, 0, 0, 0, 0, 0, 0, 35, 35, 35,
  890. 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
  891. 35, 35, 35, 0, 0, 0, 35, 35, 0, 0,
  892. 0, 0, 0, 35, 35, 35, 35, 35, 35, 35,
  893. 35, 35, 35, 0, 0, 14, 0, 0, 14, 0,
  894. 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
  895. 35, 35, 35, 35, 35, 35, 100, 0, 15, 0,
  896. 105, 15, 0, 0, 108, 9, 35, 16, 9, 0,
  897. 16, 17, 0, 0, 17, 0, 0, 0, 0, 0,
  898. 0, 0, 0, 112, 113, 0, 0, 0, 0, 0,
  899. 0, 115, 59, 28, 29, 30, 31, 32, 33, 34,
  900. 35, 0, 0, 0, 0, 0, 0, 0, 36, 37,
  901. 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
  902. 48, 49, 50, 51, 28, 29, 30, 31, 32, 33,
  903. 34, 35, 0, 0, 0, 0, 0, 0, 0, 36,
  904. 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
  905. 47, 48, 49, 50, 51,
  906. };
  907. short tripcheck[] = { 25,
  908. 0, 271, 1, 1, 261, 0, 261, 1, 258, 0,
  909. 15, 16, 27, 257, 257, 274, 271, 259, 260, 299,
  910. 19, 297, 298, 275, 273, 274, 261, 302, 0, 272,
  911. 300, 295, 296, 0, 304, 305, 306, 0, 304, 294,
  912. 297, 298, 297, 298, 301, 300, 301, 301, 303, 304,
  913. 305, 277, 307, 68, 306, 60, 54, 0, 306, 58,
  914. 54, 60, 297, 298, 90, 0, 65, 261, 262, 263,
  915. 264, 265, 266, 267, 268, 269, 270, 271, 273, 274,
  916. 273, 274, 56, 57, 278, 279, 280, 281, 282, 283,
  917. 284, 285, 286, 287, 288, 289, 290, 291, 292, 293,
  918. 294, 80, 81, 276, 272, 276, 300, 301, 272, 303,
  919. 304, 305, 261, 307, 262, 263, 264, 265, 266, 267,
  920. 268, 269, 270, 271, 295, 296, 304, 84, 13, 108,
  921. 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
  922. 288, 289, 290, 291, 292, 293, 294, -1, 297, 298,
  923. -1, -1, 300, 301, -1, 303, 304, 305, 261, 307,
  924. 262, 263, 264, 265, 266, 267, 268, 269, 270, 271,
  925. -1, 272, -1, -1, -1, -1, 278, 279, 280, 281,
  926. 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
  927. 292, 293, 294, -1, 297, 298, -1, -1, 300, 300,
  928. -1, 303, 304, 305, 305, 307, 262, 263, 264, 265,
  929. 266, 267, 268, 269, 270, 271, 271, 261, -1, -1,
  930. -1, -1, 278, 279, 280, 281, 282, 283, 284, 285,
  931. 286, 287, 288, 289, 290, 291, 292, 293, 294, -1,
  932. -1, -1, -1, -1, -1, 301, 301, 303, 304, -1,
  933. -1, 307, 307, 297, 298, 271, 300, 257, 258, 259,
  934. 260, 305, 257, 258, 259, 260, 257, -1, 259, 260,
  935. -1, -1, 272, 273, 274, -1, 276, 272, 273, 274,
  936. -1, 272, 273, 274, 300, 257, -1, 259, 260, 305,
  937. 306, 258, 259, 260, 257, 258, -1, -1, -1, 299,
  938. 272, 273, 274, -1, 299, 272, 273, 274, 299, 272,
  939. 273, 274, -1, -1, 257, 258, 259, 260, -1, -1,
  940. -1, -1, 257, 258, 259, 260, -1, 299, -1, 272,
  941. 273, 274, 299, 276, -1, -1, 299, 272, 273, 274,
  942. 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
  943. -1, -1, -1, -1, -1, -1, -1, 278, 279, 280,
  944. 281, 282, 283, 284, 285, 286, 287, 288, 289, 290,
  945. 291, 292, 293, 294, -1, -1, 297, 298, -1, 300,
  946. -1, -1, 303, 304, 305, 261, 262, 263, 264, 265,
  947. 266, 267, 268, 269, 270, -1, -1, -1, -1, -1,
  948. -1, -1, 278, 279, 280, 281, 282, 283, 284, 285,
  949. 286, 287, 288, 289, 290, 291, 292, 293, -1, -1,
  950. -1, 297, 298, -1, 300, -1, -1, -1, 304, 305,
  951. 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
  952. -1, -1, -1, -1, -1, -1, -1, 278, 279, 280,
  953. 281, 282, 283, 284, 285, 286, 287, 288, 289, 290,
  954. 291, 292, 293, -1, -1, -1, 297, 298, -1, -1,
  955. -1, -1, -1, 304, 305, 263, 264, 265, 266, 267,
  956. 268, 269, 270, -1, -1, 271, -1, -1, 271, -1,
  957. 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
  958. 288, 289, 290, 291, 292, 293, 79, -1, 294, -1,
  959. 83, 294, -1, -1, 300, 301, 304, 303, 301, -1,
  960. 303, 307, -1, -1, 307, -1, -1, -1, -1, -1,
  961. -1, -1, -1, 106, 107, -1, -1, -1, -1, -1,
  962. -1, 114, 262, 263, 264, 265, 266, 267, 268, 269,
  963. 270, -1, -1, -1, -1, -1, -1, -1, 278, 279,
  964. 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
  965. 290, 291, 292, 293, 263, 264, 265, 266, 267, 268,
  966. 269, 270, -1, -1, -1, -1, -1, -1, -1, 278,
  967. 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
  968. 289, 290, 291, 292, 293,
  969. };
  970. #define YYFINAL 4
  971. #ifndef YYDEBUG
  972. #define YYDEBUG 0
  973. #endif
  974. #define YYMAXTOKEN 308
  975. #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
  976. char *tripname[] = {
  977. "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  978. 0,0,0,0,0,0,"'('","')'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  979. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  980. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  981. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  982. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  983. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"_OR","_AND","_NEAR",
  984. "_NEARDIST","_NOT","_CONTAINS","_LT","_GT","_LTE","_GTE","_EQ","_NE","_ALLOF",
  985. "_SOMEOF","_OPEN","_CLOSE","_VECTOR_END","_VE","_VE_END","_PROPEND","_NEAR_END",
  986. "_LTSOME","_GTSOME","_LTESOME","_GTESOME","_EQSOME","_NESOME","_ALLOFSOME",
  987. "_SOMEOFSOME","_LTALL","_GTALL","_LTEALL","_GTEALL","_EQALL","_NEALL",
  988. "_ALLOFALL","_SOMEOFALL","_COERCE","_SHGENPREFIX","_SHGENINFLECT","_GENPREFIX",
  989. "_GENINFLECT","_GENNORMAL","_PHRASE","_PROPNAME","_NEARUNIT","_WEIGHT","_REGEX",
  990. "_FREETEXT","_VECTORELEMENT","_VEMETHOD","_PHRASEORREGEX",
  991. };
  992. char *triprule[] = {
  993. "$accept : query",
  994. "query : AndTerm",
  995. "query : query _OR AndTerm",
  996. "query : _NOT query",
  997. "AndTerm : NearTerm",
  998. "AndTerm : _NOT PropTerm",
  999. "AndTerm : AndTerm _AND NearTerm",
  1000. "AndTerm : AndTerm _AND _NOT NearTerm",
  1001. "NearTerm : CoerceTerm",
  1002. "NearTerm : NearTerm _NEAR CoerceTerm",
  1003. "NearTerm : NearTerm _NEARDIST _NEARUNIT _NEAR_END CoerceTerm",
  1004. "CoerceTerm : Gen NestTerm GenEnd",
  1005. "CoerceTerm : Gen _COERCE Gen NestTerm GenEnd",
  1006. "CoerceTerm : Gen _WEIGHT Gen NestTerm GenEnd",
  1007. "Gen :",
  1008. "Gen : _GENPREFIX",
  1009. "Gen : _GENINFLECT",
  1010. "GenEnd :",
  1011. "GenEnd : _GENNORMAL",
  1012. "NestTerm : VectorTerm",
  1013. "NestTerm : Term",
  1014. "NestTerm : Open query Close",
  1015. "VectorTerm : VectorSpec _VECTOR_END",
  1016. "VectorSpec : _VEMETHOD _VE query",
  1017. "VectorSpec : VectorSpec _VE query",
  1018. "Open : _OPEN",
  1019. "Close : _CLOSE",
  1020. "Term : PropTerm",
  1021. "Term : Property Contains _PHRASE ShortGen PropEnd",
  1022. "Term : Property Contains _PHRASE PropEnd",
  1023. "Term : Property Contains Gen _PHRASE GenEnd PropEnd",
  1024. "Term : Property Contains query",
  1025. "Term : Property Contains _FREETEXT ShortGen PropEnd",
  1026. "PropTerm : Property Matches _REGEX PropEnd",
  1027. "PropTerm : Property Op Value PropEnd",
  1028. "Property :",
  1029. "Property : _PROPNAME",
  1030. "PropEnd :",
  1031. "PropEnd : _PROPEND",
  1032. "Op : _EQ",
  1033. "Op : _NE",
  1034. "Op : _GT",
  1035. "Op : _GTE",
  1036. "Op : _LT",
  1037. "Op : _LTE",
  1038. "Op : _ALLOF",
  1039. "Op : _SOMEOF",
  1040. "Op : _EQSOME",
  1041. "Op : _NESOME",
  1042. "Op : _GTSOME",
  1043. "Op : _GTESOME",
  1044. "Op : _LTSOME",
  1045. "Op : _LTESOME",
  1046. "Op : _ALLOFSOME",
  1047. "Op : _SOMEOFSOME",
  1048. "Op : _EQALL",
  1049. "Op : _NEALL",
  1050. "Op : _GTALL",
  1051. "Op : _GTEALL",
  1052. "Op : _LTALL",
  1053. "Op : _LTEALL",
  1054. "Op : _ALLOFALL",
  1055. "Op : _SOMEOFALL",
  1056. "Matches :",
  1057. "Matches : _EQ",
  1058. "Value : _PHRASE",
  1059. "Value : _FREETEXT",
  1060. "Value : VectorValue",
  1061. "VectorValue : EmptyVector",
  1062. "VectorValue : SingletVector",
  1063. "VectorValue : MultiVector _VE_END",
  1064. "EmptyVector : _OPEN _CLOSE",
  1065. "SingletVector : _OPEN _PHRASE _CLOSE",
  1066. "SingletVector : _OPEN _FREETEXT _CLOSE",
  1067. "MultiVector : _VECTORELEMENT _VECTORELEMENT",
  1068. "MultiVector : MultiVector _VECTORELEMENT",
  1069. "Contains :",
  1070. "Contains : _CONTAINS",
  1071. "ShortGen :",
  1072. "ShortGen : _SHGENPREFIX",
  1073. "ShortGen : _SHGENINFLECT",
  1074. };
  1075. #endif
  1076. YYPARSER::YYPARSER(IColumnMapper & ColumnMapper, LCID & locale, YYLEXER & yylex)
  1077. : CTripYYBase( ColumnMapper, locale, yylex ) {
  1078. xyyvs.SetSize(INITSTACKSIZE);
  1079. yydebug = 0;
  1080. }
  1081. #define YYABORT(sc) { return ResultFromScode(sc); }
  1082. #define YYFATAL E_FAIL
  1083. #define YYSUCCESS S_OK
  1084. #define YYREJECT goto yyabort
  1085. #define YYACCEPT goto yyaccept
  1086. int YYPARSER::Parse()
  1087. {
  1088. register int yym, yyn, yystate;
  1089. #if YYDEBUG
  1090. register char *yys;
  1091. if (yys = getenv("YYDEBUG"))
  1092. {
  1093. yyn = *yys;
  1094. if (yyn >= '0' && yyn <= '9')
  1095. yydebug = yyn - '0';
  1096. }
  1097. #endif
  1098. yynerrs = 0;
  1099. yyerrflag = 0;
  1100. yychar = (-1);
  1101. yyssp = xyyss.Get();
  1102. yyvsp = xyyvs.Get();
  1103. *yyssp = yystate = 0;
  1104. yyloop:
  1105. if (yyn = yydefred[yystate]) goto yyreduce;
  1106. if (yychar < 0)
  1107. {
  1108. try
  1109. {
  1110. if ( (yychar = YYLEX(&YYAPI_VALUENAME)) < 0 )
  1111. yychar = 0;
  1112. }
  1113. catch (HRESULT hr)
  1114. {
  1115. switch(hr)
  1116. {
  1117. case E_OUTOFMEMORY:
  1118. YYABORT(E_OUTOFMEMORY);
  1119. break;
  1120. default:
  1121. YYABORT(E_FAIL);
  1122. break;
  1123. }
  1124. }
  1125. #if YYDEBUG
  1126. if (yydebug)
  1127. {
  1128. yys = 0;
  1129. if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  1130. if (!yys) yys = "illegal-symbol";
  1131. printf("%sdebug: state %d, reading %d (%s)\n",
  1132. YYPREFIX, yystate, yychar, yys);
  1133. }
  1134. #endif
  1135. }
  1136. if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
  1137. yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  1138. {
  1139. #if YYDEBUG
  1140. if (yydebug)
  1141. printf("%sdebug: state %d, shifting to state %d\n",
  1142. YYPREFIX, yystate, yytable[yyn]);
  1143. #endif
  1144. if ( yyssp >= xyyss.Get() + xyyss.Count() - 1 )
  1145. {
  1146. int yysspLoc = (int) ( yyssp - xyyss.Get() );
  1147. xyyss.SetSize((unsigned) (yyssp-xyyss.Get())+2);
  1148. yyssp = xyyss.Get() + yysspLoc;
  1149. }
  1150. if ( yyvsp >= xyyvs.Get() + xyyvs.Size() - 1 )
  1151. {
  1152. int yyvspLoc = (int) ( yyvsp - xyyvs.Get() );
  1153. xyyvs.SetSize((unsigned) (yyvsp-xyyvs.Get())+2);
  1154. yyvsp = xyyvs.Get() + yyvspLoc;
  1155. }
  1156. *++yyssp = yystate = yytable[yyn];
  1157. *++yyvsp = yylval;
  1158. yychar = (-1);
  1159. if (yyerrflag > 0) --yyerrflag;
  1160. goto yyloop;
  1161. }
  1162. if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
  1163. yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  1164. {
  1165. yyn = yytable[yyn];
  1166. goto yyreduce;
  1167. }
  1168. if (yyerrflag) goto yyinrecovery;
  1169. yyerror("syntax error");
  1170. ++yynerrs;
  1171. yyinrecovery:
  1172. if (yyerrflag < 3)
  1173. {
  1174. yyerrflag = 3;
  1175. for (;;)
  1176. {
  1177. if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
  1178. yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
  1179. {
  1180. #if YYDEBUG
  1181. if (yydebug)
  1182. printf("%sdebug: state %d, error recovery shifting\
  1183. to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
  1184. #endif
  1185. if ( yyssp >= xyyss.Get() + xyyss.Count() - 1 )
  1186. {
  1187. int yysspLoc = (int) ( yyssp - xyyss.Get() );
  1188. xyyss.SetSize((unsigned) (yyssp-xyyss.Get())+2);
  1189. yyssp = xyyss.Get() + yysspLoc;
  1190. }
  1191. if ( yyvsp >= xyyvs.Get() + xyyvs.Size() - 1 )
  1192. {
  1193. int yyvspLoc = (int) ( yyvsp - xyyvs.Get() );
  1194. xyyvs.SetSize((unsigned) (yyvsp-xyyvs.Get())+2);
  1195. yyvsp = xyyvs.Get() + yyvspLoc;
  1196. }
  1197. *++yyssp = yystate = yytable[yyn];
  1198. *++yyvsp = yylval;
  1199. goto yyloop;
  1200. }
  1201. else
  1202. {
  1203. #if YYDEBUG
  1204. if (yydebug)
  1205. printf("%sdebug: error recovery discarding state %d\n",
  1206. YYPREFIX, *yyssp);
  1207. #endif
  1208. if (yyssp <= xyyss.Get()) goto yyabort;
  1209. --yyssp;
  1210. PopVs();
  1211. }
  1212. }
  1213. }
  1214. else
  1215. {
  1216. if (yychar == 0) goto yyabort;
  1217. #if YYDEBUG
  1218. if (yydebug)
  1219. {
  1220. yys = 0;
  1221. if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  1222. if (!yys) yys = "illegal-symbol";
  1223. printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
  1224. YYPREFIX, yystate, yychar, yys);
  1225. }
  1226. #endif
  1227. yychar = (-1);
  1228. goto yyloop;
  1229. }
  1230. yyreduce:
  1231. #if YYDEBUG
  1232. if (yydebug)
  1233. printf("%sdebug: state %d, reducing by rule %d (%s)\n",
  1234. YYPREFIX, yystate, yyn, yyrule[yyn]);
  1235. #endif
  1236. yym = yylen[yyn];
  1237. yyval = yyvsp[1-yym];
  1238. switch (yyn)
  1239. {
  1240. case 1:
  1241. {
  1242. yyval.pRest = yyvsp[0].pRest;
  1243. }
  1244. break;
  1245. case 2:
  1246. {
  1247. AssertReq(yyvsp[-2].pRest);
  1248. AssertReq(yyvsp[0].pRest);
  1249. XDbRestriction prstQuery(yyvsp[-2].pRest);
  1250. XDbRestriction prstTerm(yyvsp[0].pRest);
  1251. _setRst.Remove( yyvsp[-2].pRest );
  1252. _setRst.Remove( yyvsp[0].pRest );
  1253. BOOL fAcquireQuery = FALSE;
  1254. XDbBooleanNodeRestriction prstNew;
  1255. if (DBOP_or == yyvsp[-2].pRest->GetCommandType())
  1256. {
  1257. /* add right term & release its smart pointer*/
  1258. ((CDbBooleanNodeRestriction *)(yyvsp[-2].pRest))->AppendChild( prstTerm.GetPointer() );
  1259. prstTerm.Acquire();
  1260. fAcquireQuery = TRUE;
  1261. yyval.pRest = prstQuery.GetPointer();
  1262. }
  1263. else
  1264. {
  1265. /* create smart Or node*/
  1266. prstNew.Set( new CDbBooleanNodeRestriction( DBOP_or ) );
  1267. if( 0 == prstNew.GetPointer() )
  1268. THROW( CException( E_OUTOFMEMORY ) );
  1269. prstNew->SetWeight(MAX_QUERY_RANK);
  1270. /* add left term & release its smart pointer*/
  1271. prstNew->AppendChild( prstQuery.GetPointer() );
  1272. prstQuery.Acquire();
  1273. /* add right term & release its smart pointer*/
  1274. prstNew->AppendChild( prstTerm.GetPointer() );
  1275. prstTerm.Acquire();
  1276. yyval.pRest = prstNew.GetPointer();
  1277. }
  1278. _setRst.Add( yyval.pRest );
  1279. if ( fAcquireQuery )
  1280. prstQuery.Acquire();
  1281. else
  1282. prstNew.Acquire();
  1283. }
  1284. break;
  1285. case 3:
  1286. {
  1287. AssertReq(yyvsp[0].pRest);
  1288. XDbRestriction prstQuery(yyvsp[0].pRest);
  1289. _setRst.Remove( yyvsp[0].pRest );
  1290. /* Create not node*/
  1291. XDbBooleanNodeRestriction prstNew( new CDbBooleanNodeRestriction( DBOP_not ) );
  1292. if( 0 == prstNew.GetPointer() )
  1293. THROW( CException( E_OUTOFMEMORY ) );
  1294. prstNew->SetWeight(MAX_QUERY_RANK);
  1295. /* add right term and release its smart pointer*/
  1296. prstNew->AppendChild( prstQuery.GetPointer() );
  1297. prstQuery.Acquire();
  1298. yyval.pRest = prstNew.GetPointer();
  1299. _setRst.Add( yyval.pRest );
  1300. prstNew.Acquire();
  1301. }
  1302. break;
  1303. case 4:
  1304. { yyval.pRest = yyvsp[0].pRest;}
  1305. break;
  1306. case 5:
  1307. {
  1308. AssertReq(yyvsp[0].pRest);
  1309. XDbRestriction prstTerm(yyvsp[0].pRest);
  1310. _setRst.Remove( yyvsp[0].pRest );
  1311. /* Create not node*/
  1312. XDbBooleanNodeRestriction prstNew( new CDbBooleanNodeRestriction( DBOP_not ) );
  1313. if( 0 == prstNew.GetPointer() )
  1314. THROW( CException( E_OUTOFMEMORY ) );
  1315. prstNew->SetWeight(MAX_QUERY_RANK);
  1316. /* add right term and release its smart pointer*/
  1317. prstNew->AppendChild( prstTerm.GetPointer() );
  1318. prstTerm.Acquire();
  1319. yyval.pRest = prstNew.GetPointer();
  1320. _setRst.Add( yyval.pRest );
  1321. prstNew.Acquire();
  1322. }
  1323. break;
  1324. case 6:
  1325. {
  1326. AssertReq(yyvsp[-2].pRest);
  1327. AssertReq(yyvsp[0].pRest);
  1328. XDbRestriction prstQuery(yyvsp[-2].pRest);
  1329. XDbRestriction prstTerm(yyvsp[0].pRest);
  1330. _setRst.Remove( yyvsp[-2].pRest );
  1331. _setRst.Remove( yyvsp[0].pRest );
  1332. BOOL fAcquireQuery = FALSE;
  1333. XDbBooleanNodeRestriction prstNew;
  1334. if (DBOP_and == yyvsp[-2].pRest->GetCommandType())
  1335. {
  1336. /* add right term & release its smart pointer*/
  1337. ((CDbBooleanNodeRestriction *)(yyvsp[-2].pRest))->AppendChild( prstTerm.GetPointer() );
  1338. prstTerm.Acquire();
  1339. fAcquireQuery = TRUE;
  1340. yyval.pRest = prstQuery.GetPointer();
  1341. }
  1342. else
  1343. {
  1344. /* create smart And node*/
  1345. prstNew.Set( new CDbBooleanNodeRestriction( DBOP_and ) );
  1346. if( prstNew.GetPointer() == 0 )
  1347. THROW( CException( E_OUTOFMEMORY ) );
  1348. prstNew->SetWeight(MAX_QUERY_RANK);
  1349. /* add left term & release its smart pointer*/
  1350. prstNew->AppendChild( prstQuery.GetPointer() );
  1351. prstQuery.Acquire();
  1352. /* add right term & release its smart pointer*/
  1353. prstNew->AppendChild( prstTerm.GetPointer() );
  1354. prstTerm.Acquire();
  1355. yyval.pRest = prstNew.GetPointer();
  1356. }
  1357. _setRst.Add( yyval.pRest );
  1358. if ( fAcquireQuery )
  1359. prstQuery.Acquire();
  1360. else
  1361. prstNew.Acquire();
  1362. }
  1363. break;
  1364. case 7:
  1365. {
  1366. AssertReq(yyvsp[-3].pRest);
  1367. AssertReq(yyvsp[0].pRest);
  1368. XDbRestriction prstQuery(yyvsp[-3].pRest);
  1369. XDbRestriction prstTerm(yyvsp[0].pRest);
  1370. _setRst.Remove( yyvsp[-3].pRest );
  1371. _setRst.Remove( yyvsp[0].pRest );
  1372. /* create smart Not node*/
  1373. XDbNotRestriction prstNot( new CDbNotRestriction );
  1374. if( prstNot.GetPointer() == 0 )
  1375. THROW( CException( E_OUTOFMEMORY ) );
  1376. prstNot->SetWeight(MAX_QUERY_RANK);
  1377. /* set child of Not node & release smart factor pointer*/
  1378. prstNot->SetChild( prstTerm.GetPointer() );
  1379. prstTerm.Acquire();
  1380. BOOL fAcquireQuery = FALSE;
  1381. XDbBooleanNodeRestriction prstNew;
  1382. if (DBOP_and == yyvsp[-3].pRest->GetCommandType())
  1383. {
  1384. /* add right term & release its smart pointer*/
  1385. ((CDbBooleanNodeRestriction *)(yyvsp[-3].pRest))->AppendChild( prstNot.GetPointer() );
  1386. prstNot.Acquire();
  1387. yyval.pRest = prstQuery.GetPointer();
  1388. fAcquireQuery = TRUE;
  1389. }
  1390. else
  1391. {
  1392. /* create smart And node*/
  1393. prstNew.Set( new CDbBooleanNodeRestriction( DBOP_and ) );
  1394. if( prstNew.GetPointer() == 0 )
  1395. THROW( CException( E_OUTOFMEMORY ) );
  1396. prstNew->SetWeight(MAX_QUERY_RANK);
  1397. /* add left term & release its smart pointer*/
  1398. prstNew->AppendChild( prstQuery.GetPointer() );
  1399. prstQuery.Acquire();
  1400. /* add right term & release its smart pointer*/
  1401. prstNew->AppendChild( prstNot.GetPointer() );
  1402. prstNot.Acquire();
  1403. yyval.pRest = prstNew.GetPointer();
  1404. }
  1405. _setRst.Add( yyval.pRest );
  1406. if ( fAcquireQuery )
  1407. prstQuery.Acquire();
  1408. else
  1409. prstNew.Acquire();
  1410. }
  1411. break;
  1412. case 8:
  1413. { yyval.pRest = yyvsp[0].pRest; }
  1414. break;
  1415. case 9:
  1416. {
  1417. /* uses defaults*/
  1418. AssertReq(yyvsp[-2].pRest);
  1419. AssertReq(yyvsp[0].pRest);
  1420. XDbRestriction prstLeft(yyvsp[-2].pRest);
  1421. XDbRestriction prstRight(yyvsp[0].pRest);
  1422. _setRst.Remove( yyvsp[-2].pRest );
  1423. _setRst.Remove( yyvsp[0].pRest );
  1424. BOOL fAcquireLeft = FALSE;
  1425. XDbProximityNodeRestriction prstNew;
  1426. if (DBOP_content_proximity == yyvsp[-2].pRest->GetCommandType() &&
  1427. 50 == ((CDbProximityNodeRestriction *)yyvsp[-2].pRest)->GetProximityDistance() &&
  1428. PROXIMITY_UNIT_WORD == ((CDbProximityNodeRestriction *)yyvsp[-2].pRest)->GetProximityUnit())
  1429. {
  1430. /* add right term & release its smart pointer*/
  1431. ((CDbProximityNodeRestriction *)yyvsp[-2].pRest)->AppendChild( prstRight.GetPointer() );
  1432. prstRight.Acquire();
  1433. yyval.pRest = prstLeft.GetPointer();
  1434. fAcquireLeft = TRUE;
  1435. }
  1436. else
  1437. {
  1438. /* create smart Prox node*/
  1439. prstNew.Set(new CDbProximityNodeRestriction()); /* uses defaults*/
  1440. if ( prstNew.IsNull() || !prstNew->IsValid() )
  1441. THROW( CException( E_OUTOFMEMORY ) );
  1442. /* add left phrase & release its smart pointer*/
  1443. prstNew->AppendChild( prstLeft.GetPointer() );
  1444. prstLeft.Acquire();
  1445. /* add right term & release its smart pointer*/
  1446. prstNew->AppendChild( prstRight.GetPointer() );
  1447. prstRight.Acquire();
  1448. yyval.pRest = prstNew.GetPointer();
  1449. }
  1450. _setRst.Add( yyval.pRest );
  1451. if ( fAcquireLeft )
  1452. prstLeft.Acquire();
  1453. else
  1454. prstNew.Acquire();
  1455. }
  1456. break;
  1457. case 10:
  1458. {
  1459. AssertReq(yyvsp[-4].pRest);
  1460. AssertReq(yyvsp[-3].pwszChar);
  1461. AssertReq(yyvsp[-2].pwszChar);
  1462. AssertReq(yyvsp[0].pRest);
  1463. XDbRestriction prstLeft(yyvsp[-4].pRest);
  1464. XDbRestriction prstRight(yyvsp[0].pRest);
  1465. _setRst.Remove( yyvsp[-4].pRest );
  1466. _setRst.Remove( yyvsp[0].pRest );
  1467. WCHAR * pwcEnd;
  1468. ULONG ulValue = wcstol( yyvsp[-3].pwszChar, &pwcEnd, 10 );
  1469. ULONG ulUnit;
  1470. if (L'w' == *yyvsp[-2].pwszChar)
  1471. ulUnit = PROXIMITY_UNIT_WORD;
  1472. else if (L's' == *yyvsp[-2].pwszChar)
  1473. ulUnit = PROXIMITY_UNIT_SENTENCE;
  1474. else if (L'p' == *yyvsp[-2].pwszChar)
  1475. ulUnit = PROXIMITY_UNIT_PARAGRAPH;
  1476. else if (L'c' == *yyvsp[-2].pwszChar)
  1477. ulUnit = PROXIMITY_UNIT_CHAPTER;
  1478. BOOL fAcquireLeft = FALSE;
  1479. XDbProximityNodeRestriction prstNew;
  1480. if (DBOP_content_proximity == yyvsp[-4].pRest->GetCommandType() &&
  1481. ulValue == ((CDbProximityNodeRestriction *)yyvsp[-4].pRest)->GetProximityDistance() &&
  1482. ulUnit == ((CDbProximityNodeRestriction *)yyvsp[-4].pRest)->GetProximityUnit())
  1483. {
  1484. /* add right term & release its smart pointer*/
  1485. ((CDbProximityNodeRestriction *)yyvsp[-4].pRest)->AppendChild( prstRight.GetPointer() );
  1486. prstRight.Acquire();
  1487. yyval.pRest = prstLeft.GetPointer();
  1488. fAcquireLeft = TRUE;
  1489. }
  1490. else
  1491. {
  1492. /* create smart Prox node*/
  1493. prstNew.Set(new CDbProximityNodeRestriction(ulUnit, ulValue));
  1494. if( prstNew.IsNull() || !prstNew->IsValid() )
  1495. THROW( CException( E_OUTOFMEMORY ) );
  1496. /* add left phrase & release its smart pointer*/
  1497. prstNew->AppendChild( prstLeft.GetPointer() );
  1498. prstLeft.Acquire();
  1499. /* add right term & release its smart pointer*/
  1500. prstNew->AppendChild( prstRight.GetPointer() );
  1501. prstRight.Acquire();
  1502. yyval.pRest = prstNew.GetPointer();
  1503. }
  1504. _setRst.Add( yyval.pRest );
  1505. if ( fAcquireLeft )
  1506. prstLeft.Acquire();
  1507. else
  1508. prstNew.Acquire();
  1509. }
  1510. break;
  1511. case 11:
  1512. {
  1513. yyval.pRest = yyvsp[-1].pRest;
  1514. }
  1515. break;
  1516. case 12:
  1517. {
  1518. AssertReq(yyvsp[-1].pRest);
  1519. XDbRestriction prstQuery(yyvsp[-1].pRest);
  1520. yyvsp[-1].pRest->SetWeight(MAX_QUERY_RANK);
  1521. yyval.pRest = prstQuery.Acquire();
  1522. }
  1523. break;
  1524. case 13:
  1525. {
  1526. AssertReq(yyvsp[-3].pwszChar);
  1527. AssertReq(yyvsp[-1].pRest);
  1528. XDbRestriction prstQuery(yyvsp[-1].pRest);
  1529. WCHAR * pwcEnd;
  1530. double dWeight = wcstod( yyvsp[-3].pwszChar, &pwcEnd );
  1531. if ( dWeight > 1.0 )
  1532. THROW( CParserException( QPARSE_E_WEIGHT_OUT_OF_RANGE ) );
  1533. LONG lWeight = (LONG)(dWeight * MAX_QUERY_RANK);
  1534. yyvsp[-1].pRest->SetWeight(lWeight);
  1535. yyval.pRest = prstQuery.Acquire();
  1536. }
  1537. break;
  1538. case 14:
  1539. {
  1540. yyval.iInt = 0;
  1541. }
  1542. break;
  1543. case 15:
  1544. {
  1545. SetCurrentGenerate(GENERATE_METHOD_PREFIX);
  1546. yyval.iInt = GENERATE_METHOD_PREFIX;
  1547. }
  1548. break;
  1549. case 16:
  1550. {
  1551. SetCurrentGenerate(GENERATE_METHOD_INFLECT);
  1552. yyval.iInt = GENERATE_METHOD_INFLECT;
  1553. }
  1554. break;
  1555. case 17:
  1556. {
  1557. yyval.iEmpty = GENERATE_METHOD_EXACT;
  1558. }
  1559. break;
  1560. case 18:
  1561. {
  1562. /* don't set the generate method to 0 here. Doing so will*/
  1563. /* reset the method before it gets used.*/
  1564. yyval.iEmpty = GENERATE_METHOD_EXACT;
  1565. }
  1566. break;
  1567. case 19:
  1568. {
  1569. yyval.pRest = yyvsp[0].pRest;
  1570. }
  1571. break;
  1572. case 20:
  1573. {
  1574. yyval.pRest = yyvsp[0].pRest;
  1575. }
  1576. break;
  1577. case 21:
  1578. {
  1579. yyval.pRest = yyvsp[-1].pRest;
  1580. }
  1581. break;
  1582. case 22:
  1583. {
  1584. yyval.pRest = yyvsp[-1].pRest;
  1585. }
  1586. break;
  1587. case 23:
  1588. {
  1589. AssertReq(yyvsp[-2].pwszChar);
  1590. AssertReq(yyvsp[0].pRest);
  1591. XDbRestriction prstQuery(yyvsp[0].pRest);
  1592. _setRst.Remove( yyvsp[0].pRest );
  1593. ULONG rankMethod = VECTOR_RANK_JACCARD; /* default if nothing else matches*/
  1594. if ( 0 == _wcsicmp( L"jaccard", yyvsp[-2].pwszChar) )
  1595. {
  1596. rankMethod = VECTOR_RANK_JACCARD;
  1597. }
  1598. else if ( 0 == _wcsicmp( L"dice", yyvsp[-2].pwszChar) )
  1599. {
  1600. rankMethod = VECTOR_RANK_DICE;
  1601. }
  1602. else if ( 0 == _wcsicmp( L"inner", yyvsp[-2].pwszChar) )
  1603. {
  1604. rankMethod = VECTOR_RANK_INNER;
  1605. }
  1606. else if ( 0 == _wcsicmp( L"max", yyvsp[-2].pwszChar) )
  1607. {
  1608. rankMethod = VECTOR_RANK_MAX;
  1609. }
  1610. else if ( 0 == _wcsicmp( L"min", yyvsp[-2].pwszChar) )
  1611. {
  1612. rankMethod = VECTOR_RANK_MIN;
  1613. }
  1614. else
  1615. {
  1616. THROW( CException( QPARSE_E_INVALID_RANKMETHOD ) );
  1617. }
  1618. /* create smart Vector node*/
  1619. XDbVectorRestriction prstNew( new CDbVectorRestriction( rankMethod ) );
  1620. if ( prstNew.IsNull() || !prstNew->IsValid() )
  1621. {
  1622. THROW( CException( E_OUTOFMEMORY ) );
  1623. }
  1624. /* add expression & release its smart pointer*/
  1625. prstNew->AppendChild( prstQuery.GetPointer() );
  1626. prstQuery.Acquire();
  1627. /* Let the next vector element start off with a clean slate...*/
  1628. /* We don't want the current element's property and genmethod*/
  1629. /* to rub off on it.*/
  1630. InitState();
  1631. yyval.pRest = prstNew.GetPointer();
  1632. _setRst.Add( yyval.pRest );
  1633. prstNew.Acquire();
  1634. }
  1635. break;
  1636. case 24:
  1637. {
  1638. AssertReq(yyvsp[-2].pRest);
  1639. AssertReq(yyvsp[0].pRest);
  1640. XDbRestriction prstLeft(yyvsp[-2].pRest);
  1641. XDbRestriction prstRight(yyvsp[0].pRest);
  1642. _setRst.Remove( yyvsp[-2].pRest );
  1643. _setRst.Remove( yyvsp[0].pRest );
  1644. /* add right term & release its smart pointer*/
  1645. ((CDbVectorRestriction *)(yyvsp[-2].pRest))->AppendChild( prstRight.GetPointer() );
  1646. prstRight.Acquire();
  1647. /* Let the next vector element start off with a clean slate...*/
  1648. /* We don't want the current element's property and genmethod*/
  1649. /* to rub off on it.*/
  1650. InitState();
  1651. yyval.pRest = prstLeft.GetPointer();
  1652. _setRst.Add( yyval.pRest );
  1653. prstLeft.Acquire();
  1654. }
  1655. break;
  1656. case 25:
  1657. {
  1658. SaveState();
  1659. yyval.iEmpty = 0;
  1660. }
  1661. break;
  1662. case 26:
  1663. {
  1664. RestoreState();
  1665. yyval.iEmpty = 0;
  1666. }
  1667. break;
  1668. case 27:
  1669. {
  1670. yyval.pRest = yyvsp[0].pRest;
  1671. }
  1672. break;
  1673. case 28:
  1674. {
  1675. yyval.pRest = BuildPhrase(yyvsp[-2].pwszChar, yyvsp[-1].iInt);
  1676. _setRst.Add( yyval.pRest );
  1677. }
  1678. break;
  1679. case 29:
  1680. {
  1681. yyval.pRest = BuildPhrase(yyvsp[-1].pwszChar, 0);
  1682. _setRst.Add( yyval.pRest );
  1683. }
  1684. break;
  1685. case 30:
  1686. {
  1687. yyval.pRest = BuildPhrase(yyvsp[-2].pwszChar, yyvsp[-3].iInt);
  1688. _setRst.Add( yyval.pRest );
  1689. }
  1690. break;
  1691. case 31:
  1692. {
  1693. yyval.pRest = yyvsp[0].pRest;
  1694. }
  1695. break;
  1696. case 32:
  1697. {
  1698. AssertReq(yyvsp[-2].pwszChar);
  1699. CDbColId *pps;
  1700. DBTYPE dbType;
  1701. GetCurrentProperty(&pps, &dbType);
  1702. /* We used the property. Now pop it off if need be*/
  1703. if (fDeferredPop)
  1704. PopProperty();
  1705. /* Clear generation method so it won't rub off on the following phrase*/
  1706. SetCurrentGenerate(GENERATE_METHOD_EXACT);
  1707. /* generation method not used - if it's there, ignore it*/
  1708. /* (already stripped from longhand version, but not from*/
  1709. /* shorthand version*/
  1710. LPWSTR pLast = yyvsp[-2].pwszChar + wcslen(yyvsp[-2].pwszChar) -1;
  1711. if ( L'*' == *pLast) /* prefix*/
  1712. *pLast-- = L'\0';
  1713. if ( L'*' == *pLast) /* inflect*/
  1714. *pLast-- = L'\0';
  1715. XDbNatLangRestriction pRest ( new CDbNatLangRestriction (yyvsp[-2].pwszChar, *pps, _lcid));
  1716. if ( pRest.IsNull() || !pRest->IsValid() )
  1717. THROW( CException( E_OUTOFMEMORY ) );
  1718. yyval.pRest = pRest.GetPointer();
  1719. _setRst.Add( yyval.pRest );
  1720. pRest.Acquire();
  1721. }
  1722. break;
  1723. case 33:
  1724. {
  1725. AssertReq(yyvsp[-1].pwszChar);
  1726. CDbColId *pps;
  1727. DBTYPE dbType;
  1728. GetCurrentProperty(&pps, &dbType);
  1729. /* We used the property. Now pop it off if need be*/
  1730. if (fDeferredPop)
  1731. PopProperty();
  1732. if ( ( ( DBTYPE_WSTR|DBTYPE_BYREF ) != dbType ) &&
  1733. ( ( DBTYPE_STR|DBTYPE_BYREF ) != dbType ) &&
  1734. ( VT_BSTR != dbType ) &&
  1735. ( VT_LPWSTR != dbType ) &&
  1736. ( VT_LPSTR != dbType ) )
  1737. THROW( CParserException( QPARSE_E_EXPECTING_REGEX_PROPERTY ) );
  1738. if( yyvsp[-1].pwszChar == 0 )
  1739. THROW( CParserException( QPARSE_E_EXPECTING_REGEX ) );
  1740. /* create smart Property node*/
  1741. XDbPropertyRestriction prstProp( new CDbPropertyRestriction );
  1742. if( prstProp.GetPointer() == 0 )
  1743. THROW( CException( E_OUTOFMEMORY ) );
  1744. prstProp->SetRelation(DBOP_like); /* LIKE relation*/
  1745. if ( ( ! prstProp->SetProperty( *pps ) ) ||
  1746. ( ! prstProp->SetValue( yyvsp[-1].pwszChar ) ) ||
  1747. ( ! prstProp->IsValid() ) )
  1748. THROW( CException( E_OUTOFMEMORY ) );
  1749. /* release & return smart Property node*/
  1750. yyval.pRest = prstProp.GetPointer();
  1751. _setRst.Add( yyval.pRest );
  1752. prstProp.Acquire();
  1753. }
  1754. break;
  1755. case 34:
  1756. {
  1757. AssertReq(yyvsp[-2].dbop);
  1758. AssertReq(yyvsp[-1].pStorageVar);
  1759. XPtr<CStorageVariant> pStorageVar( yyvsp[-1].pStorageVar );
  1760. _setStgVar.Remove( yyvsp[-1].pStorageVar );
  1761. CDbColId *pps;
  1762. DBTYPE dbType;
  1763. GetCurrentProperty(&pps, &dbType);
  1764. /* We used the property. Now pop it off if need be*/
  1765. if (fDeferredPop)
  1766. PopProperty();
  1767. /* create smart Property node*/
  1768. XDbPropertyRestriction prstProp( new CDbPropertyRestriction );
  1769. if( prstProp.GetPointer() == 0 )
  1770. THROW( CException( E_OUTOFMEMORY ) );
  1771. if (! prstProp->SetProperty( *pps ) )
  1772. THROW( CException( E_OUTOFMEMORY ) );
  1773. /* don't allow @contents <relop> X -- it's too expensive and we'll*/
  1774. /* never find any hits anyway (until we implement this feature)*/
  1775. if ( *pps == psContents )
  1776. THROW( CParserException( QPARSE_E_EXPECTING_PHRASE ) );
  1777. prstProp->SetRelation( yyvsp[-2].dbop );
  1778. if ( 0 != pStorageVar.GetPointer() )
  1779. {
  1780. /* This should always be the case - else PropValueParser would have thrown*/
  1781. if ( ! ( ( prstProp->SetValue( pStorageVar.GetReference() ) ) &&
  1782. ( prstProp->IsValid() ) ) )
  1783. THROW( CException( E_OUTOFMEMORY ) );
  1784. }
  1785. yyval.pRest = prstProp.GetPointer();
  1786. _setRst.Add( yyval.pRest );
  1787. prstProp.Acquire();
  1788. }
  1789. break;
  1790. case 35:
  1791. {
  1792. yyval.iEmpty = 0;
  1793. }
  1794. break;
  1795. case 36:
  1796. {
  1797. PushProperty(yyvsp[0].pwszChar);
  1798. yyval.iEmpty = 0;
  1799. }
  1800. break;
  1801. case 37:
  1802. {
  1803. fDeferredPop = FALSE;
  1804. yyval.iEmpty = 0;
  1805. }
  1806. break;
  1807. case 38:
  1808. {
  1809. /* When PropEnd is matched, the action of using the property*/
  1810. /* hasn't yet taken place. So popping the property right now*/
  1811. /* will cause the property to be unavailable when the action*/
  1812. /* is performed. Instead, pop it off after it has been used.*/
  1813. fDeferredPop = TRUE;
  1814. yyval.iEmpty = 0;
  1815. }
  1816. break;
  1817. case 39:
  1818. { yyval.dbop = DBOP_equal;}
  1819. break;
  1820. case 40:
  1821. { yyval.dbop = DBOP_not_equal;}
  1822. break;
  1823. case 41:
  1824. { yyval.dbop = DBOP_greater;}
  1825. break;
  1826. case 42:
  1827. { yyval.dbop = DBOP_greater_equal;}
  1828. break;
  1829. case 43:
  1830. { yyval.dbop = DBOP_less;}
  1831. break;
  1832. case 44:
  1833. { yyval.dbop = DBOP_less_equal;}
  1834. break;
  1835. case 45:
  1836. { yyval.dbop = DBOP_allbits;}
  1837. break;
  1838. case 46:
  1839. { yyval.dbop = DBOP_anybits;}
  1840. break;
  1841. case 47:
  1842. { yyval.dbop = DBOP_equal_any;}
  1843. break;
  1844. case 48:
  1845. { yyval.dbop = DBOP_not_equal_any;}
  1846. break;
  1847. case 49:
  1848. { yyval.dbop = DBOP_greater_any;}
  1849. break;
  1850. case 50:
  1851. { yyval.dbop = DBOP_greater_equal_any;}
  1852. break;
  1853. case 51:
  1854. { yyval.dbop = DBOP_less_any;}
  1855. break;
  1856. case 52:
  1857. { yyval.dbop = DBOP_less_equal_any;}
  1858. break;
  1859. case 53:
  1860. { yyval.dbop = DBOP_allbits_any;}
  1861. break;
  1862. case 54:
  1863. { yyval.dbop = DBOP_anybits_any;}
  1864. break;
  1865. case 55:
  1866. { yyval.dbop = DBOP_equal_all;}
  1867. break;
  1868. case 56:
  1869. { yyval.dbop = DBOP_not_equal_all;}
  1870. break;
  1871. case 57:
  1872. { yyval.dbop = DBOP_greater_all;}
  1873. break;
  1874. case 58:
  1875. { yyval.dbop = DBOP_greater_equal_all;}
  1876. break;
  1877. case 59:
  1878. { yyval.dbop = DBOP_less_all;}
  1879. break;
  1880. case 60:
  1881. { yyval.dbop = DBOP_less_equal_all;}
  1882. break;
  1883. case 61:
  1884. { yyval.dbop = DBOP_allbits_all;}
  1885. break;
  1886. case 62:
  1887. { yyval.dbop = DBOP_anybits_all;}
  1888. break;
  1889. case 63:
  1890. { yyval.dbop = 0; }
  1891. break;
  1892. case 64:
  1893. { yyval.dbop = DBOP_equal; }
  1894. break;
  1895. case 65:
  1896. {
  1897. CDbColId *pps;
  1898. DBTYPE dbType;
  1899. GetCurrentProperty(&pps, &dbType);
  1900. CValueParser PropValueParser( FALSE, dbType, _lcid );
  1901. StripQuotes(yyvsp[0].pwszChar);
  1902. PropValueParser.AddValue( yyvsp[0].pwszChar );
  1903. yyval.pStorageVar = PropValueParser.GetStgVariant();
  1904. _setStgVar.Add( yyval.pStorageVar );
  1905. PropValueParser.AcquireStgVariant();
  1906. }
  1907. break;
  1908. case 66:
  1909. {
  1910. CDbColId *pps;
  1911. DBTYPE dbType;
  1912. GetCurrentProperty(&pps, &dbType);
  1913. CValueParser PropValueParser( FALSE, dbType, _lcid );
  1914. PropValueParser.AddValue( yyvsp[0].pwszChar );
  1915. yyval.pStorageVar = PropValueParser.GetStgVariant();
  1916. _setStgVar.Add( yyval.pStorageVar );
  1917. PropValueParser.AcquireStgVariant();
  1918. }
  1919. break;
  1920. case 67:
  1921. {
  1922. yyval.pStorageVar = yyvsp[0].pStorageVar;
  1923. }
  1924. break;
  1925. case 68:
  1926. {
  1927. XPtr <CValueParser> pPropValueParser ( yyvsp[0].pPropValueParser );
  1928. _setValueParser.Remove( yyvsp[0].pPropValueParser );
  1929. yyval.pStorageVar = yyvsp[0].pPropValueParser->GetStgVariant();
  1930. _setStgVar.Add( yyval.pStorageVar );
  1931. yyvsp[0].pPropValueParser->AcquireStgVariant();
  1932. }
  1933. break;
  1934. case 69:
  1935. {
  1936. XPtr <CValueParser> pPropValueParser ( yyvsp[0].pPropValueParser );
  1937. _setValueParser.Remove( yyvsp[0].pPropValueParser );
  1938. yyval.pStorageVar = yyvsp[0].pPropValueParser->GetStgVariant();
  1939. _setStgVar.Add( yyval.pStorageVar );
  1940. yyvsp[0].pPropValueParser->AcquireStgVariant();
  1941. }
  1942. break;
  1943. case 70:
  1944. {
  1945. XPtr <CValueParser> pPropValueParser ( yyvsp[-1].pPropValueParser );
  1946. _setValueParser.Remove( yyvsp[-1].pPropValueParser );
  1947. yyval.pStorageVar = yyvsp[-1].pPropValueParser->GetStgVariant();
  1948. _setStgVar.Add( yyval.pStorageVar );
  1949. yyvsp[-1].pPropValueParser->AcquireStgVariant();
  1950. }
  1951. break;
  1952. case 71:
  1953. {
  1954. CDbColId *pps;
  1955. DBTYPE dbType;
  1956. GetCurrentProperty(&pps, &dbType);
  1957. XPtr <CValueParser> pPropValueParser ( new CValueParser( TRUE, dbType, _lcid ) );
  1958. if( pPropValueParser.GetPointer() == 0 )
  1959. THROW( CException( E_OUTOFMEMORY ) );
  1960. yyval.pPropValueParser = pPropValueParser.GetPointer();
  1961. _setValueParser.Add( yyval.pPropValueParser );
  1962. pPropValueParser.Acquire();
  1963. }
  1964. break;
  1965. case 72:
  1966. {
  1967. AssertReq(yyvsp[-1].pwszChar);
  1968. CDbColId *pps;
  1969. DBTYPE dbType;
  1970. GetCurrentProperty(&pps, &dbType);
  1971. XPtr <CValueParser> pPropValueParser ( new CValueParser( TRUE, dbType, _lcid ) );
  1972. if( pPropValueParser.GetPointer() == 0 )
  1973. THROW( CException( E_OUTOFMEMORY ) );
  1974. StripQuotes(yyvsp[-1].pwszChar);
  1975. pPropValueParser->AddValue( yyvsp[-1].pwszChar );
  1976. yyval.pPropValueParser = pPropValueParser.GetPointer();
  1977. _setValueParser.Add( yyval.pPropValueParser );
  1978. pPropValueParser.Acquire();
  1979. }
  1980. break;
  1981. case 73:
  1982. {
  1983. AssertReq(yyvsp[-1].pwszChar);
  1984. CDbColId *pps;
  1985. DBTYPE dbType;
  1986. GetCurrentProperty(&pps, &dbType);
  1987. XPtr <CValueParser> pPropValueParser ( new CValueParser( TRUE, dbType, _lcid ) );
  1988. if( pPropValueParser.GetPointer() == 0 )
  1989. THROW( CException( E_OUTOFMEMORY ) );
  1990. pPropValueParser->AddValue( yyvsp[-1].pwszChar );
  1991. yyval.pPropValueParser = pPropValueParser.GetPointer();
  1992. _setValueParser.Add( yyval.pPropValueParser );
  1993. pPropValueParser.Acquire();
  1994. }
  1995. break;
  1996. case 74:
  1997. {
  1998. AssertReq(yyvsp[-1].pwszChar);
  1999. AssertReq(yyvsp[0].pwszChar);
  2000. CDbColId *pps;
  2001. DBTYPE dbType;
  2002. GetCurrentProperty(&pps, &dbType);
  2003. XPtr <CValueParser> pPropValueParser ( new CValueParser( TRUE, dbType, _lcid ) );
  2004. if( pPropValueParser.GetPointer() == 0 )
  2005. THROW( CException( E_OUTOFMEMORY ) );
  2006. pPropValueParser->AddValue( yyvsp[-1].pwszChar );
  2007. pPropValueParser->AddValue( yyvsp[0].pwszChar );
  2008. yyval.pPropValueParser = pPropValueParser.GetPointer();
  2009. _setValueParser.Add( yyval.pPropValueParser );
  2010. pPropValueParser.Acquire();
  2011. }
  2012. break;
  2013. case 75:
  2014. {
  2015. AssertReq(yyvsp[-1].pPropValueParser);
  2016. AssertReq(yyvsp[0].pwszChar);
  2017. yyvsp[-1].pPropValueParser->AddValue(yyvsp[0].pwszChar);
  2018. yyval.pPropValueParser = yyvsp[-1].pPropValueParser;
  2019. }
  2020. break;
  2021. case 76:
  2022. {
  2023. yyval.iEmpty = 0;
  2024. }
  2025. break;
  2026. case 77:
  2027. {
  2028. yyval.iEmpty = 0;
  2029. }
  2030. break;
  2031. case 78:
  2032. {
  2033. yyval.iInt = 0;
  2034. }
  2035. break;
  2036. case 79:
  2037. {
  2038. yyval.iInt = 1;
  2039. }
  2040. break;
  2041. case 80:
  2042. {
  2043. yyval.iInt = 2;
  2044. }
  2045. break;
  2046. }
  2047. yyssp -= yym;
  2048. yystate = *yyssp;
  2049. yyvsp -= yym;
  2050. yym = yylhs[yyn];
  2051. if (yystate == 0 && yym == 0)
  2052. {
  2053. #if YYDEBUG
  2054. if (yydebug)
  2055. printf("%sdebug: after reduction, shifting from state 0 to\
  2056. state %d\n", YYPREFIX, YYFINAL);
  2057. #endif
  2058. yystate = YYFINAL;
  2059. *++yyssp = YYFINAL;
  2060. *++yyvsp = yyval;
  2061. if (yychar < 0)
  2062. {
  2063. try
  2064. {
  2065. if ( (yychar = YYLEX(&YYAPI_VALUENAME)) < 0 )
  2066. yychar = 0;
  2067. }
  2068. catch (HRESULT hr)
  2069. {
  2070. switch(hr)
  2071. {
  2072. case E_OUTOFMEMORY:
  2073. YYABORT(E_OUTOFMEMORY);
  2074. break;
  2075. default:
  2076. YYABORT(E_FAIL);
  2077. break;
  2078. }
  2079. }
  2080. #if YYDEBUG
  2081. if (yydebug)
  2082. {
  2083. yys = 0;
  2084. if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  2085. if (!yys) yys = "illegal-symbol";
  2086. printf("%sdebug: state %d, reading %d (%s)\n",
  2087. YYPREFIX, YYFINAL, yychar, yys);
  2088. }
  2089. #endif
  2090. }
  2091. if (yychar == 0) goto yyaccept;
  2092. goto yyloop;
  2093. }
  2094. if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
  2095. yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
  2096. yystate = yytable[yyn];
  2097. else
  2098. yystate = yydgoto[yym];
  2099. #if YYDEBUG
  2100. if (yydebug)
  2101. printf("%sdebug: after reduction, shifting from state %d \
  2102. to state %d\n", YYPREFIX, *yyssp, yystate);
  2103. #endif
  2104. if ( yyssp >= xyyss.Get() + xyyss.Count() - 1 )
  2105. {
  2106. int yysspLoc = (int) ( yyssp - xyyss.Get() );
  2107. xyyss.SetSize((unsigned) ( yyssp-xyyss.Get())+2);
  2108. yyssp = xyyss.Get() + yysspLoc;
  2109. }
  2110. if ( yyvsp >= xyyvs.Get() + xyyvs.Size() - 1 )
  2111. {
  2112. int yyvspLoc = (int) ( yyssp - xyyss.Get() );
  2113. xyyvs.SetSize((unsigned) ( yyvsp-xyyvs.Get())+2);
  2114. yyvsp = xyyvs.Get() + yyvspLoc;
  2115. }
  2116. *++yyssp = (short) yystate;
  2117. *++yyvsp = yyval;
  2118. goto yyloop;
  2119. yyabort:
  2120. EmptyValueStack(yylval);
  2121. return YYFATAL;
  2122. yyaccept:
  2123. return YYSUCCESS;
  2124. }