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.

14782 lines
436 KiB

  1. diff --git a/src/pregen/DAAP.u b/src/pregen/DAAP.u
  2. new file mode 100644
  3. index 0000000..3de527b
  4. --- /dev/null
  5. +++ b/src/pregen/DAAP.u
  6. @@ -0,0 +1,6 @@
  7. +DAAPParser.c : DAAP.g
  8. +./DAAP.tokens : DAAP.g
  9. +DAAPParser.h : DAAP.g
  10. +DAAPLexer.c : DAAP.g
  11. +DAAPLexer.h : DAAP.g
  12. +ANTLR_PRODUCTS += DAAPParser.c ./DAAP.tokens DAAPParser.h DAAPLexer.c DAAPLexer.h
  13. \ No newline at end of file
  14. diff --git a/src/pregen/DAAP2SQL.c b/src/pregen/DAAP2SQL.c
  15. new file mode 100644
  16. index 0000000..3f94589
  17. --- /dev/null
  18. +++ b/src/pregen/DAAP2SQL.c
  19. @@ -0,0 +1,929 @@
  20. +/** \file
  21. + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
  22. + *
  23. + * - From the grammar source file : DAAP2SQL.g
  24. + * - On : 2014-09-30 21:42:43
  25. + * - for the tree parser : DAAP2SQLTreeParser *
  26. + * Editing it, at least manually, is not wise.
  27. + *
  28. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  29. + *
  30. + *
  31. +*/
  32. +// [The "BSD licence"]
  33. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  34. +// http://www.temporal-wave.com
  35. +// http://www.linkedin.com/in/jimidle
  36. +//
  37. +// All rights reserved.
  38. +//
  39. +// Redistribution and use in source and binary forms, with or without
  40. +// modification, are permitted provided that the following conditions
  41. +// are met:
  42. +// 1. Redistributions of source code must retain the above copyright
  43. +// notice, this list of conditions and the following disclaimer.
  44. +// 2. Redistributions in binary form must reproduce the above copyright
  45. +// notice, this list of conditions and the following disclaimer in the
  46. +// documentation and/or other materials provided with the distribution.
  47. +// 3. The name of the author may not be used to endorse or promote products
  48. +// derived from this software without specific prior written permission.
  49. +//
  50. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  51. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  52. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  53. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  54. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  55. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  56. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  57. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  58. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  59. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  60. +
  61. +
  62. +/* =============================================================================
  63. + * This is what the grammar programmer asked us to put at the top of every file.
  64. + */
  65. +
  66. + #include <stdio.h>
  67. + #include <stdlib.h>
  68. + #include <string.h>
  69. + #include <limits.h>
  70. + #include <errno.h>
  71. +
  72. + #include "logger.h"
  73. + #include "db.h"
  74. + #include "daap_query.h"
  75. +
  76. +/* End of Header action.
  77. + * =============================================================================
  78. + */
  79. +/* -----------------------------------------
  80. + * Include the ANTLR3 generated header file.
  81. + */
  82. +#include "DAAP2SQL.h"
  83. +/* ----------------------------------------- */
  84. +
  85. +
  86. +
  87. +
  88. +
  89. +/* MACROS that hide the C interface implementations from the
  90. + * generated code, which makes it a little more understandable to the human eye.
  91. + * I am very much against using C pre-processor macros for function calls and bits
  92. + * of code as you cannot see what is happening when single stepping in debuggers
  93. + * and so on. The exception (in my book at least) is for generated code, where you are
  94. + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
  95. + * hides some indirect calls, but is always referring to the input stream. This is
  96. + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
  97. + * the runtime interfaces without changing the generated code too often, without
  98. + * confusing the reader of the generated output, who may not wish to know the gory
  99. + * details of the interface inheritance.
  100. + */
  101. +
  102. +#define CTX ctx
  103. +
  104. +/* Aids in accessing scopes for grammar programmers
  105. + */
  106. +#undef SCOPE_TYPE
  107. +#undef SCOPE_STACK
  108. +#undef SCOPE_TOP
  109. +#define SCOPE_TYPE(scope) pDAAP2SQL_##scope##_SCOPE
  110. +#define SCOPE_STACK(scope) pDAAP2SQL_##scope##Stack
  111. +#define SCOPE_TOP(scope) ctx->pDAAP2SQL_##scope##Top
  112. +#define SCOPE_SIZE(scope) ctx->pDAAP2SQL_##scope##Stack_limit
  113. +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
  114. +
  115. +/* Macros for accessing things in the parser
  116. + */
  117. +
  118. +#undef PARSER
  119. +#undef RECOGNIZER
  120. +#undef HAVEPARSEDRULE
  121. +#undef INPUT
  122. +#undef STRSTREAM
  123. +#undef HASEXCEPTION
  124. +#undef EXCEPTION
  125. +#undef MATCHT
  126. +#undef MATCHANYT
  127. +#undef FOLLOWSTACK
  128. +#undef FOLLOWPUSH
  129. +#undef FOLLOWPOP
  130. +#undef PRECOVER
  131. +#undef PREPORTERROR
  132. +#undef LA
  133. +#undef LT
  134. +#undef CONSTRUCTEX
  135. +#undef CONSUME
  136. +#undef MARK
  137. +#undef REWIND
  138. +#undef REWINDLAST
  139. +#undef PERRORRECOVERY
  140. +#undef HASFAILED
  141. +#undef FAILEDFLAG
  142. +#undef RECOVERFROMMISMATCHEDSET
  143. +#undef RECOVERFROMMISMATCHEDELEMENT
  144. +#undef BACKTRACKING
  145. +#undef ADAPTOR
  146. +#undef RULEMEMO
  147. +#undef SEEK
  148. +#undef INDEX
  149. +#undef DBG
  150. +
  151. +#define PARSER ctx->pTreeParser
  152. +#define RECOGNIZER PARSER->rec
  153. +#define PSRSTATE RECOGNIZER->state
  154. +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
  155. +#define INPUT PARSER->ctnstream
  156. +#define ISTREAM INPUT->tnstream->istream
  157. +#define STRSTREAM INPUT->tnstream
  158. +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
  159. +#define EXCEPTION PSRSTATE->exception
  160. +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
  161. +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
  162. +#define FOLLOWSTACK PSRSTATE->following
  163. +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
  164. +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
  165. +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
  166. +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
  167. +#define LA(n) ISTREAM->_LA(ISTREAM, n)
  168. +#define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n)
  169. +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
  170. +#define CONSUME() ISTREAM->consume(ISTREAM)
  171. +#define MARK() ISTREAM->mark(ISTREAM)
  172. +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
  173. +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
  174. +#define PERRORRECOVERY PSRSTATE->errorRecovery
  175. +#define FAILEDFLAG PSRSTATE->failed
  176. +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
  177. +#define BACKTRACKING PSRSTATE->backtracking
  178. +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
  179. +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
  180. +#define ADAPTOR INPUT->adaptor
  181. +#define RULEMEMO PSRSTATE->ruleMemo
  182. +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
  183. +#define INDEX() ISTREAM->index(ISTREAM)
  184. +#define DBG RECOGNIZER->debugger
  185. +
  186. +
  187. +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
  188. +
  189. +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
  190. + * then for the present you must use different names for your defines as these are hard coded
  191. + * in the code generator. It would be better not to use such names internally, and maybe
  192. + * we can change this in a forthcoming release. I deliberately do not #undef these
  193. + * here as this will at least give you a redefined error somewhere if they clash.
  194. + */
  195. +#define UP ANTLR3_TOKEN_UP
  196. +#define DOWN ANTLR3_TOKEN_DOWN
  197. +#define EOR ANTLR3_TOKEN_EOR
  198. +#define INVALID ANTLR3_TOKEN_INVALID
  199. +
  200. +
  201. +/* =============================================================================
  202. + * Functions to create and destroy scopes. First come the rule scopes, followed
  203. + * by the global declared scopes.
  204. + */
  205. +
  206. +
  207. +
  208. +/* ============================================================================= */
  209. +
  210. +/* =============================================================================
  211. + * Start of recognizer
  212. + */
  213. +
  214. +
  215. +
  216. +/** \brief Table of all token names in symbolic order, mainly used for
  217. + * error reporting.
  218. + */
  219. +pANTLR3_UINT8 DAAP2SQLTokenNames[8+4]
  220. + = {
  221. + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
  222. + (pANTLR3_UINT8) "<EOR>",
  223. + (pANTLR3_UINT8) "<DOWN>",
  224. + (pANTLR3_UINT8) "<UP>",
  225. + (pANTLR3_UINT8) "NEWLINE",
  226. + (pANTLR3_UINT8) "OPOR",
  227. + (pANTLR3_UINT8) "OPAND",
  228. + (pANTLR3_UINT8) "LPAR",
  229. + (pANTLR3_UINT8) "RPAR",
  230. + (pANTLR3_UINT8) "STR",
  231. + (pANTLR3_UINT8) "QUOTE",
  232. + (pANTLR3_UINT8) "ESCAPED"
  233. + };
  234. +
  235. +
  236. +
  237. +// Forward declare the locally static matching functions we have generated.
  238. +//
  239. +static pANTLR3_STRING query (pDAAP2SQL ctx);
  240. +static DAAP2SQL_expr_return expr (pDAAP2SQL ctx);
  241. +static void DAAP2SQLFree(pDAAP2SQL ctx);
  242. +/* For use in tree output where we are accumulating rule labels via label += ruleRef
  243. + * we need a function that knows how to free a return scope when the list is destroyed.
  244. + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
  245. + */
  246. +static void ANTLR3_CDECL freeScope(void * scope)
  247. +{
  248. + ANTLR3_FREE(scope);
  249. +}
  250. +
  251. +/** \brief Name of the grammar file that generated this code
  252. + */
  253. +static const char fileName[] = "DAAP2SQL.g";
  254. +
  255. +/** \brief Return the name of the grammar file that generated this code.
  256. + */
  257. +static const char * getGrammarFileName()
  258. +{
  259. + return fileName;
  260. +}
  261. +/** \brief Create a new DAAP2SQL parser and return a context for it.
  262. + *
  263. + * \param[in] instream Pointer to an input stream interface.
  264. + *
  265. + * \return Pointer to new parser context upon success.
  266. + */
  267. +ANTLR3_API pDAAP2SQL
  268. +DAAP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream)
  269. +{
  270. + // See if we can create a new parser with the standard constructor
  271. + //
  272. + return DAAP2SQLNewSSD(instream, NULL);
  273. +}
  274. +
  275. +/** \brief Create a new DAAP2SQL parser and return a context for it.
  276. + *
  277. + * \param[in] instream Pointer to an input stream interface.
  278. + *
  279. + * \return Pointer to new parser context upon success.
  280. + */
  281. +ANTLR3_API pDAAP2SQL
  282. +DAAP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
  283. +{
  284. + pDAAP2SQL ctx; /* Context structure we will build and return */
  285. +
  286. + ctx = (pDAAP2SQL) ANTLR3_CALLOC(1, sizeof(DAAP2SQL));
  287. +
  288. + if (ctx == NULL)
  289. + {
  290. + // Failed to allocate memory for parser context
  291. + //
  292. + return NULL;
  293. + }
  294. +
  295. + /* -------------------------------------------------------------------
  296. + * Memory for basic structure is allocated, now to fill in
  297. + * the base ANTLR3 structures. We initialize the function pointers
  298. + * for the standard ANTLR3 parser function set, but upon return
  299. + * from here, the programmer may set the pointers to provide custom
  300. + * implementations of each function.
  301. + *
  302. + * We don't use the macros defined in DAAP2SQL.h here, in order that you can get a sense
  303. + * of what goes where.
  304. + */
  305. +
  306. + /* Create a base Tree parser/recognizer, using the supplied tree node stream
  307. + */
  308. + ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state);
  309. + /* Install the implementation of our DAAP2SQL interface
  310. + */
  311. + ctx->query = query;
  312. + ctx->expr = expr;
  313. + ctx->free = DAAP2SQLFree;
  314. + ctx->getGrammarFileName = getGrammarFileName;
  315. +
  316. + /* Install the scope pushing methods.
  317. + */
  318. +
  319. +
  320. +
  321. +
  322. +
  323. + /* Install the token table
  324. + */
  325. + PSRSTATE->tokenNames = DAAP2SQLTokenNames;
  326. +
  327. +
  328. + /* Return the newly built parser to the caller
  329. + */
  330. + return ctx;
  331. +}
  332. +
  333. +/** Free the parser resources
  334. + */
  335. + static void
  336. + DAAP2SQLFree(pDAAP2SQL ctx)
  337. + {
  338. + /* Free any scope memory
  339. + */
  340. +
  341. +
  342. + // Free this parser
  343. + //
  344. + ctx->pTreeParser->free(ctx->pTreeParser);
  345. + ANTLR3_FREE(ctx);
  346. +
  347. + /* Everything is released, so we can return
  348. + */
  349. + return;
  350. + }
  351. +
  352. +/** Return token names used by this tree parser
  353. + *
  354. + * The returned pointer is used as an index into the token names table (using the token
  355. + * number as the index).
  356. + *
  357. + * \return Pointer to first char * in the table.
  358. + */
  359. +static pANTLR3_UINT8 *getTokenNames()
  360. +{
  361. + return DAAP2SQLTokenNames;
  362. +}
  363. +
  364. +
  365. + struct dmap_query_field_map {
  366. + char *dmap_field;
  367. + char *db_col;
  368. + int as_int;
  369. + };
  370. +
  371. + /* gperf static hash, daap_query.gperf */
  372. + #include "daap_query_hash.c"
  373. +
  374. +
  375. +/* Declare the bitsets
  376. + */
  377. +
  378. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query70 */
  379. +static ANTLR3_BITWORD FOLLOW_expr_in_query70_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  380. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_query70 = { FOLLOW_expr_in_query70_bits, 1 };
  381. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPAND_in_expr95 */
  382. +static ANTLR3_BITWORD FOLLOW_OPAND_in_expr95_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  383. +static ANTLR3_BITSET_LIST FOLLOW_OPAND_in_expr95 = { FOLLOW_OPAND_in_expr95_bits, 1 };
  384. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr101 */
  385. +static ANTLR3_BITWORD FOLLOW_expr_in_expr101_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000260) };
  386. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr101 = { FOLLOW_expr_in_expr101_bits, 1 };
  387. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr107 */
  388. +static ANTLR3_BITWORD FOLLOW_expr_in_expr107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  389. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr107 = { FOLLOW_expr_in_expr107_bits, 1 };
  390. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPOR_in_expr118 */
  391. +static ANTLR3_BITWORD FOLLOW_OPOR_in_expr118_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  392. +static ANTLR3_BITSET_LIST FOLLOW_OPOR_in_expr118 = { FOLLOW_OPOR_in_expr118_bits, 1 };
  393. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr124 */
  394. +static ANTLR3_BITWORD FOLLOW_expr_in_expr124_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000260) };
  395. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr124 = { FOLLOW_expr_in_expr124_bits, 1 };
  396. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr130 */
  397. +static ANTLR3_BITWORD FOLLOW_expr_in_expr130_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  398. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr130 = { FOLLOW_expr_in_expr130_bits, 1 };
  399. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_expr140 */
  400. +static ANTLR3_BITWORD FOLLOW_STR_in_expr140_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  401. +static ANTLR3_BITSET_LIST FOLLOW_STR_in_expr140 = { FOLLOW_STR_in_expr140_bits, 1 };
  402. +
  403. +
  404. +
  405. +
  406. +/* ==============================================
  407. + * Parsing rules
  408. + */
  409. +/**
  410. + * $ANTLR start query
  411. + * DAAP2SQL.g:50:1: query returns [ pANTLR3_STRING result ] : e= expr ;
  412. + */
  413. +static pANTLR3_STRING
  414. +query(pDAAP2SQL ctx)
  415. +{
  416. + pANTLR3_STRING result = NULL;
  417. +
  418. + DAAP2SQL_expr_return e;
  419. + #undef RETURN_TYPE_e
  420. + #define RETURN_TYPE_e DAAP2SQL_expr_return
  421. +
  422. + /* Initialize rule variables
  423. + */
  424. +
  425. +
  426. + result= NULL;
  427. + {
  428. + // DAAP2SQL.g:52:2: (e= expr )
  429. + // DAAP2SQL.g:52:4: e= expr
  430. + {
  431. + FOLLOWPUSH(FOLLOW_expr_in_query70);
  432. + e=expr(ctx);
  433. +
  434. + FOLLOWPOP();
  435. + if (HASEXCEPTION())
  436. + {
  437. + goto rulequeryEx;
  438. + }
  439. +
  440. + {
  441. +
  442. + if (!e.valid)
  443. + {
  444. + result= NULL;
  445. + }
  446. + else
  447. + {
  448. + result= e.result->factory->newRaw(e.result->factory);
  449. + result->append8(result, "(");
  450. + result->appendS(result, e.result);
  451. + result->append8(result, ")");
  452. + }
  453. +
  454. + }
  455. +
  456. + }
  457. +
  458. + }
  459. +
  460. +
  461. + // This is where rules clean up and exit
  462. + //
  463. + goto rulequeryEx; /* Prevent compiler warnings */
  464. + rulequeryEx: ;
  465. +
  466. + if (HASEXCEPTION())
  467. + {
  468. + PREPORTERROR();
  469. + PRECOVER();
  470. + }
  471. +
  472. +
  473. + return result;
  474. +}
  475. +/* $ANTLR end query */
  476. +
  477. +/**
  478. + * $ANTLR start expr
  479. + * DAAP2SQL.g:68:1: expr returns [ pANTLR3_STRING result, int valid ] : ( ^( OPAND a= expr b= expr ) | ^( OPOR a= expr b= expr ) | STR );
  480. + */
  481. +static DAAP2SQL_expr_return
  482. +expr(pDAAP2SQL ctx)
  483. +{
  484. + DAAP2SQL_expr_return retval;
  485. +
  486. + pANTLR3_BASE_TREE STR1;
  487. + DAAP2SQL_expr_return a;
  488. + #undef RETURN_TYPE_a
  489. + #define RETURN_TYPE_a DAAP2SQL_expr_return
  490. +
  491. + DAAP2SQL_expr_return b;
  492. + #undef RETURN_TYPE_b
  493. + #define RETURN_TYPE_b DAAP2SQL_expr_return
  494. +
  495. + /* Initialize rule variables
  496. + */
  497. +
  498. +
  499. + retval.result= NULL; retval.valid= 1;
  500. + STR1 = NULL;
  501. + retval.start = LT(1); retval.stop = retval.start;
  502. +
  503. + {
  504. + {
  505. + // DAAP2SQL.g:70:2: ( ^( OPAND a= expr b= expr ) | ^( OPOR a= expr b= expr ) | STR )
  506. +
  507. + ANTLR3_UINT32 alt1;
  508. +
  509. + alt1=3;
  510. +
  511. + switch ( LA(1) )
  512. + {
  513. + case OPAND:
  514. + {
  515. + alt1=1;
  516. + }
  517. + break;
  518. + case OPOR:
  519. + {
  520. + alt1=2;
  521. + }
  522. + break;
  523. + case STR:
  524. + {
  525. + alt1=3;
  526. + }
  527. + break;
  528. +
  529. + default:
  530. + CONSTRUCTEX();
  531. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  532. + EXCEPTION->message = (void *)"";
  533. + EXCEPTION->decisionNum = 1;
  534. + EXCEPTION->state = 0;
  535. +
  536. +
  537. + goto ruleexprEx;
  538. + }
  539. +
  540. + switch (alt1)
  541. + {
  542. + case 1:
  543. + // DAAP2SQL.g:70:4: ^( OPAND a= expr b= expr )
  544. + {
  545. + MATCHT(OPAND, &FOLLOW_OPAND_in_expr95);
  546. + if (HASEXCEPTION())
  547. + {
  548. + goto ruleexprEx;
  549. + }
  550. +
  551. +
  552. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  553. + if (HASEXCEPTION())
  554. + {
  555. + goto ruleexprEx;
  556. + }
  557. +
  558. + FOLLOWPUSH(FOLLOW_expr_in_expr101);
  559. + a=expr(ctx);
  560. +
  561. + FOLLOWPOP();
  562. + if (HASEXCEPTION())
  563. + {
  564. + goto ruleexprEx;
  565. + }
  566. +
  567. + FOLLOWPUSH(FOLLOW_expr_in_expr107);
  568. + b=expr(ctx);
  569. +
  570. + FOLLOWPOP();
  571. + if (HASEXCEPTION())
  572. + {
  573. + goto ruleexprEx;
  574. + }
  575. +
  576. +
  577. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  578. + if (HASEXCEPTION())
  579. + {
  580. + goto ruleexprEx;
  581. + }
  582. +
  583. + {
  584. +
  585. + if (!a.valid || !b.valid)
  586. + {
  587. + retval.valid= 0;
  588. + }
  589. + else
  590. + {
  591. + retval.result= a.result->factory->newRaw(a.result->factory);
  592. + retval.result->append8(retval.result, "(");
  593. + retval.result->appendS(retval.result, a.result);
  594. + retval.result->append8(retval.result, " AND ");
  595. + retval.result->appendS(retval.result, b.result);
  596. + retval.result->append8(retval.result, ")");
  597. + }
  598. +
  599. + }
  600. +
  601. + }
  602. + break;
  603. + case 2:
  604. + // DAAP2SQL.g:86:4: ^( OPOR a= expr b= expr )
  605. + {
  606. + MATCHT(OPOR, &FOLLOW_OPOR_in_expr118);
  607. + if (HASEXCEPTION())
  608. + {
  609. + goto ruleexprEx;
  610. + }
  611. +
  612. +
  613. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  614. + if (HASEXCEPTION())
  615. + {
  616. + goto ruleexprEx;
  617. + }
  618. +
  619. + FOLLOWPUSH(FOLLOW_expr_in_expr124);
  620. + a=expr(ctx);
  621. +
  622. + FOLLOWPOP();
  623. + if (HASEXCEPTION())
  624. + {
  625. + goto ruleexprEx;
  626. + }
  627. +
  628. + FOLLOWPUSH(FOLLOW_expr_in_expr130);
  629. + b=expr(ctx);
  630. +
  631. + FOLLOWPOP();
  632. + if (HASEXCEPTION())
  633. + {
  634. + goto ruleexprEx;
  635. + }
  636. +
  637. +
  638. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  639. + if (HASEXCEPTION())
  640. + {
  641. + goto ruleexprEx;
  642. + }
  643. +
  644. + {
  645. +
  646. + if (!a.valid || !b.valid)
  647. + {
  648. + retval.valid= 0;
  649. + }
  650. + else
  651. + {
  652. + retval.result= a.result->factory->newRaw(a.result->factory);
  653. + retval.result->append8(retval.result, "(");
  654. + retval.result->appendS(retval.result, a.result);
  655. + retval.result->append8(retval.result, " OR ");
  656. + retval.result->appendS(retval.result, b.result);
  657. + retval.result->append8(retval.result, ")");
  658. + }
  659. +
  660. + }
  661. +
  662. + }
  663. + break;
  664. + case 3:
  665. + // DAAP2SQL.g:102:4: STR
  666. + {
  667. + STR1 = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_expr140);
  668. + if (HASEXCEPTION())
  669. + {
  670. + goto ruleexprEx;
  671. + }
  672. +
  673. + {
  674. +
  675. + pANTLR3_STRING str;
  676. + pANTLR3_UINT8 field;
  677. + pANTLR3_UINT8 val;
  678. + pANTLR3_UINT8 escaped;
  679. + ANTLR3_UINT8 op;
  680. + int neg_op;
  681. + const struct dmap_query_field_map *dqfm;
  682. + char *end;
  683. + long long llval;
  684. +
  685. + escaped = NULL;
  686. +
  687. + retval.result= (STR1->getText(STR1))->factory->newRaw((STR1->getText(STR1))->factory);
  688. +
  689. + str = (STR1->getText(STR1))->toUTF8((STR1->getText(STR1)));
  690. +
  691. + /* NOTE: the lexer delivers the string without quotes
  692. + which may not be obvious from the grammar due to embedded code
  693. + */
  694. +
  695. + /* Make daap.songalbumid:0 a no-op */
  696. + if (strcmp((char *)str->chars, "daap.songalbumid:0") == 0)
  697. + {
  698. + retval.result->append8(retval.result, "1 = 1");
  699. +
  700. + goto STR_out;
  701. + }
  702. +
  703. + field = str->chars;
  704. +
  705. + val = field;
  706. + while ((*val != '\0') && ((*val == '.')
  707. + || (*val == '-')
  708. + || ((*val >= 'a') && (*val <= 'z'))
  709. + || ((*val >= 'A') && (*val <= 'Z'))
  710. + || ((*val >= '0') && (*val <= '9'))))
  711. + {
  712. + val++;
  713. + }
  714. +
  715. + if (*field == '\0')
  716. + {
  717. + DPRINTF(E_LOG, L_DAAP, "No field name found in clause '%s'\n", field);
  718. + retval.valid= 0;
  719. + goto STR_result_valid_0; /* ABORT */
  720. + }
  721. +
  722. + if (*val == '\0')
  723. + {
  724. + DPRINTF(E_LOG, L_DAAP, "No operator found in clause '%s'\n", field);
  725. + retval.valid= 0;
  726. + goto STR_result_valid_0; /* ABORT */
  727. + }
  728. +
  729. + op = *val;
  730. + *val = '\0';
  731. + val++;
  732. +
  733. + if (op == '!')
  734. + {
  735. + if (*val == '\0')
  736. + {
  737. + DPRINTF(E_LOG, L_DAAP, "Negation found but operator missing in clause '%s%c'\n", field, op);
  738. + retval.valid= 0;
  739. + goto STR_result_valid_0; /* ABORT */
  740. + }
  741. +
  742. + neg_op = 1;
  743. + op = *val;
  744. + val++;
  745. + }
  746. + else
  747. + neg_op = 0;
  748. +
  749. + /* Lookup DMAP field in the query field map */
  750. + dqfm = daap_query_field_lookup((char *)field, strlen((char *)field));
  751. + if (!dqfm)
  752. + {
  753. + DPRINTF(E_LOG, L_DAAP, "DMAP field '%s' is not a valid field in queries\n", field);
  754. + retval.valid= 0;
  755. + goto STR_result_valid_0; /* ABORT */
  756. + }
  757. +
  758. + /* Empty values OK for string fields, NOK for integer */
  759. + if (*val == '\0')
  760. + {
  761. + if (dqfm->as_int)
  762. + {
  763. + DPRINTF(E_LOG, L_DAAP, "No value given in clause '%s%s%c'\n", field, (neg_op) ? "!" : "", op);
  764. + retval.valid= 0;
  765. + goto STR_result_valid_0; /* ABORT */
  766. + }
  767. +
  768. + /* Need to check against NULL too */
  769. + if (op == ':')
  770. + retval.result->append8(retval.result, "(");
  771. + }
  772. +
  773. + retval.result->append8(retval.result, dqfm->db_col);
  774. +
  775. + /* Int field: check integer conversion */
  776. + if (dqfm->as_int)
  777. + {
  778. + errno = 0;
  779. + llval = strtoll((const char *)val, &end, 10);
  780. +
  781. + if (((errno == ERANGE) && ((llval == LLONG_MAX) || (llval == LLONG_MIN)))
  782. + || ((errno != 0) && (llval == 0)))
  783. + {
  784. + DPRINTF(E_LOG, L_DAAP, "Value '%s' in clause '%s%s%c%s' does not convert to an integer type\n",
  785. + val, field, (neg_op) ? "!" : "", op, val);
  786. + retval.valid= 0;
  787. + goto STR_result_valid_0; /* ABORT */
  788. + }
  789. +
  790. + if (end == (char *)val)
  791. + {
  792. + DPRINTF(E_LOG, L_DAAP, "Value '%s' in clause '%s%s%c%s' does not represent an integer value\n",
  793. + val, field, (neg_op) ? "!" : "", op, val);
  794. + retval.valid= 0;
  795. + goto STR_result_valid_0; /* ABORT */
  796. + }
  797. +
  798. + *end = '\0'; /* Cut out potential garbage - we're being kind */
  799. + }
  800. + /* String field: escape string, check for '*' */
  801. + else
  802. + {
  803. + if (op != ':')
  804. + {
  805. + DPRINTF(E_LOG, L_DAAP, "Operation '%c' not valid for string values\n", op);
  806. + retval.valid= 0;
  807. + goto STR_result_valid_0; /* ABORT */
  808. + }
  809. +
  810. + escaped = (pANTLR3_UINT8)db_escape_string((char *)val);
  811. + if (!escaped)
  812. + {
  813. + DPRINTF(E_LOG, L_DAAP, "Could not escape value\n");
  814. + retval.valid= 0;
  815. + goto STR_result_valid_0; /* ABORT */
  816. + }
  817. +
  818. + val = escaped;
  819. +
  820. + if (val[0] == '*')
  821. + {
  822. + op = '%';
  823. + val[0] = '%';
  824. + }
  825. +
  826. + if (val[strlen((char *)val) - 1] == '*')
  827. + {
  828. + op = '%';
  829. + val[strlen((char *)val) - 1] = '%';
  830. + }
  831. + }
  832. +
  833. + switch(op)
  834. + {
  835. + case ':':
  836. + if (neg_op)
  837. + retval.result->append8(retval.result, " <> ");
  838. + else
  839. + retval.result->append8(retval.result, " = ");
  840. + break;
  841. +
  842. + case '+':
  843. + if (neg_op)
  844. + retval.result->append8(retval.result, " <= ");
  845. + else
  846. + retval.result->append8(retval.result, " > ");
  847. + break;
  848. +
  849. + case '-':
  850. + if (neg_op)
  851. + retval.result->append8(retval.result, " >= ");
  852. + else
  853. + retval.result->append8(retval.result, " < ");
  854. + break;
  855. +
  856. + case '%':
  857. + retval.result->append8(retval.result, " LIKE ");
  858. + break;
  859. +
  860. + default:
  861. + if (neg_op)
  862. + DPRINTF(E_LOG, L_DAAP, "Missing or unknown operator '%c' in clause '%s!%c%s'\n", op, field, op, val);
  863. + else
  864. + DPRINTF(E_LOG, L_DAAP, "Unknown operator '%c' in clause '%s%c%s'\n", op, field, op, val);
  865. + retval.valid= 0;
  866. + goto STR_result_valid_0; /* ABORT */
  867. + break;
  868. + }
  869. +
  870. + if (!dqfm->as_int)
  871. + retval.result->append8(retval.result, "'");
  872. +
  873. + retval.result->append8(retval.result, (const char *)val);
  874. +
  875. + if (!dqfm->as_int)
  876. + retval.result->append8(retval.result, "'");
  877. +
  878. + /* For empty string value, we need to check against NULL too */
  879. + if ((*val == '\0') && (op == ':'))
  880. + {
  881. + if (neg_op)
  882. + retval.result->append8(retval.result, " AND ");
  883. + else
  884. + retval.result->append8(retval.result, " OR ");
  885. +
  886. + retval.result->append8(retval.result, dqfm->db_col);
  887. +
  888. + if (neg_op)
  889. + retval.result->append8(retval.result, " IS NOT NULL");
  890. + else
  891. + retval.result->append8(retval.result, " IS NULL");
  892. +
  893. + retval.result->append8(retval.result, ")");
  894. + }
  895. +
  896. + STR_result_valid_0: /* bail out label */
  897. + ;
  898. +
  899. + if (escaped)
  900. + free(escaped);
  901. +
  902. + STR_out: /* get out of here */
  903. + ;
  904. +
  905. + }
  906. +
  907. + }
  908. + break;
  909. +
  910. + }
  911. + }
  912. + }
  913. +
  914. +
  915. + // This is where rules clean up and exit
  916. + //
  917. + goto ruleexprEx; /* Prevent compiler warnings */
  918. + ruleexprEx: ;
  919. +
  920. + if (HASEXCEPTION())
  921. + {
  922. + PREPORTERROR();
  923. + PRECOVER();
  924. + }
  925. +
  926. +
  927. + return retval;
  928. +}
  929. +/* $ANTLR end expr */
  930. +/* End of parsing rules
  931. + * ==============================================
  932. + */
  933. +
  934. +/* ==============================================
  935. + * Syntactic predicates
  936. + */
  937. +/* End of syntactic predicates
  938. + * ==============================================
  939. + */
  940. +
  941. +
  942. +
  943. +
  944. +
  945. +
  946. +/* End of code
  947. + * =============================================================================
  948. + */
  949. diff --git a/src/pregen/DAAP2SQL.h b/src/pregen/DAAP2SQL.h
  950. new file mode 100644
  951. index 0000000..e170f6c
  952. --- /dev/null
  953. +++ b/src/pregen/DAAP2SQL.h
  954. @@ -0,0 +1,195 @@
  955. +/** \file
  956. + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
  957. + *
  958. + * - From the grammar source file : DAAP2SQL.g
  959. + * - On : 2014-09-30 21:42:43
  960. + * - for the tree parser : DAAP2SQLTreeParser *
  961. + * Editing it, at least manually, is not wise.
  962. + *
  963. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  964. + *
  965. + *
  966. + * The tree parser DAAP2SQL has the callable functions (rules) shown below,
  967. + * which will invoke the code for the associated rule in the source grammar
  968. + * assuming that the input stream is pointing to a token/text stream that could begin
  969. + * this rule.
  970. + *
  971. + * For instance if you call the first (topmost) rule in a parser grammar, you will
  972. + * get the results of a full parse, but calling a rule half way through the grammar will
  973. + * allow you to pass part of a full token stream to the parser, such as for syntax checking
  974. + * in editors and so on.
  975. + *
  976. + * The parser entry points are called indirectly (by function pointer to function) via
  977. + * a parser context typedef pDAAP2SQL, which is returned from a call to DAAP2SQLNew().
  978. + *
  979. + * The methods in pDAAP2SQL are as follows:
  980. + *
  981. + * - pANTLR3_STRING pDAAP2SQL->query(pDAAP2SQL)
  982. + * - DAAP2SQL_expr_return pDAAP2SQL->expr(pDAAP2SQL)
  983. + *
  984. + * The return type for any particular rule is of course determined by the source
  985. + * grammar file.
  986. + */
  987. +// [The "BSD licence"]
  988. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  989. +// http://www.temporal-wave.com
  990. +// http://www.linkedin.com/in/jimidle
  991. +//
  992. +// All rights reserved.
  993. +//
  994. +// Redistribution and use in source and binary forms, with or without
  995. +// modification, are permitted provided that the following conditions
  996. +// are met:
  997. +// 1. Redistributions of source code must retain the above copyright
  998. +// notice, this list of conditions and the following disclaimer.
  999. +// 2. Redistributions in binary form must reproduce the above copyright
  1000. +// notice, this list of conditions and the following disclaimer in the
  1001. +// documentation and/or other materials provided with the distribution.
  1002. +// 3. The name of the author may not be used to endorse or promote products
  1003. +// derived from this software without specific prior written permission.
  1004. +//
  1005. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  1006. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  1007. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  1008. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  1009. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  1010. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  1011. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  1012. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  1013. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  1014. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1015. +
  1016. +#ifndef _DAAP2SQL_H
  1017. +#define _DAAP2SQL_H
  1018. +/* =============================================================================
  1019. + * Standard antlr3 C runtime definitions
  1020. + */
  1021. +#include <antlr3.h>
  1022. +
  1023. +/* End of standard antlr 3 runtime definitions
  1024. + * =============================================================================
  1025. + */
  1026. +
  1027. +#ifdef __cplusplus
  1028. +extern "C" {
  1029. +#endif
  1030. +
  1031. +// Forward declare the context typedef so that we can use it before it is
  1032. +// properly defined. Delegators and delegates (from import statements) are
  1033. +// interdependent and their context structures contain pointers to each other
  1034. +// C only allows such things to be declared if you pre-declare the typedef.
  1035. +//
  1036. +typedef struct DAAP2SQL_Ctx_struct DAAP2SQL, * pDAAP2SQL;
  1037. +
  1038. +
  1039. +
  1040. + #include <stdio.h>
  1041. + #include <stdlib.h>
  1042. + #include <string.h>
  1043. + #include <limits.h>
  1044. + #include <errno.h>
  1045. +
  1046. + #include "logger.h"
  1047. + #include "db.h"
  1048. + #include "daap_query.h"
  1049. +
  1050. +
  1051. +#ifdef ANTLR3_WINDOWS
  1052. +// Disable: Unreferenced parameter, - Rules with parameters that are not used
  1053. +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
  1054. +// initialized but unused variable - tree rewrite variables declared but not needed
  1055. +// Unreferenced local variable - lexer rule declares but does not always use _type
  1056. +// potentially unitialized variable used - retval always returned from a rule
  1057. +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
  1058. +//
  1059. +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
  1060. +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
  1061. +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
  1062. +// this is a matter of orthogonality hence I disable that one.
  1063. +//
  1064. +#pragma warning( disable : 4100 )
  1065. +#pragma warning( disable : 4101 )
  1066. +#pragma warning( disable : 4127 )
  1067. +#pragma warning( disable : 4189 )
  1068. +#pragma warning( disable : 4505 )
  1069. +#pragma warning( disable : 4701 )
  1070. +#endif
  1071. +typedef struct DAAP2SQL_expr_return_struct
  1072. +{
  1073. + pANTLR3_BASE_TREE start;
  1074. + pANTLR3_BASE_TREE stop;
  1075. + pANTLR3_STRING result;
  1076. + int valid;
  1077. +}
  1078. + DAAP2SQL_expr_return;
  1079. +
  1080. +
  1081. +
  1082. +/** Context tracking structure for DAAP2SQL
  1083. + */
  1084. +struct DAAP2SQL_Ctx_struct
  1085. +{
  1086. + /** Built in ANTLR3 context tracker contains all the generic elements
  1087. + * required for context tracking.
  1088. + */
  1089. + pANTLR3_TREE_PARSER pTreeParser;
  1090. +
  1091. +
  1092. + pANTLR3_STRING (*query) (struct DAAP2SQL_Ctx_struct * ctx);
  1093. + DAAP2SQL_expr_return (*expr) (struct DAAP2SQL_Ctx_struct * ctx);
  1094. + // Delegated rules
  1095. + const char * (*getGrammarFileName)();
  1096. + void (*free) (struct DAAP2SQL_Ctx_struct * ctx);
  1097. +
  1098. +};
  1099. +
  1100. +// Function protoypes for the constructor functions that external translation units
  1101. +// such as delegators and delegates may wish to call.
  1102. +//
  1103. +ANTLR3_API pDAAP2SQL DAAP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream);
  1104. +ANTLR3_API pDAAP2SQL DAAP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
  1105. +
  1106. +/** Symbolic definitions of all the tokens that the tree parser will work with.
  1107. + * \{
  1108. + *
  1109. + * Antlr will define EOF, but we can't use that as it it is too common in
  1110. + * in C header files and that would be confusing. There is no way to filter this out at the moment
  1111. + * so we just undef it here for now. That isn't the value we get back from C recognizers
  1112. + * anyway. We are looking for ANTLR3_TOKEN_EOF.
  1113. + */
  1114. +#ifdef EOF
  1115. +#undef EOF
  1116. +#endif
  1117. +#ifdef Tokens
  1118. +#undef Tokens
  1119. +#endif
  1120. +#define STR 9
  1121. +#define QUOTE 10
  1122. +#define NEWLINE 4
  1123. +#define LPAR 7
  1124. +#define OPOR 5
  1125. +#define RPAR 8
  1126. +#define ESCAPED 11
  1127. +#define OPAND 6
  1128. +#define EOF -1
  1129. +#ifdef EOF
  1130. +#undef EOF
  1131. +#define EOF ANTLR3_TOKEN_EOF
  1132. +#endif
  1133. +
  1134. +#ifndef TOKENSOURCE
  1135. +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
  1136. +#endif
  1137. +
  1138. +/* End of token definitions for DAAP2SQL
  1139. + * =============================================================================
  1140. + */
  1141. +/** \} */
  1142. +
  1143. +#ifdef __cplusplus
  1144. +}
  1145. +#endif
  1146. +
  1147. +#endif
  1148. +
  1149. +/* END - Note:Keep extra line feed to satisfy UNIX systems */
  1150. diff --git a/src/pregen/DAAP2SQL.u b/src/pregen/DAAP2SQL.u
  1151. new file mode 100644
  1152. index 0000000..385d80b
  1153. --- /dev/null
  1154. +++ b/src/pregen/DAAP2SQL.u
  1155. @@ -0,0 +1,5 @@
  1156. +DAAP2SQL.g: DAAP.tokens
  1157. +DAAP2SQL.c : DAAP2SQL.g
  1158. +./DAAP2SQL.tokens : DAAP2SQL.g
  1159. +DAAP2SQL.h : DAAP2SQL.g
  1160. +ANTLR_PRODUCTS += DAAP2SQL.c ./DAAP2SQL.tokens DAAP2SQL.h
  1161. \ No newline at end of file
  1162. diff --git a/src/pregen/DAAPLexer.c b/src/pregen/DAAPLexer.c
  1163. new file mode 100644
  1164. index 0000000..12e7ef3
  1165. --- /dev/null
  1166. +++ b/src/pregen/DAAPLexer.c
  1167. @@ -0,0 +1,1101 @@
  1168. +/** \file
  1169. + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
  1170. + *
  1171. + * - From the grammar source file : DAAP.g
  1172. + * - On : 2014-09-30 21:42:40
  1173. + * - for the lexer : DAAPLexerLexer *
  1174. + * Editing it, at least manually, is not wise.
  1175. + *
  1176. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  1177. + *
  1178. + *
  1179. +*/
  1180. +// [The "BSD licence"]
  1181. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  1182. +// http://www.temporal-wave.com
  1183. +// http://www.linkedin.com/in/jimidle
  1184. +//
  1185. +// All rights reserved.
  1186. +//
  1187. +// Redistribution and use in source and binary forms, with or without
  1188. +// modification, are permitted provided that the following conditions
  1189. +// are met:
  1190. +// 1. Redistributions of source code must retain the above copyright
  1191. +// notice, this list of conditions and the following disclaimer.
  1192. +// 2. Redistributions in binary form must reproduce the above copyright
  1193. +// notice, this list of conditions and the following disclaimer in the
  1194. +// documentation and/or other materials provided with the distribution.
  1195. +// 3. The name of the author may not be used to endorse or promote products
  1196. +// derived from this software without specific prior written permission.
  1197. +//
  1198. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  1199. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  1200. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  1201. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  1202. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  1203. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  1204. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  1205. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  1206. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  1207. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1208. +
  1209. +/* -----------------------------------------
  1210. + * Include the ANTLR3 generated header file.
  1211. + */
  1212. +#include "DAAPLexer.h"
  1213. +/* ----------------------------------------- */
  1214. +
  1215. +
  1216. +
  1217. +
  1218. +
  1219. +/* MACROS that hide the C interface implementations from the
  1220. + * generated code, which makes it a little more understandable to the human eye.
  1221. + * I am very much against using C pre-processor macros for function calls and bits
  1222. + * of code as you cannot see what is happening when single stepping in debuggers
  1223. + * and so on. The exception (in my book at least) is for generated code, where you are
  1224. + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
  1225. + * hides some indirect calls, but is always referring to the input stream. This is
  1226. + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
  1227. + * the runtime interfaces without changing the generated code too often, without
  1228. + * confusing the reader of the generated output, who may not wish to know the gory
  1229. + * details of the interface inheritance.
  1230. + */
  1231. +
  1232. +#define CTX ctx
  1233. +
  1234. +/* Aids in accessing scopes for grammar programmers
  1235. + */
  1236. +#undef SCOPE_TYPE
  1237. +#undef SCOPE_STACK
  1238. +#undef SCOPE_TOP
  1239. +#define SCOPE_TYPE(scope) pDAAPLexer_##scope##_SCOPE
  1240. +#define SCOPE_STACK(scope) pDAAPLexer_##scope##Stack
  1241. +#define SCOPE_TOP(scope) ctx->pDAAPLexer_##scope##Top
  1242. +#define SCOPE_SIZE(scope) ctx->pDAAPLexer_##scope##Stack_limit
  1243. +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
  1244. +
  1245. +
  1246. +/* Macros for accessing things in a lexer
  1247. + */
  1248. +#undef LEXER
  1249. +#undef RECOGNIZER
  1250. +#undef RULEMEMO
  1251. +#undef GETCHARINDEX
  1252. +#undef GETLINE
  1253. +#undef GETCHARPOSITIONINLINE
  1254. +#undef EMIT
  1255. +#undef EMITNEW
  1256. +#undef MATCHC
  1257. +#undef MATCHS
  1258. +#undef MATCHRANGE
  1259. +#undef LTOKEN
  1260. +#undef HASFAILED
  1261. +#undef FAILEDFLAG
  1262. +#undef INPUT
  1263. +#undef STRSTREAM
  1264. +#undef LA
  1265. +#undef HASEXCEPTION
  1266. +#undef EXCEPTION
  1267. +#undef CONSTRUCTEX
  1268. +#undef CONSUME
  1269. +#undef LRECOVER
  1270. +#undef MARK
  1271. +#undef REWIND
  1272. +#undef REWINDLAST
  1273. +#undef BACKTRACKING
  1274. +#undef MATCHANY
  1275. +#undef MEMOIZE
  1276. +#undef HAVEPARSEDRULE
  1277. +#undef GETTEXT
  1278. +#undef INDEX
  1279. +#undef SEEK
  1280. +#undef PUSHSTREAM
  1281. +#undef POPSTREAM
  1282. +#undef SETTEXT
  1283. +#undef SETTEXT8
  1284. +
  1285. +#define LEXER ctx->pLexer
  1286. +#define RECOGNIZER LEXER->rec
  1287. +#define LEXSTATE RECOGNIZER->state
  1288. +#define TOKSOURCE LEXSTATE->tokSource
  1289. +#define GETCHARINDEX() LEXER->getCharIndex(LEXER)
  1290. +#define GETLINE() LEXER->getLine(LEXER)
  1291. +#define GETTEXT() LEXER->getText(LEXER)
  1292. +#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER)
  1293. +#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER)
  1294. +#define EMITNEW(t) LEXER->emitNew(LEXER, t)
  1295. +#define MATCHC(c) LEXER->matchc(LEXER, c)
  1296. +#define MATCHS(s) LEXER->matchs(LEXER, s)
  1297. +#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2)
  1298. +#define MATCHANY() LEXER->matchAny(LEXER)
  1299. +#define LTOKEN LEXSTATE->token
  1300. +#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE)
  1301. +#define BACKTRACKING LEXSTATE->backtracking
  1302. +#define FAILEDFLAG LEXSTATE->failed
  1303. +#define INPUT LEXER->input
  1304. +#define STRSTREAM INPUT
  1305. +#define ISTREAM INPUT->istream
  1306. +#define INDEX() ISTREAM->index(ISTREAM)
  1307. +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
  1308. +#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken)
  1309. +#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE)
  1310. +#define EXCEPTION LEXSTATE->exception
  1311. +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
  1312. +#define LRECOVER() LEXER->recover(LEXER)
  1313. +#define MARK() ISTREAM->mark(ISTREAM)
  1314. +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
  1315. +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
  1316. +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
  1317. +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
  1318. +#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str)
  1319. +#define POPSTREAM() LEXER->popCharStream(LEXER)
  1320. +#define SETTEXT(str) LEXSTATE->text = str
  1321. +#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken)
  1322. +#define USER1 LEXSTATE->user1
  1323. +#define USER2 LEXSTATE->user2
  1324. +#define USER3 LEXSTATE->user3
  1325. +#define CUSTOM LEXSTATE->custom
  1326. +#define RULEMEMO LEXSTATE->ruleMemo
  1327. +#define DBG RECOGNIZER->debugger
  1328. +
  1329. +/* If we have been told we can rely on the standard 8 bit or 16 bit input
  1330. + * stream, then we can define our macros to use the direct pointers
  1331. + * in the input object, which is much faster than indirect calls. This
  1332. + * is really only significant to lexers with a lot of fragment rules (which
  1333. + * do not place LA(1) in a temporary at the moment) and even then
  1334. + * only if there is a lot of input (order of say 1M or so).
  1335. + */
  1336. +#if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16)
  1337. +
  1338. +# ifdef ANTLR3_INLINE_INPUT_ASCII
  1339. +
  1340. +/* 8 bit "ASCII" (actually any 8 bit character set) */
  1341. +
  1342. +# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar))
  1343. +# define DATAP ((pANTLR3_UINT8)(INPUT->data))
  1344. +
  1345. +# else
  1346. +
  1347. +# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar))
  1348. +# define DATAP ((pANTLR3_UINT16)(INPUT->data))
  1349. +
  1350. +# endif
  1351. +
  1352. +# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1)))
  1353. +# define CONSUME() \
  1354. +{ \
  1355. + if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \
  1356. + { \
  1357. + INPUT->charPositionInLine++; \
  1358. + if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \
  1359. + { \
  1360. + INPUT->line++; \
  1361. + INPUT->charPositionInLine = 0; \
  1362. + INPUT->currentLine = (void *)(NEXTCHAR + 1); \
  1363. + } \
  1364. + INPUT->nextChar = (void *)(NEXTCHAR + 1); \
  1365. + } \
  1366. +}
  1367. +
  1368. +#else
  1369. +
  1370. +// Pick up the input character by calling the input stream implementation.
  1371. +//
  1372. +#define CONSUME() INPUT->istream->consume(INPUT->istream)
  1373. +#define LA(n) INPUT->istream->_LA(INPUT->istream, n)
  1374. +
  1375. +#endif
  1376. +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
  1377. +
  1378. +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
  1379. + * then for the present you must use different names for your defines as these are hard coded
  1380. + * in the code generator. It would be better not to use such names internally, and maybe
  1381. + * we can change this in a forthcoming release. I deliberately do not #undef these
  1382. + * here as this will at least give you a redefined error somewhere if they clash.
  1383. + */
  1384. +#define UP ANTLR3_TOKEN_UP
  1385. +#define DOWN ANTLR3_TOKEN_DOWN
  1386. +#define EOR ANTLR3_TOKEN_EOR
  1387. +#define INVALID ANTLR3_TOKEN_INVALID
  1388. +
  1389. +
  1390. +/* =============================================================================
  1391. + * Functions to create and destroy scopes. First come the rule scopes, followed
  1392. + * by the global declared scopes.
  1393. + */
  1394. +
  1395. +
  1396. +
  1397. +/* ============================================================================= */
  1398. +
  1399. +/* =============================================================================
  1400. + * Start of recognizer
  1401. + */
  1402. +
  1403. +
  1404. +/* Forward declare the locally static matching functions we have generated and any predicate functions.
  1405. + */
  1406. +static ANTLR3_INLINE void mQUOTE (pDAAPLexer ctx);
  1407. +static ANTLR3_INLINE void mLPAR (pDAAPLexer ctx);
  1408. +static ANTLR3_INLINE void mRPAR (pDAAPLexer ctx);
  1409. +static ANTLR3_INLINE void mOPAND (pDAAPLexer ctx);
  1410. +static ANTLR3_INLINE void mOPOR (pDAAPLexer ctx);
  1411. +static ANTLR3_INLINE void mNEWLINE (pDAAPLexer ctx);
  1412. +static ANTLR3_INLINE void mSTR (pDAAPLexer ctx);
  1413. +static ANTLR3_INLINE void mESCAPED (pDAAPLexer ctx);
  1414. +static ANTLR3_INLINE void mTokens (pDAAPLexer ctx);
  1415. +static void DAAPLexerFree(pDAAPLexer ctx);
  1416. +
  1417. +/* =========================================================================
  1418. + * Lexer matching rules end.
  1419. + * =========================================================================
  1420. + */
  1421. +
  1422. +
  1423. +
  1424. +static void
  1425. +DAAPLexerFree (pDAAPLexer ctx)
  1426. +{
  1427. + LEXER->free(LEXER);
  1428. +
  1429. + ANTLR3_FREE(ctx);
  1430. +}
  1431. +
  1432. +/** \brief Name of the grammar file that generated this code
  1433. + */
  1434. +static const char fileName[] = "DAAP.g";
  1435. +
  1436. +/** \brief Return the name of the grammar file that generated this code.
  1437. + */
  1438. +static const char * getGrammarFileName()
  1439. +{
  1440. + return fileName;
  1441. +}
  1442. +
  1443. +/** \brief Create a new lexer called DAAPLexer
  1444. + *
  1445. + * \param[in] instream Pointer to an initialized input stream
  1446. + * \return
  1447. + * - Success pDAAPLexer initialized for the lex start
  1448. + * - Fail NULL
  1449. + */
  1450. +ANTLR3_API pDAAPLexer DAAPLexerNew
  1451. +(pANTLR3_INPUT_STREAM instream)
  1452. +{
  1453. + // See if we can create a new lexer with the standard constructor
  1454. + //
  1455. + return DAAPLexerNewSSD(instream, NULL);
  1456. +}
  1457. +
  1458. +/** \brief Create a new lexer called DAAPLexer
  1459. + *
  1460. + * \param[in] instream Pointer to an initialized input stream
  1461. + * \param[state] state Previously created shared recognizer stat
  1462. + * \return
  1463. + * - Success pDAAPLexer initialized for the lex start
  1464. + * - Fail NULL
  1465. + */
  1466. +ANTLR3_API pDAAPLexer DAAPLexerNewSSD
  1467. +(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
  1468. +{
  1469. + pDAAPLexer ctx; // Context structure we will build and return
  1470. +
  1471. + ctx = (pDAAPLexer) ANTLR3_CALLOC(1, sizeof(DAAPLexer));
  1472. +
  1473. + if (ctx == NULL)
  1474. + {
  1475. + // Failed to allocate memory for lexer context
  1476. + return NULL;
  1477. + }
  1478. +
  1479. + /* -------------------------------------------------------------------
  1480. + * Memory for basic structure is allocated, now to fill in
  1481. + * in base ANTLR3 structures. We initialize the function pointers
  1482. + * for the standard ANTLR3 lexer function set, but upon return
  1483. + * from here, the programmer may set the pointers to provide custom
  1484. + * implementations of each function.
  1485. + *
  1486. + * We don't use the macros defined in DAAPLexer.h here so you can get a sense
  1487. + * of what goes where.
  1488. + */
  1489. +
  1490. + /* Create a base lexer, using the supplied input stream
  1491. + */
  1492. + ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state);
  1493. +
  1494. + /* Check that we allocated the memory correctly
  1495. + */
  1496. + if (ctx->pLexer == NULL)
  1497. + {
  1498. + ANTLR3_FREE(ctx);
  1499. + return NULL;
  1500. + }
  1501. + /* Install the implementation of our DAAPLexer interface
  1502. + */
  1503. + ctx->mQUOTE = mQUOTE;
  1504. + ctx->mLPAR = mLPAR;
  1505. + ctx->mRPAR = mRPAR;
  1506. + ctx->mOPAND = mOPAND;
  1507. + ctx->mOPOR = mOPOR;
  1508. + ctx->mNEWLINE = mNEWLINE;
  1509. + ctx->mSTR = mSTR;
  1510. + ctx->mESCAPED = mESCAPED;
  1511. + ctx->mTokens = mTokens;
  1512. +
  1513. + /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE
  1514. + * it will call mTokens() in this generated code, and will pass it the ctx
  1515. + * pointer of this lexer, not the context of the base lexer, so store that now.
  1516. + */
  1517. + ctx->pLexer->ctx = ctx;
  1518. +
  1519. + /**Install the token matching function
  1520. + */
  1521. + ctx->pLexer->mTokens = (void (*) (void *))(mTokens);
  1522. +
  1523. + ctx->getGrammarFileName = getGrammarFileName;
  1524. + ctx->free = DAAPLexerFree;
  1525. +
  1526. +
  1527. +
  1528. +
  1529. +
  1530. + /* Return the newly built lexer to the caller
  1531. + */
  1532. + return ctx;
  1533. +}
  1534. +
  1535. +
  1536. +/* =========================================================================
  1537. + * Functions to match the lexer grammar defined tokens from the input stream
  1538. + */
  1539. +
  1540. +// Comes from: 40:7: ( '\\'' )
  1541. +/** \brief Lexer rule generated by ANTLR3
  1542. + *
  1543. + * $ANTLR start QUOTE
  1544. + *
  1545. + * Looks to match the characters the constitute the token QUOTE
  1546. + * from the attached input stream.
  1547. + *
  1548. + *
  1549. + * \remark
  1550. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  1551. + */
  1552. +static ANTLR3_INLINE
  1553. +void mQUOTE(pDAAPLexer ctx)
  1554. +{
  1555. + ANTLR3_UINT32 _type;
  1556. +
  1557. + _type = QUOTE;
  1558. +
  1559. +
  1560. + // DAAP.g:40:7: ( '\\'' )
  1561. + // DAAP.g:40:9: '\\''
  1562. + {
  1563. + MATCHC('\'');
  1564. + if (HASEXCEPTION())
  1565. + {
  1566. + goto ruleQUOTEEx;
  1567. + }
  1568. +
  1569. +
  1570. + }
  1571. +
  1572. + LEXSTATE->type = _type;
  1573. +
  1574. + // This is where rules clean up and exit
  1575. + //
  1576. + goto ruleQUOTEEx; /* Prevent compiler warnings */
  1577. + ruleQUOTEEx: ;
  1578. +
  1579. +}
  1580. +// $ANTLR end QUOTE
  1581. +
  1582. +// Comes from: 41:6: ( '(' )
  1583. +/** \brief Lexer rule generated by ANTLR3
  1584. + *
  1585. + * $ANTLR start LPAR
  1586. + *
  1587. + * Looks to match the characters the constitute the token LPAR
  1588. + * from the attached input stream.
  1589. + *
  1590. + *
  1591. + * \remark
  1592. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  1593. + */
  1594. +static ANTLR3_INLINE
  1595. +void mLPAR(pDAAPLexer ctx)
  1596. +{
  1597. + ANTLR3_UINT32 _type;
  1598. +
  1599. + _type = LPAR;
  1600. +
  1601. +
  1602. + // DAAP.g:41:6: ( '(' )
  1603. + // DAAP.g:41:8: '('
  1604. + {
  1605. + MATCHC('(');
  1606. + if (HASEXCEPTION())
  1607. + {
  1608. + goto ruleLPAREx;
  1609. + }
  1610. +
  1611. +
  1612. + }
  1613. +
  1614. + LEXSTATE->type = _type;
  1615. +
  1616. + // This is where rules clean up and exit
  1617. + //
  1618. + goto ruleLPAREx; /* Prevent compiler warnings */
  1619. + ruleLPAREx: ;
  1620. +
  1621. +}
  1622. +// $ANTLR end LPAR
  1623. +
  1624. +// Comes from: 42:6: ( ')' )
  1625. +/** \brief Lexer rule generated by ANTLR3
  1626. + *
  1627. + * $ANTLR start RPAR
  1628. + *
  1629. + * Looks to match the characters the constitute the token RPAR
  1630. + * from the attached input stream.
  1631. + *
  1632. + *
  1633. + * \remark
  1634. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  1635. + */
  1636. +static ANTLR3_INLINE
  1637. +void mRPAR(pDAAPLexer ctx)
  1638. +{
  1639. + ANTLR3_UINT32 _type;
  1640. +
  1641. + _type = RPAR;
  1642. +
  1643. +
  1644. + // DAAP.g:42:6: ( ')' )
  1645. + // DAAP.g:42:8: ')'
  1646. + {
  1647. + MATCHC(')');
  1648. + if (HASEXCEPTION())
  1649. + {
  1650. + goto ruleRPAREx;
  1651. + }
  1652. +
  1653. +
  1654. + }
  1655. +
  1656. + LEXSTATE->type = _type;
  1657. +
  1658. + // This is where rules clean up and exit
  1659. + //
  1660. + goto ruleRPAREx; /* Prevent compiler warnings */
  1661. + ruleRPAREx: ;
  1662. +
  1663. +}
  1664. +// $ANTLR end RPAR
  1665. +
  1666. +// Comes from: 44:7: ( '+' | ' ' )
  1667. +/** \brief Lexer rule generated by ANTLR3
  1668. + *
  1669. + * $ANTLR start OPAND
  1670. + *
  1671. + * Looks to match the characters the constitute the token OPAND
  1672. + * from the attached input stream.
  1673. + *
  1674. + *
  1675. + * \remark
  1676. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  1677. + */
  1678. +static ANTLR3_INLINE
  1679. +void mOPAND(pDAAPLexer ctx)
  1680. +{
  1681. + ANTLR3_UINT32 _type;
  1682. +
  1683. + _type = OPAND;
  1684. +
  1685. +
  1686. + // DAAP.g:44:7: ( '+' | ' ' )
  1687. + // DAAP.g:
  1688. + {
  1689. + if ( LA(1) == ' ' || LA(1) == '+' )
  1690. + {
  1691. + CONSUME();
  1692. +
  1693. + }
  1694. + else
  1695. + {
  1696. + CONSTRUCTEX();
  1697. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  1698. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  1699. +
  1700. + LRECOVER(); goto ruleOPANDEx;
  1701. + }
  1702. +
  1703. +
  1704. + }
  1705. +
  1706. + LEXSTATE->type = _type;
  1707. +
  1708. + // This is where rules clean up and exit
  1709. + //
  1710. + goto ruleOPANDEx; /* Prevent compiler warnings */
  1711. + ruleOPANDEx: ;
  1712. +
  1713. +}
  1714. +// $ANTLR end OPAND
  1715. +
  1716. +// Comes from: 45:6: ( ',' )
  1717. +/** \brief Lexer rule generated by ANTLR3
  1718. + *
  1719. + * $ANTLR start OPOR
  1720. + *
  1721. + * Looks to match the characters the constitute the token OPOR
  1722. + * from the attached input stream.
  1723. + *
  1724. + *
  1725. + * \remark
  1726. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  1727. + */
  1728. +static ANTLR3_INLINE
  1729. +void mOPOR(pDAAPLexer ctx)
  1730. +{
  1731. + ANTLR3_UINT32 _type;
  1732. +
  1733. + _type = OPOR;
  1734. +
  1735. +
  1736. + // DAAP.g:45:6: ( ',' )
  1737. + // DAAP.g:45:8: ','
  1738. + {
  1739. + MATCHC(',');
  1740. + if (HASEXCEPTION())
  1741. + {
  1742. + goto ruleOPOREx;
  1743. + }
  1744. +
  1745. +
  1746. + }
  1747. +
  1748. + LEXSTATE->type = _type;
  1749. +
  1750. + // This is where rules clean up and exit
  1751. + //
  1752. + goto ruleOPOREx; /* Prevent compiler warnings */
  1753. + ruleOPOREx: ;
  1754. +
  1755. +}
  1756. +// $ANTLR end OPOR
  1757. +
  1758. +// Comes from: 47:9: ( ( '\\r' )? '\\n' )
  1759. +/** \brief Lexer rule generated by ANTLR3
  1760. + *
  1761. + * $ANTLR start NEWLINE
  1762. + *
  1763. + * Looks to match the characters the constitute the token NEWLINE
  1764. + * from the attached input stream.
  1765. + *
  1766. + *
  1767. + * \remark
  1768. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  1769. + */
  1770. +static ANTLR3_INLINE
  1771. +void mNEWLINE(pDAAPLexer ctx)
  1772. +{
  1773. + ANTLR3_UINT32 _type;
  1774. +
  1775. + _type = NEWLINE;
  1776. +
  1777. +
  1778. + // DAAP.g:47:9: ( ( '\\r' )? '\\n' )
  1779. + // DAAP.g:47:11: ( '\\r' )? '\\n'
  1780. + {
  1781. +
  1782. + // DAAP.g:47:11: ( '\\r' )?
  1783. + {
  1784. + int alt1=2;
  1785. + switch ( LA(1) )
  1786. + {
  1787. + case '\r':
  1788. + {
  1789. + alt1=1;
  1790. + }
  1791. + break;
  1792. + }
  1793. +
  1794. + switch (alt1)
  1795. + {
  1796. + case 1:
  1797. + // DAAP.g:47:11: '\\r'
  1798. + {
  1799. + MATCHC('\r');
  1800. + if (HASEXCEPTION())
  1801. + {
  1802. + goto ruleNEWLINEEx;
  1803. + }
  1804. +
  1805. +
  1806. + }
  1807. + break;
  1808. +
  1809. + }
  1810. + }
  1811. + MATCHC('\n');
  1812. + if (HASEXCEPTION())
  1813. + {
  1814. + goto ruleNEWLINEEx;
  1815. + }
  1816. +
  1817. +
  1818. + }
  1819. +
  1820. + LEXSTATE->type = _type;
  1821. +
  1822. + // This is where rules clean up and exit
  1823. + //
  1824. + goto ruleNEWLINEEx; /* Prevent compiler warnings */
  1825. + ruleNEWLINEEx: ;
  1826. +
  1827. +}
  1828. +// $ANTLR end NEWLINE
  1829. +
  1830. +// Comes from: 55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE )
  1831. +/** \brief Lexer rule generated by ANTLR3
  1832. + *
  1833. + * $ANTLR start STR
  1834. + *
  1835. + * Looks to match the characters the constitute the token STR
  1836. + * from the attached input stream.
  1837. + *
  1838. + *
  1839. + * \remark
  1840. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  1841. + */
  1842. +static ANTLR3_INLINE
  1843. +void mSTR(pDAAPLexer ctx)
  1844. +{
  1845. + ANTLR3_UINT32 _type;
  1846. + pANTLR3_COMMON_TOKEN esc;
  1847. + ANTLR3_UINT32 reg;
  1848. +
  1849. +
  1850. + esc = NULL;
  1851. +
  1852. + _type = STR;
  1853. +
  1854. + pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory);
  1855. +
  1856. + // DAAP.g:55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE )
  1857. + // DAAP.g:55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE
  1858. + {
  1859. + /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */
  1860. + mQUOTE(ctx );
  1861. + if (HASEXCEPTION())
  1862. + {
  1863. + goto ruleSTREx;
  1864. + }
  1865. +
  1866. + // DAAP.g:55:10: (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+
  1867. + {
  1868. + int cnt2=0;
  1869. +
  1870. + for (;;)
  1871. + {
  1872. + int alt2=3;
  1873. + {
  1874. + /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState)
  1875. + */
  1876. + int LA2_0 = LA(1);
  1877. + if ( (((LA2_0 >= 0x0000) && (LA2_0 <= '&')) || ((LA2_0 >= '(') && (LA2_0 <= '[')) || ((LA2_0 >= ']') && (LA2_0 <= 0xFFFF))) )
  1878. + {
  1879. + alt2=1;
  1880. + }
  1881. + else if ( (LA2_0 == '\\') )
  1882. + {
  1883. + alt2=2;
  1884. + }
  1885. +
  1886. + }
  1887. + switch (alt2)
  1888. + {
  1889. + case 1:
  1890. + // DAAP.g:55:12: reg=~ ( '\\\\' | '\\'' )
  1891. + {
  1892. + reg= LA(1);
  1893. + if ( ((LA(1) >= 0x0000) && (LA(1) <= '&')) || ((LA(1) >= '(') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) )
  1894. + {
  1895. + CONSUME();
  1896. +
  1897. + }
  1898. + else
  1899. + {
  1900. + CONSTRUCTEX();
  1901. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  1902. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  1903. +
  1904. + LRECOVER(); goto ruleSTREx;
  1905. + }
  1906. +
  1907. + {
  1908. + unesc->addc(unesc, reg);
  1909. + }
  1910. +
  1911. + }
  1912. + break;
  1913. + case 2:
  1914. + // DAAP.g:56:6: esc= ESCAPED
  1915. + {
  1916. + /* 56:6: esc= ESCAPED */
  1917. + {
  1918. + ANTLR3_MARKER escStart118 = GETCHARINDEX();
  1919. + mESCAPED(ctx );
  1920. + if (HASEXCEPTION())
  1921. + {
  1922. + goto ruleSTREx;
  1923. + }
  1924. +
  1925. + esc = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory);
  1926. + esc->setType(esc, ANTLR3_TOKEN_INVALID);
  1927. + esc->setStartIndex(esc, escStart118);
  1928. + esc->setStopIndex(esc, GETCHARINDEX()-1);
  1929. + esc->input = INPUT;
  1930. + }
  1931. + {
  1932. + unesc->appendS(unesc, GETTEXT());
  1933. + }
  1934. +
  1935. + }
  1936. + break;
  1937. +
  1938. + default:
  1939. +
  1940. + if ( cnt2 >= 1 )
  1941. + {
  1942. + goto loop2;
  1943. + }
  1944. + /* mismatchedSetEx()
  1945. + */
  1946. + CONSTRUCTEX();
  1947. + EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
  1948. + EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;
  1949. +
  1950. +
  1951. + goto ruleSTREx;
  1952. + }
  1953. + cnt2++;
  1954. + }
  1955. + loop2: ; /* Jump to here if this rule does not match */
  1956. + }
  1957. + /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */
  1958. + mQUOTE(ctx );
  1959. + if (HASEXCEPTION())
  1960. + {
  1961. + goto ruleSTREx;
  1962. + }
  1963. +
  1964. + {
  1965. + SETTEXT(unesc);
  1966. + }
  1967. +
  1968. + }
  1969. +
  1970. + LEXSTATE->type = _type;
  1971. +
  1972. + // This is where rules clean up and exit
  1973. + //
  1974. + goto ruleSTREx; /* Prevent compiler warnings */
  1975. + ruleSTREx: ;
  1976. +
  1977. + esc = NULL;
  1978. +
  1979. +}
  1980. +// $ANTLR end STR
  1981. +
  1982. +// Comes from: 59:9: ( '\\\\' ( '\\\\' | '\\'' ) )
  1983. +/** \brief Lexer rule generated by ANTLR3
  1984. + *
  1985. + * $ANTLR start ESCAPED
  1986. + *
  1987. + * Looks to match the characters the constitute the token ESCAPED
  1988. + * from the attached input stream.
  1989. + *
  1990. + *
  1991. + * \remark
  1992. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  1993. + */
  1994. +static ANTLR3_INLINE
  1995. +void mESCAPED(pDAAPLexer ctx)
  1996. +{
  1997. + ANTLR3_UINT32 _type;
  1998. +
  1999. +
  2000. + // DAAP.g:59:9: ( '\\\\' ( '\\\\' | '\\'' ) )
  2001. + // DAAP.g:59:11: '\\\\' ( '\\\\' | '\\'' )
  2002. + {
  2003. + MATCHC('\\');
  2004. + if (HASEXCEPTION())
  2005. + {
  2006. + goto ruleESCAPEDEx;
  2007. + }
  2008. +
  2009. +
  2010. + // DAAP.g:60:3: ( '\\\\' | '\\'' )
  2011. + {
  2012. + int alt3=2;
  2013. + switch ( LA(1) )
  2014. + {
  2015. + case '\\':
  2016. + {
  2017. + alt3=1;
  2018. + }
  2019. + break;
  2020. + case '\'':
  2021. + {
  2022. + alt3=2;
  2023. + }
  2024. + break;
  2025. +
  2026. + default:
  2027. + CONSTRUCTEX();
  2028. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  2029. + EXCEPTION->message = (void *)"";
  2030. + EXCEPTION->decisionNum = 3;
  2031. + EXCEPTION->state = 0;
  2032. +
  2033. +
  2034. + goto ruleESCAPEDEx;
  2035. + }
  2036. +
  2037. + switch (alt3)
  2038. + {
  2039. + case 1:
  2040. + // DAAP.g:60:5: '\\\\'
  2041. + {
  2042. + MATCHC('\\');
  2043. + if (HASEXCEPTION())
  2044. + {
  2045. + goto ruleESCAPEDEx;
  2046. + }
  2047. +
  2048. + {
  2049. + SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\"));
  2050. + }
  2051. +
  2052. + }
  2053. + break;
  2054. + case 2:
  2055. + // DAAP.g:61:5: '\\''
  2056. + {
  2057. + MATCHC('\'');
  2058. + if (HASEXCEPTION())
  2059. + {
  2060. + goto ruleESCAPEDEx;
  2061. + }
  2062. +
  2063. + {
  2064. + SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\'"));
  2065. + }
  2066. +
  2067. + }
  2068. + break;
  2069. +
  2070. + }
  2071. + }
  2072. +
  2073. + }
  2074. +
  2075. +
  2076. +
  2077. + // This is where rules clean up and exit
  2078. + //
  2079. + goto ruleESCAPEDEx; /* Prevent compiler warnings */
  2080. + ruleESCAPEDEx: ;
  2081. +
  2082. +}
  2083. +// $ANTLR end ESCAPED
  2084. +
  2085. +/** This is the entry point in to the lexer from an object that
  2086. + * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM
  2087. + */
  2088. +static void
  2089. +mTokens(pDAAPLexer ctx)
  2090. +{
  2091. + {
  2092. + // DAAP.g:1:8: ( QUOTE | LPAR | RPAR | OPAND | OPOR | NEWLINE | STR )
  2093. +
  2094. + ANTLR3_UINT32 alt4;
  2095. +
  2096. + alt4=7;
  2097. +
  2098. + switch ( LA(1) )
  2099. + {
  2100. + case '\'':
  2101. + {
  2102. +
  2103. + {
  2104. + int LA4_1 = LA(2);
  2105. + if ( (((LA4_1 >= 0x0000) && (LA4_1 <= '&')) || ((LA4_1 >= '(') && (LA4_1 <= 0xFFFF))) )
  2106. + {
  2107. + alt4=7;
  2108. + }
  2109. + else
  2110. + {
  2111. + alt4=1; }
  2112. + }
  2113. + }
  2114. + break;
  2115. + case '(':
  2116. + {
  2117. + alt4=2;
  2118. + }
  2119. + break;
  2120. + case ')':
  2121. + {
  2122. + alt4=3;
  2123. + }
  2124. + break;
  2125. + case ' ':
  2126. + case '+':
  2127. + {
  2128. + alt4=4;
  2129. + }
  2130. + break;
  2131. + case ',':
  2132. + {
  2133. + alt4=5;
  2134. + }
  2135. + break;
  2136. + case '\n':
  2137. + case '\r':
  2138. + {
  2139. + alt4=6;
  2140. + }
  2141. + break;
  2142. +
  2143. + default:
  2144. + CONSTRUCTEX();
  2145. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  2146. + EXCEPTION->message = (void *)"";
  2147. + EXCEPTION->decisionNum = 4;
  2148. + EXCEPTION->state = 0;
  2149. +
  2150. +
  2151. + goto ruleTokensEx;
  2152. + }
  2153. +
  2154. + switch (alt4)
  2155. + {
  2156. + case 1:
  2157. + // DAAP.g:1:10: QUOTE
  2158. + {
  2159. + /* 1:10: QUOTE */
  2160. + mQUOTE(ctx );
  2161. + if (HASEXCEPTION())
  2162. + {
  2163. + goto ruleTokensEx;
  2164. + }
  2165. +
  2166. +
  2167. + }
  2168. + break;
  2169. + case 2:
  2170. + // DAAP.g:1:16: LPAR
  2171. + {
  2172. + /* 1:16: LPAR */
  2173. + mLPAR(ctx );
  2174. + if (HASEXCEPTION())
  2175. + {
  2176. + goto ruleTokensEx;
  2177. + }
  2178. +
  2179. +
  2180. + }
  2181. + break;
  2182. + case 3:
  2183. + // DAAP.g:1:21: RPAR
  2184. + {
  2185. + /* 1:21: RPAR */
  2186. + mRPAR(ctx );
  2187. + if (HASEXCEPTION())
  2188. + {
  2189. + goto ruleTokensEx;
  2190. + }
  2191. +
  2192. +
  2193. + }
  2194. + break;
  2195. + case 4:
  2196. + // DAAP.g:1:26: OPAND
  2197. + {
  2198. + /* 1:26: OPAND */
  2199. + mOPAND(ctx );
  2200. + if (HASEXCEPTION())
  2201. + {
  2202. + goto ruleTokensEx;
  2203. + }
  2204. +
  2205. +
  2206. + }
  2207. + break;
  2208. + case 5:
  2209. + // DAAP.g:1:32: OPOR
  2210. + {
  2211. + /* 1:32: OPOR */
  2212. + mOPOR(ctx );
  2213. + if (HASEXCEPTION())
  2214. + {
  2215. + goto ruleTokensEx;
  2216. + }
  2217. +
  2218. +
  2219. + }
  2220. + break;
  2221. + case 6:
  2222. + // DAAP.g:1:37: NEWLINE
  2223. + {
  2224. + /* 1:37: NEWLINE */
  2225. + mNEWLINE(ctx );
  2226. + if (HASEXCEPTION())
  2227. + {
  2228. + goto ruleTokensEx;
  2229. + }
  2230. +
  2231. +
  2232. + }
  2233. + break;
  2234. + case 7:
  2235. + // DAAP.g:1:45: STR
  2236. + {
  2237. + /* 1:45: STR */
  2238. + mSTR(ctx );
  2239. + if (HASEXCEPTION())
  2240. + {
  2241. + goto ruleTokensEx;
  2242. + }
  2243. +
  2244. +
  2245. + }
  2246. + break;
  2247. +
  2248. + }
  2249. + }
  2250. +
  2251. +
  2252. + goto ruleTokensEx; /* Prevent compiler warnings */
  2253. +ruleTokensEx: ;
  2254. +}
  2255. +
  2256. +/* =========================================================================
  2257. + * Lexer matching rules end.
  2258. + * =========================================================================
  2259. + */
  2260. +/* End of Lexer code
  2261. + * ================================================
  2262. + * ================================================
  2263. + */
  2264. +
  2265. +
  2266. +/* End of code
  2267. + * =============================================================================
  2268. + */
  2269. diff --git a/src/pregen/DAAPLexer.h b/src/pregen/DAAPLexer.h
  2270. new file mode 100644
  2271. index 0000000..ba8f58b
  2272. --- /dev/null
  2273. +++ b/src/pregen/DAAPLexer.h
  2274. @@ -0,0 +1,188 @@
  2275. +/** \file
  2276. + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
  2277. + *
  2278. + * - From the grammar source file : DAAP.g
  2279. + * - On : 2014-09-30 21:42:40
  2280. + * - for the lexer : DAAPLexerLexer *
  2281. + * Editing it, at least manually, is not wise.
  2282. + *
  2283. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  2284. + *
  2285. + *
  2286. + * The lexer DAAPLexer has the callable functions (rules) shown below,
  2287. + * which will invoke the code for the associated rule in the source grammar
  2288. + * assuming that the input stream is pointing to a token/text stream that could begin
  2289. + * this rule.
  2290. + *
  2291. + * For instance if you call the first (topmost) rule in a parser grammar, you will
  2292. + * get the results of a full parse, but calling a rule half way through the grammar will
  2293. + * allow you to pass part of a full token stream to the parser, such as for syntax checking
  2294. + * in editors and so on.
  2295. + *
  2296. + * The parser entry points are called indirectly (by function pointer to function) via
  2297. + * a parser context typedef pDAAPLexer, which is returned from a call to DAAPLexerNew().
  2298. + *
  2299. + * As this is a generated lexer, it is unlikely you will call it 'manually'. However
  2300. + * the methods are provided anyway.
  2301. + * * The methods in pDAAPLexer are as follows:
  2302. + *
  2303. + * - void pDAAPLexer->QUOTE(pDAAPLexer)
  2304. + * - void pDAAPLexer->LPAR(pDAAPLexer)
  2305. + * - void pDAAPLexer->RPAR(pDAAPLexer)
  2306. + * - void pDAAPLexer->OPAND(pDAAPLexer)
  2307. + * - void pDAAPLexer->OPOR(pDAAPLexer)
  2308. + * - void pDAAPLexer->NEWLINE(pDAAPLexer)
  2309. + * - void pDAAPLexer->STR(pDAAPLexer)
  2310. + * - void pDAAPLexer->ESCAPED(pDAAPLexer)
  2311. + * - void pDAAPLexer->Tokens(pDAAPLexer)
  2312. + *
  2313. + * The return type for any particular rule is of course determined by the source
  2314. + * grammar file.
  2315. + */
  2316. +// [The "BSD licence"]
  2317. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  2318. +// http://www.temporal-wave.com
  2319. +// http://www.linkedin.com/in/jimidle
  2320. +//
  2321. +// All rights reserved.
  2322. +//
  2323. +// Redistribution and use in source and binary forms, with or without
  2324. +// modification, are permitted provided that the following conditions
  2325. +// are met:
  2326. +// 1. Redistributions of source code must retain the above copyright
  2327. +// notice, this list of conditions and the following disclaimer.
  2328. +// 2. Redistributions in binary form must reproduce the above copyright
  2329. +// notice, this list of conditions and the following disclaimer in the
  2330. +// documentation and/or other materials provided with the distribution.
  2331. +// 3. The name of the author may not be used to endorse or promote products
  2332. +// derived from this software without specific prior written permission.
  2333. +//
  2334. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  2335. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  2336. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  2337. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  2338. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  2339. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  2340. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2341. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2342. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  2343. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2344. +
  2345. +#ifndef _DAAPLexer_H
  2346. +#define _DAAPLexer_H
  2347. +/* =============================================================================
  2348. + * Standard antlr3 C runtime definitions
  2349. + */
  2350. +#include <antlr3.h>
  2351. +
  2352. +/* End of standard antlr 3 runtime definitions
  2353. + * =============================================================================
  2354. + */
  2355. +
  2356. +#ifdef __cplusplus
  2357. +extern "C" {
  2358. +#endif
  2359. +
  2360. +// Forward declare the context typedef so that we can use it before it is
  2361. +// properly defined. Delegators and delegates (from import statements) are
  2362. +// interdependent and their context structures contain pointers to each other
  2363. +// C only allows such things to be declared if you pre-declare the typedef.
  2364. +//
  2365. +typedef struct DAAPLexer_Ctx_struct DAAPLexer, * pDAAPLexer;
  2366. +
  2367. +
  2368. +
  2369. +#ifdef ANTLR3_WINDOWS
  2370. +// Disable: Unreferenced parameter, - Rules with parameters that are not used
  2371. +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
  2372. +// initialized but unused variable - tree rewrite variables declared but not needed
  2373. +// Unreferenced local variable - lexer rule declares but does not always use _type
  2374. +// potentially unitialized variable used - retval always returned from a rule
  2375. +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
  2376. +//
  2377. +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
  2378. +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
  2379. +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
  2380. +// this is a matter of orthogonality hence I disable that one.
  2381. +//
  2382. +#pragma warning( disable : 4100 )
  2383. +#pragma warning( disable : 4101 )
  2384. +#pragma warning( disable : 4127 )
  2385. +#pragma warning( disable : 4189 )
  2386. +#pragma warning( disable : 4505 )
  2387. +#pragma warning( disable : 4701 )
  2388. +#endif
  2389. +
  2390. +/** Context tracking structure for DAAPLexer
  2391. + */
  2392. +struct DAAPLexer_Ctx_struct
  2393. +{
  2394. + /** Built in ANTLR3 context tracker contains all the generic elements
  2395. + * required for context tracking.
  2396. + */
  2397. + pANTLR3_LEXER pLexer;
  2398. +
  2399. +
  2400. + void (*mQUOTE) (struct DAAPLexer_Ctx_struct * ctx);
  2401. + void (*mLPAR) (struct DAAPLexer_Ctx_struct * ctx);
  2402. + void (*mRPAR) (struct DAAPLexer_Ctx_struct * ctx);
  2403. + void (*mOPAND) (struct DAAPLexer_Ctx_struct * ctx);
  2404. + void (*mOPOR) (struct DAAPLexer_Ctx_struct * ctx);
  2405. + void (*mNEWLINE) (struct DAAPLexer_Ctx_struct * ctx);
  2406. + void (*mSTR) (struct DAAPLexer_Ctx_struct * ctx);
  2407. + void (*mESCAPED) (struct DAAPLexer_Ctx_struct * ctx);
  2408. + void (*mTokens) (struct DAAPLexer_Ctx_struct * ctx); const char * (*getGrammarFileName)();
  2409. + void (*free) (struct DAAPLexer_Ctx_struct * ctx);
  2410. +
  2411. +};
  2412. +
  2413. +// Function protoypes for the constructor functions that external translation units
  2414. +// such as delegators and delegates may wish to call.
  2415. +//
  2416. +ANTLR3_API pDAAPLexer DAAPLexerNew (pANTLR3_INPUT_STREAM instream);
  2417. +ANTLR3_API pDAAPLexer DAAPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
  2418. +
  2419. +/** Symbolic definitions of all the tokens that the lexer will work with.
  2420. + * \{
  2421. + *
  2422. + * Antlr will define EOF, but we can't use that as it it is too common in
  2423. + * in C header files and that would be confusing. There is no way to filter this out at the moment
  2424. + * so we just undef it here for now. That isn't the value we get back from C recognizers
  2425. + * anyway. We are looking for ANTLR3_TOKEN_EOF.
  2426. + */
  2427. +#ifdef EOF
  2428. +#undef EOF
  2429. +#endif
  2430. +#ifdef Tokens
  2431. +#undef Tokens
  2432. +#endif
  2433. +#define STR 9
  2434. +#define QUOTE 10
  2435. +#define NEWLINE 4
  2436. +#define LPAR 7
  2437. +#define OPOR 5
  2438. +#define RPAR 8
  2439. +#define ESCAPED 11
  2440. +#define OPAND 6
  2441. +#define EOF -1
  2442. +#ifdef EOF
  2443. +#undef EOF
  2444. +#define EOF ANTLR3_TOKEN_EOF
  2445. +#endif
  2446. +
  2447. +#ifndef TOKENSOURCE
  2448. +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
  2449. +#endif
  2450. +
  2451. +/* End of token definitions for DAAPLexer
  2452. + * =============================================================================
  2453. + */
  2454. +/** \} */
  2455. +
  2456. +#ifdef __cplusplus
  2457. +}
  2458. +#endif
  2459. +
  2460. +#endif
  2461. +
  2462. +/* END - Note:Keep extra line feed to satisfy UNIX systems */
  2463. diff --git a/src/pregen/DAAPParser.c b/src/pregen/DAAPParser.c
  2464. new file mode 100644
  2465. index 0000000..6d0239d
  2466. --- /dev/null
  2467. +++ b/src/pregen/DAAPParser.c
  2468. @@ -0,0 +1,1014 @@
  2469. +/** \file
  2470. + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
  2471. + *
  2472. + * - From the grammar source file : DAAP.g
  2473. + * - On : 2014-09-30 21:42:39
  2474. + * - for the parser : DAAPParserParser *
  2475. + * Editing it, at least manually, is not wise.
  2476. + *
  2477. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  2478. + *
  2479. + *
  2480. +*/
  2481. +// [The "BSD licence"]
  2482. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  2483. +// http://www.temporal-wave.com
  2484. +// http://www.linkedin.com/in/jimidle
  2485. +//
  2486. +// All rights reserved.
  2487. +//
  2488. +// Redistribution and use in source and binary forms, with or without
  2489. +// modification, are permitted provided that the following conditions
  2490. +// are met:
  2491. +// 1. Redistributions of source code must retain the above copyright
  2492. +// notice, this list of conditions and the following disclaimer.
  2493. +// 2. Redistributions in binary form must reproduce the above copyright
  2494. +// notice, this list of conditions and the following disclaimer in the
  2495. +// documentation and/or other materials provided with the distribution.
  2496. +// 3. The name of the author may not be used to endorse or promote products
  2497. +// derived from this software without specific prior written permission.
  2498. +//
  2499. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  2500. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  2501. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  2502. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  2503. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  2504. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  2505. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2506. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2507. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  2508. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2509. +
  2510. +/* -----------------------------------------
  2511. + * Include the ANTLR3 generated header file.
  2512. + */
  2513. +#include "DAAPParser.h"
  2514. +/* ----------------------------------------- */
  2515. +
  2516. +
  2517. +
  2518. +
  2519. +
  2520. +/* MACROS that hide the C interface implementations from the
  2521. + * generated code, which makes it a little more understandable to the human eye.
  2522. + * I am very much against using C pre-processor macros for function calls and bits
  2523. + * of code as you cannot see what is happening when single stepping in debuggers
  2524. + * and so on. The exception (in my book at least) is for generated code, where you are
  2525. + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
  2526. + * hides some indirect calls, but is always referring to the input stream. This is
  2527. + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
  2528. + * the runtime interfaces without changing the generated code too often, without
  2529. + * confusing the reader of the generated output, who may not wish to know the gory
  2530. + * details of the interface inheritance.
  2531. + */
  2532. +
  2533. +#define CTX ctx
  2534. +
  2535. +/* Aids in accessing scopes for grammar programmers
  2536. + */
  2537. +#undef SCOPE_TYPE
  2538. +#undef SCOPE_STACK
  2539. +#undef SCOPE_TOP
  2540. +#define SCOPE_TYPE(scope) pDAAPParser_##scope##_SCOPE
  2541. +#define SCOPE_STACK(scope) pDAAPParser_##scope##Stack
  2542. +#define SCOPE_TOP(scope) ctx->pDAAPParser_##scope##Top
  2543. +#define SCOPE_SIZE(scope) ctx->pDAAPParser_##scope##Stack_limit
  2544. +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
  2545. +
  2546. +/* Macros for accessing things in the parser
  2547. + */
  2548. +
  2549. +#undef PARSER
  2550. +#undef RECOGNIZER
  2551. +#undef HAVEPARSEDRULE
  2552. +#undef MEMOIZE
  2553. +#undef INPUT
  2554. +#undef STRSTREAM
  2555. +#undef HASEXCEPTION
  2556. +#undef EXCEPTION
  2557. +#undef MATCHT
  2558. +#undef MATCHANYT
  2559. +#undef FOLLOWSTACK
  2560. +#undef FOLLOWPUSH
  2561. +#undef FOLLOWPOP
  2562. +#undef PRECOVER
  2563. +#undef PREPORTERROR
  2564. +#undef LA
  2565. +#undef LT
  2566. +#undef CONSTRUCTEX
  2567. +#undef CONSUME
  2568. +#undef MARK
  2569. +#undef REWIND
  2570. +#undef REWINDLAST
  2571. +#undef PERRORRECOVERY
  2572. +#undef HASFAILED
  2573. +#undef FAILEDFLAG
  2574. +#undef RECOVERFROMMISMATCHEDSET
  2575. +#undef RECOVERFROMMISMATCHEDELEMENT
  2576. +#undef INDEX
  2577. +#undef ADAPTOR
  2578. +#undef SEEK
  2579. +#undef RULEMEMO
  2580. +#undef DBG
  2581. +
  2582. +#define PARSER ctx->pParser
  2583. +#define RECOGNIZER PARSER->rec
  2584. +#define PSRSTATE RECOGNIZER->state
  2585. +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
  2586. +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
  2587. +#define INPUT PARSER->tstream
  2588. +#define STRSTREAM INPUT
  2589. +#define ISTREAM INPUT->istream
  2590. +#define INDEX() ISTREAM->index(INPUT->istream)
  2591. +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
  2592. +#define EXCEPTION PSRSTATE->exception
  2593. +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
  2594. +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
  2595. +#define FOLLOWSTACK PSRSTATE->following
  2596. +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
  2597. +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
  2598. +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
  2599. +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
  2600. +#define LA(n) INPUT->istream->_LA(ISTREAM, n)
  2601. +#define LT(n) INPUT->_LT(INPUT, n)
  2602. +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
  2603. +#define CONSUME() ISTREAM->consume(ISTREAM)
  2604. +#define MARK() ISTREAM->mark(ISTREAM)
  2605. +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
  2606. +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
  2607. +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
  2608. +#define PERRORRECOVERY PSRSTATE->errorRecovery
  2609. +#define FAILEDFLAG PSRSTATE->failed
  2610. +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
  2611. +#define BACKTRACKING PSRSTATE->backtracking
  2612. +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
  2613. +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
  2614. +#define ADAPTOR ctx->adaptor
  2615. +#define RULEMEMO PSRSTATE->ruleMemo
  2616. +#define DBG RECOGNIZER->debugger
  2617. +
  2618. +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
  2619. +
  2620. +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
  2621. + * then for the present you must use different names for your defines as these are hard coded
  2622. + * in the code generator. It would be better not to use such names internally, and maybe
  2623. + * we can change this in a forthcoming release. I deliberately do not #undef these
  2624. + * here as this will at least give you a redefined error somewhere if they clash.
  2625. + */
  2626. +#define UP ANTLR3_TOKEN_UP
  2627. +#define DOWN ANTLR3_TOKEN_DOWN
  2628. +#define EOR ANTLR3_TOKEN_EOR
  2629. +#define INVALID ANTLR3_TOKEN_INVALID
  2630. +
  2631. +
  2632. +/* =============================================================================
  2633. + * Functions to create and destroy scopes. First come the rule scopes, followed
  2634. + * by the global declared scopes.
  2635. + */
  2636. +
  2637. +
  2638. +
  2639. +/* ============================================================================= */
  2640. +
  2641. +/* =============================================================================
  2642. + * Start of recognizer
  2643. + */
  2644. +
  2645. +
  2646. +
  2647. +/** \brief Table of all token names in symbolic order, mainly used for
  2648. + * error reporting.
  2649. + */
  2650. +pANTLR3_UINT8 DAAPParserTokenNames[8+4]
  2651. + = {
  2652. + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
  2653. + (pANTLR3_UINT8) "<EOR>",
  2654. + (pANTLR3_UINT8) "<DOWN>",
  2655. + (pANTLR3_UINT8) "<UP>",
  2656. + (pANTLR3_UINT8) "NEWLINE",
  2657. + (pANTLR3_UINT8) "OPOR",
  2658. + (pANTLR3_UINT8) "OPAND",
  2659. + (pANTLR3_UINT8) "LPAR",
  2660. + (pANTLR3_UINT8) "RPAR",
  2661. + (pANTLR3_UINT8) "STR",
  2662. + (pANTLR3_UINT8) "QUOTE",
  2663. + (pANTLR3_UINT8) "ESCAPED"
  2664. + };
  2665. +
  2666. +
  2667. +
  2668. +// Forward declare the locally static matching functions we have generated.
  2669. +//
  2670. +static DAAPParser_query_return query (pDAAPParser ctx);
  2671. +static DAAPParser_expr_return expr (pDAAPParser ctx);
  2672. +static DAAPParser_aexpr_return aexpr (pDAAPParser ctx);
  2673. +static DAAPParser_crit_return crit (pDAAPParser ctx);
  2674. +static void DAAPParserFree(pDAAPParser ctx);
  2675. +/* For use in tree output where we are accumulating rule labels via label += ruleRef
  2676. + * we need a function that knows how to free a return scope when the list is destroyed.
  2677. + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
  2678. + */
  2679. +static void ANTLR3_CDECL freeScope(void * scope)
  2680. +{
  2681. + ANTLR3_FREE(scope);
  2682. +}
  2683. +
  2684. +/** \brief Name of the grammar file that generated this code
  2685. + */
  2686. +static const char fileName[] = "DAAP.g";
  2687. +
  2688. +/** \brief Return the name of the grammar file that generated this code.
  2689. + */
  2690. +static const char * getGrammarFileName()
  2691. +{
  2692. + return fileName;
  2693. +}
  2694. +/** \brief Create a new DAAPParser parser and return a context for it.
  2695. + *
  2696. + * \param[in] instream Pointer to an input stream interface.
  2697. + *
  2698. + * \return Pointer to new parser context upon success.
  2699. + */
  2700. +ANTLR3_API pDAAPParser
  2701. +DAAPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream)
  2702. +{
  2703. + // See if we can create a new parser with the standard constructor
  2704. + //
  2705. + return DAAPParserNewSSD(instream, NULL);
  2706. +}
  2707. +
  2708. +/** \brief Create a new DAAPParser parser and return a context for it.
  2709. + *
  2710. + * \param[in] instream Pointer to an input stream interface.
  2711. + *
  2712. + * \return Pointer to new parser context upon success.
  2713. + */
  2714. +ANTLR3_API pDAAPParser
  2715. +DAAPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
  2716. +{
  2717. + pDAAPParser ctx; /* Context structure we will build and return */
  2718. +
  2719. + ctx = (pDAAPParser) ANTLR3_CALLOC(1, sizeof(DAAPParser));
  2720. +
  2721. + if (ctx == NULL)
  2722. + {
  2723. + // Failed to allocate memory for parser context
  2724. + //
  2725. + return NULL;
  2726. + }
  2727. +
  2728. + /* -------------------------------------------------------------------
  2729. + * Memory for basic structure is allocated, now to fill in
  2730. + * the base ANTLR3 structures. We initialize the function pointers
  2731. + * for the standard ANTLR3 parser function set, but upon return
  2732. + * from here, the programmer may set the pointers to provide custom
  2733. + * implementations of each function.
  2734. + *
  2735. + * We don't use the macros defined in DAAPParser.h here, in order that you can get a sense
  2736. + * of what goes where.
  2737. + */
  2738. +
  2739. + /* Create a base parser/recognizer, using the supplied token stream
  2740. + */
  2741. + ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state);
  2742. + /* Install the implementation of our DAAPParser interface
  2743. + */
  2744. + ctx->query = query;
  2745. + ctx->expr = expr;
  2746. + ctx->aexpr = aexpr;
  2747. + ctx->crit = crit;
  2748. + ctx->free = DAAPParserFree;
  2749. + ctx->getGrammarFileName = getGrammarFileName;
  2750. +
  2751. + /* Install the scope pushing methods.
  2752. + */
  2753. + ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory);
  2754. + ctx->vectors = antlr3VectorFactoryNew(0);
  2755. +
  2756. +
  2757. +
  2758. + /* Install the token table
  2759. + */
  2760. + PSRSTATE->tokenNames = DAAPParserTokenNames;
  2761. +
  2762. +
  2763. + /* Return the newly built parser to the caller
  2764. + */
  2765. + return ctx;
  2766. +}
  2767. +
  2768. +/** Free the parser resources
  2769. + */
  2770. + static void
  2771. + DAAPParserFree(pDAAPParser ctx)
  2772. + {
  2773. + /* Free any scope memory
  2774. + */
  2775. +
  2776. + ctx->vectors->close(ctx->vectors);
  2777. + /* We created the adaptor so we must free it
  2778. + */
  2779. + ADAPTOR->free(ADAPTOR);
  2780. + // Free this parser
  2781. + //
  2782. + ctx->pParser->free(ctx->pParser);
  2783. + ANTLR3_FREE(ctx);
  2784. +
  2785. + /* Everything is released, so we can return
  2786. + */
  2787. + return;
  2788. + }
  2789. +
  2790. +/** Return token names used by this parser
  2791. + *
  2792. + * The returned pointer is used as an index into the token names table (using the token
  2793. + * number as the index).
  2794. + *
  2795. + * \return Pointer to first char * in the table.
  2796. + */
  2797. +static pANTLR3_UINT8 *getTokenNames()
  2798. +{
  2799. + return DAAPParserTokenNames;
  2800. +}
  2801. +
  2802. +
  2803. +/* Declare the bitsets
  2804. + */
  2805. +
  2806. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42 */
  2807. +static ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) };
  2808. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_query42 = { FOLLOW_expr_in_query42_bits, 1 };
  2809. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44 */
  2810. +static ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000) };
  2811. +static ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44 = { FOLLOW_NEWLINE_in_query44_bits, 1 };
  2812. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47 */
  2813. +static ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  2814. +static ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47 = { FOLLOW_EOF_in_query47_bits, 1 };
  2815. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr62 */
  2816. +static ANTLR3_BITWORD FOLLOW_aexpr_in_expr62_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
  2817. +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr62 = { FOLLOW_aexpr_in_expr62_bits, 1 };
  2818. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPOR_in_expr65 */
  2819. +static ANTLR3_BITWORD FOLLOW_OPOR_in_expr65_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
  2820. +static ANTLR3_BITSET_LIST FOLLOW_OPOR_in_expr65 = { FOLLOW_OPOR_in_expr65_bits, 1 };
  2821. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr68 */
  2822. +static ANTLR3_BITWORD FOLLOW_aexpr_in_expr68_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
  2823. +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr68 = { FOLLOW_aexpr_in_expr68_bits, 1 };
  2824. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr80 */
  2825. +static ANTLR3_BITWORD FOLLOW_crit_in_aexpr80_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
  2826. +static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr80 = { FOLLOW_crit_in_aexpr80_bits, 1 };
  2827. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPAND_in_aexpr83 */
  2828. +static ANTLR3_BITWORD FOLLOW_OPAND_in_aexpr83_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
  2829. +static ANTLR3_BITSET_LIST FOLLOW_OPAND_in_aexpr83 = { FOLLOW_OPAND_in_aexpr83_bits, 1 };
  2830. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr86 */
  2831. +static ANTLR3_BITWORD FOLLOW_crit_in_aexpr86_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
  2832. +static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr86 = { FOLLOW_crit_in_aexpr86_bits, 1 };
  2833. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit98 */
  2834. +static ANTLR3_BITWORD FOLLOW_LPAR_in_crit98_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
  2835. +static ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit98 = { FOLLOW_LPAR_in_crit98_bits, 1 };
  2836. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit100 */
  2837. +static ANTLR3_BITWORD FOLLOW_expr_in_crit100_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000100) };
  2838. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_crit100 = { FOLLOW_expr_in_crit100_bits, 1 };
  2839. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit102 */
  2840. +static ANTLR3_BITWORD FOLLOW_RPAR_in_crit102_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  2841. +static ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit102 = { FOLLOW_RPAR_in_crit102_bits, 1 };
  2842. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_crit112 */
  2843. +static ANTLR3_BITWORD FOLLOW_STR_in_crit112_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  2844. +static ANTLR3_BITSET_LIST FOLLOW_STR_in_crit112 = { FOLLOW_STR_in_crit112_bits, 1 };
  2845. +
  2846. +
  2847. +
  2848. +
  2849. +/* ==============================================
  2850. + * Parsing rules
  2851. + */
  2852. +/**
  2853. + * $ANTLR start query
  2854. + * DAAP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ;
  2855. + */
  2856. +static DAAPParser_query_return
  2857. +query(pDAAPParser ctx)
  2858. +{
  2859. + DAAPParser_query_return retval;
  2860. +
  2861. + pANTLR3_BASE_TREE root_0;
  2862. +
  2863. + pANTLR3_COMMON_TOKEN NEWLINE2;
  2864. + pANTLR3_COMMON_TOKEN EOF3;
  2865. + DAAPParser_expr_return expr1;
  2866. + #undef RETURN_TYPE_expr1
  2867. + #define RETURN_TYPE_expr1 DAAPParser_expr_return
  2868. +
  2869. + pANTLR3_BASE_TREE NEWLINE2_tree;
  2870. + pANTLR3_BASE_TREE EOF3_tree;
  2871. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE;
  2872. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF;
  2873. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
  2874. + /* Initialize rule variables
  2875. + */
  2876. +
  2877. +
  2878. + root_0 = NULL;
  2879. +
  2880. + NEWLINE2 = NULL;
  2881. + EOF3 = NULL;
  2882. + expr1.tree = NULL;
  2883. +
  2884. + retval.start = LT(1); retval.stop = retval.start;
  2885. +
  2886. + NEWLINE2_tree = NULL;
  2887. + EOF3_tree = NULL;
  2888. +
  2889. + stream_NEWLINE = NULL;
  2890. + #define CREATE_stream_NEWLINE if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); }
  2891. + stream_EOF = NULL;
  2892. + #define CREATE_stream_EOF if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); }
  2893. + stream_expr = NULL;
  2894. + #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
  2895. +
  2896. + retval.tree = NULL;
  2897. + {
  2898. + // DAAP.g:27:7: ( expr ( NEWLINE )? EOF -> expr )
  2899. + // DAAP.g:27:9: expr ( NEWLINE )? EOF
  2900. + {
  2901. + FOLLOWPUSH(FOLLOW_expr_in_query42);
  2902. + expr1=expr(ctx);
  2903. +
  2904. + FOLLOWPOP();
  2905. + if (HASEXCEPTION())
  2906. + {
  2907. + goto rulequeryEx;
  2908. + }
  2909. +
  2910. + CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL);
  2911. +
  2912. + // DAAP.g:27:14: ( NEWLINE )?
  2913. + {
  2914. + int alt1=2;
  2915. + switch ( LA(1) )
  2916. + {
  2917. + case NEWLINE:
  2918. + {
  2919. + alt1=1;
  2920. + }
  2921. + break;
  2922. + }
  2923. +
  2924. + switch (alt1)
  2925. + {
  2926. + case 1:
  2927. + // DAAP.g:27:14: NEWLINE
  2928. + {
  2929. + NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44);
  2930. + if (HASEXCEPTION())
  2931. + {
  2932. + goto rulequeryEx;
  2933. + }
  2934. +
  2935. + CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL);
  2936. +
  2937. +
  2938. + }
  2939. + break;
  2940. +
  2941. + }
  2942. + }
  2943. + EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47);
  2944. + if (HASEXCEPTION())
  2945. + {
  2946. + goto rulequeryEx;
  2947. + }
  2948. +
  2949. + CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL);
  2950. +
  2951. +
  2952. +
  2953. + /* AST REWRITE
  2954. + * elements : expr
  2955. + * token labels :
  2956. + * rule labels : retval
  2957. + * token list labels :
  2958. + * rule list labels :
  2959. + */
  2960. + {
  2961. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  2962. +
  2963. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  2964. +
  2965. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  2966. + retval.tree = root_0;
  2967. + // 27:27: -> expr
  2968. + {
  2969. + ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
  2970. +
  2971. + }
  2972. +
  2973. + retval.tree = root_0; // set result root
  2974. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  2975. +
  2976. +
  2977. + }
  2978. + }
  2979. +
  2980. + }
  2981. +
  2982. +
  2983. + // This is where rules clean up and exit
  2984. + //
  2985. + goto rulequeryEx; /* Prevent compiler warnings */
  2986. + rulequeryEx: ;
  2987. + retval.stop = LT(-1);
  2988. +
  2989. + retval.stop = LT(-1);
  2990. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  2991. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  2992. + if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE);
  2993. + if (stream_EOF != NULL) stream_EOF->free(stream_EOF);
  2994. + if (stream_expr != NULL) stream_expr->free(stream_expr);
  2995. +
  2996. + if (HASEXCEPTION())
  2997. + {
  2998. + PREPORTERROR();
  2999. + PRECOVER();
  3000. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  3001. + }
  3002. +
  3003. +
  3004. + return retval;
  3005. +}
  3006. +/* $ANTLR end query */
  3007. +
  3008. +/**
  3009. + * $ANTLR start expr
  3010. + * DAAP.g:30:1: expr : aexpr ( OPOR aexpr )* ;
  3011. + */
  3012. +static DAAPParser_expr_return
  3013. +expr(pDAAPParser ctx)
  3014. +{
  3015. + DAAPParser_expr_return retval;
  3016. +
  3017. + pANTLR3_BASE_TREE root_0;
  3018. +
  3019. + pANTLR3_COMMON_TOKEN OPOR5;
  3020. + DAAPParser_aexpr_return aexpr4;
  3021. + #undef RETURN_TYPE_aexpr4
  3022. + #define RETURN_TYPE_aexpr4 DAAPParser_aexpr_return
  3023. +
  3024. + DAAPParser_aexpr_return aexpr6;
  3025. + #undef RETURN_TYPE_aexpr6
  3026. + #define RETURN_TYPE_aexpr6 DAAPParser_aexpr_return
  3027. +
  3028. + pANTLR3_BASE_TREE OPOR5_tree;
  3029. +
  3030. + /* Initialize rule variables
  3031. + */
  3032. +
  3033. +
  3034. + root_0 = NULL;
  3035. +
  3036. + OPOR5 = NULL;
  3037. + aexpr4.tree = NULL;
  3038. +
  3039. + aexpr6.tree = NULL;
  3040. +
  3041. + retval.start = LT(1); retval.stop = retval.start;
  3042. +
  3043. + OPOR5_tree = NULL;
  3044. +
  3045. +
  3046. + retval.tree = NULL;
  3047. + {
  3048. + // DAAP.g:30:6: ( aexpr ( OPOR aexpr )* )
  3049. + // DAAP.g:30:8: aexpr ( OPOR aexpr )*
  3050. + {
  3051. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  3052. +
  3053. + FOLLOWPUSH(FOLLOW_aexpr_in_expr62);
  3054. + aexpr4=aexpr(ctx);
  3055. +
  3056. + FOLLOWPOP();
  3057. + if (HASEXCEPTION())
  3058. + {
  3059. + goto ruleexprEx;
  3060. + }
  3061. +
  3062. + ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree);
  3063. +
  3064. + // DAAP.g:30:14: ( OPOR aexpr )*
  3065. +
  3066. + for (;;)
  3067. + {
  3068. + int alt2=2;
  3069. + switch ( LA(1) )
  3070. + {
  3071. + case OPOR:
  3072. + {
  3073. + alt2=1;
  3074. + }
  3075. + break;
  3076. +
  3077. + }
  3078. +
  3079. + switch (alt2)
  3080. + {
  3081. + case 1:
  3082. + // DAAP.g:30:15: OPOR aexpr
  3083. + {
  3084. + OPOR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OPOR, &FOLLOW_OPOR_in_expr65);
  3085. + if (HASEXCEPTION())
  3086. + {
  3087. + goto ruleexprEx;
  3088. + }
  3089. +
  3090. + OPOR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPOR5));
  3091. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPOR5_tree, root_0));
  3092. +
  3093. + FOLLOWPUSH(FOLLOW_aexpr_in_expr68);
  3094. + aexpr6=aexpr(ctx);
  3095. +
  3096. + FOLLOWPOP();
  3097. + if (HASEXCEPTION())
  3098. + {
  3099. + goto ruleexprEx;
  3100. + }
  3101. +
  3102. + ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree);
  3103. +
  3104. + }
  3105. + break;
  3106. +
  3107. + default:
  3108. + goto loop2; /* break out of the loop */
  3109. + break;
  3110. + }
  3111. + }
  3112. + loop2: ; /* Jump out to here if this rule does not match */
  3113. +
  3114. +
  3115. + }
  3116. +
  3117. + }
  3118. +
  3119. +
  3120. + // This is where rules clean up and exit
  3121. + //
  3122. + goto ruleexprEx; /* Prevent compiler warnings */
  3123. + ruleexprEx: ;
  3124. + retval.stop = LT(-1);
  3125. +
  3126. + retval.stop = LT(-1);
  3127. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  3128. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  3129. +
  3130. + if (HASEXCEPTION())
  3131. + {
  3132. + PREPORTERROR();
  3133. + PRECOVER();
  3134. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  3135. + }
  3136. +
  3137. +
  3138. + return retval;
  3139. +}
  3140. +/* $ANTLR end expr */
  3141. +
  3142. +/**
  3143. + * $ANTLR start aexpr
  3144. + * DAAP.g:33:1: aexpr : crit ( OPAND crit )* ;
  3145. + */
  3146. +static DAAPParser_aexpr_return
  3147. +aexpr(pDAAPParser ctx)
  3148. +{
  3149. + DAAPParser_aexpr_return retval;
  3150. +
  3151. + pANTLR3_BASE_TREE root_0;
  3152. +
  3153. + pANTLR3_COMMON_TOKEN OPAND8;
  3154. + DAAPParser_crit_return crit7;
  3155. + #undef RETURN_TYPE_crit7
  3156. + #define RETURN_TYPE_crit7 DAAPParser_crit_return
  3157. +
  3158. + DAAPParser_crit_return crit9;
  3159. + #undef RETURN_TYPE_crit9
  3160. + #define RETURN_TYPE_crit9 DAAPParser_crit_return
  3161. +
  3162. + pANTLR3_BASE_TREE OPAND8_tree;
  3163. +
  3164. + /* Initialize rule variables
  3165. + */
  3166. +
  3167. +
  3168. + root_0 = NULL;
  3169. +
  3170. + OPAND8 = NULL;
  3171. + crit7.tree = NULL;
  3172. +
  3173. + crit9.tree = NULL;
  3174. +
  3175. + retval.start = LT(1); retval.stop = retval.start;
  3176. +
  3177. + OPAND8_tree = NULL;
  3178. +
  3179. +
  3180. + retval.tree = NULL;
  3181. + {
  3182. + // DAAP.g:33:7: ( crit ( OPAND crit )* )
  3183. + // DAAP.g:33:9: crit ( OPAND crit )*
  3184. + {
  3185. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  3186. +
  3187. + FOLLOWPUSH(FOLLOW_crit_in_aexpr80);
  3188. + crit7=crit(ctx);
  3189. +
  3190. + FOLLOWPOP();
  3191. + if (HASEXCEPTION())
  3192. + {
  3193. + goto ruleaexprEx;
  3194. + }
  3195. +
  3196. + ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree);
  3197. +
  3198. + // DAAP.g:33:14: ( OPAND crit )*
  3199. +
  3200. + for (;;)
  3201. + {
  3202. + int alt3=2;
  3203. + switch ( LA(1) )
  3204. + {
  3205. + case OPAND:
  3206. + {
  3207. + alt3=1;
  3208. + }
  3209. + break;
  3210. +
  3211. + }
  3212. +
  3213. + switch (alt3)
  3214. + {
  3215. + case 1:
  3216. + // DAAP.g:33:15: OPAND crit
  3217. + {
  3218. + OPAND8 = (pANTLR3_COMMON_TOKEN) MATCHT(OPAND, &FOLLOW_OPAND_in_aexpr83);
  3219. + if (HASEXCEPTION())
  3220. + {
  3221. + goto ruleaexprEx;
  3222. + }
  3223. +
  3224. + OPAND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPAND8));
  3225. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPAND8_tree, root_0));
  3226. +
  3227. + FOLLOWPUSH(FOLLOW_crit_in_aexpr86);
  3228. + crit9=crit(ctx);
  3229. +
  3230. + FOLLOWPOP();
  3231. + if (HASEXCEPTION())
  3232. + {
  3233. + goto ruleaexprEx;
  3234. + }
  3235. +
  3236. + ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree);
  3237. +
  3238. + }
  3239. + break;
  3240. +
  3241. + default:
  3242. + goto loop3; /* break out of the loop */
  3243. + break;
  3244. + }
  3245. + }
  3246. + loop3: ; /* Jump out to here if this rule does not match */
  3247. +
  3248. +
  3249. + }
  3250. +
  3251. + }
  3252. +
  3253. +
  3254. + // This is where rules clean up and exit
  3255. + //
  3256. + goto ruleaexprEx; /* Prevent compiler warnings */
  3257. + ruleaexprEx: ;
  3258. + retval.stop = LT(-1);
  3259. +
  3260. + retval.stop = LT(-1);
  3261. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  3262. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  3263. +
  3264. + if (HASEXCEPTION())
  3265. + {
  3266. + PREPORTERROR();
  3267. + PRECOVER();
  3268. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  3269. + }
  3270. +
  3271. +
  3272. + return retval;
  3273. +}
  3274. +/* $ANTLR end aexpr */
  3275. +
  3276. +/**
  3277. + * $ANTLR start crit
  3278. + * DAAP.g:36:1: crit : ( LPAR expr RPAR -> expr | STR );
  3279. + */
  3280. +static DAAPParser_crit_return
  3281. +crit(pDAAPParser ctx)
  3282. +{
  3283. + DAAPParser_crit_return retval;
  3284. +
  3285. + pANTLR3_BASE_TREE root_0;
  3286. +
  3287. + pANTLR3_COMMON_TOKEN LPAR10;
  3288. + pANTLR3_COMMON_TOKEN RPAR12;
  3289. + pANTLR3_COMMON_TOKEN STR13;
  3290. + DAAPParser_expr_return expr11;
  3291. + #undef RETURN_TYPE_expr11
  3292. + #define RETURN_TYPE_expr11 DAAPParser_expr_return
  3293. +
  3294. + pANTLR3_BASE_TREE LPAR10_tree;
  3295. + pANTLR3_BASE_TREE RPAR12_tree;
  3296. + pANTLR3_BASE_TREE STR13_tree;
  3297. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR;
  3298. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR;
  3299. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
  3300. + /* Initialize rule variables
  3301. + */
  3302. +
  3303. +
  3304. + root_0 = NULL;
  3305. +
  3306. + LPAR10 = NULL;
  3307. + RPAR12 = NULL;
  3308. + STR13 = NULL;
  3309. + expr11.tree = NULL;
  3310. +
  3311. + retval.start = LT(1); retval.stop = retval.start;
  3312. +
  3313. + LPAR10_tree = NULL;
  3314. + RPAR12_tree = NULL;
  3315. + STR13_tree = NULL;
  3316. +
  3317. + stream_RPAR = NULL;
  3318. + #define CREATE_stream_RPAR if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); }
  3319. + stream_LPAR = NULL;
  3320. + #define CREATE_stream_LPAR if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); }
  3321. + stream_expr = NULL;
  3322. + #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
  3323. +
  3324. + retval.tree = NULL;
  3325. + {
  3326. + {
  3327. + // DAAP.g:36:6: ( LPAR expr RPAR -> expr | STR )
  3328. +
  3329. + ANTLR3_UINT32 alt4;
  3330. +
  3331. + alt4=2;
  3332. +
  3333. + switch ( LA(1) )
  3334. + {
  3335. + case LPAR:
  3336. + {
  3337. + alt4=1;
  3338. + }
  3339. + break;
  3340. + case STR:
  3341. + {
  3342. + alt4=2;
  3343. + }
  3344. + break;
  3345. +
  3346. + default:
  3347. + CONSTRUCTEX();
  3348. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  3349. + EXCEPTION->message = (void *)"";
  3350. + EXCEPTION->decisionNum = 4;
  3351. + EXCEPTION->state = 0;
  3352. +
  3353. +
  3354. + goto rulecritEx;
  3355. + }
  3356. +
  3357. + switch (alt4)
  3358. + {
  3359. + case 1:
  3360. + // DAAP.g:36:8: LPAR expr RPAR
  3361. + {
  3362. + LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit98);
  3363. + if (HASEXCEPTION())
  3364. + {
  3365. + goto rulecritEx;
  3366. + }
  3367. +
  3368. + CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL);
  3369. +
  3370. + FOLLOWPUSH(FOLLOW_expr_in_crit100);
  3371. + expr11=expr(ctx);
  3372. +
  3373. + FOLLOWPOP();
  3374. + if (HASEXCEPTION())
  3375. + {
  3376. + goto rulecritEx;
  3377. + }
  3378. +
  3379. + CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL);
  3380. + RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit102);
  3381. + if (HASEXCEPTION())
  3382. + {
  3383. + goto rulecritEx;
  3384. + }
  3385. +
  3386. + CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL);
  3387. +
  3388. +
  3389. +
  3390. + /* AST REWRITE
  3391. + * elements : expr
  3392. + * token labels :
  3393. + * rule labels : retval
  3394. + * token list labels :
  3395. + * rule list labels :
  3396. + */
  3397. + {
  3398. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  3399. +
  3400. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  3401. +
  3402. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  3403. + retval.tree = root_0;
  3404. + // 36:24: -> expr
  3405. + {
  3406. + ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
  3407. +
  3408. + }
  3409. +
  3410. + retval.tree = root_0; // set result root
  3411. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  3412. +
  3413. +
  3414. + }
  3415. + }
  3416. + break;
  3417. + case 2:
  3418. + // DAAP.g:37:4: STR
  3419. + {
  3420. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  3421. +
  3422. + STR13 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_crit112);
  3423. + if (HASEXCEPTION())
  3424. + {
  3425. + goto rulecritEx;
  3426. + }
  3427. +
  3428. + STR13_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, STR13));
  3429. + ADAPTOR->addChild(ADAPTOR, root_0, STR13_tree);
  3430. +
  3431. +
  3432. + }
  3433. + break;
  3434. +
  3435. + }
  3436. + }
  3437. + }
  3438. +
  3439. +
  3440. + // This is where rules clean up and exit
  3441. + //
  3442. + goto rulecritEx; /* Prevent compiler warnings */
  3443. + rulecritEx: ;
  3444. + retval.stop = LT(-1);
  3445. +
  3446. + retval.stop = LT(-1);
  3447. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  3448. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  3449. + if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR);
  3450. + if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR);
  3451. + if (stream_expr != NULL) stream_expr->free(stream_expr);
  3452. +
  3453. + if (HASEXCEPTION())
  3454. + {
  3455. + PREPORTERROR();
  3456. + PRECOVER();
  3457. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  3458. + }
  3459. +
  3460. +
  3461. + return retval;
  3462. +}
  3463. +/* $ANTLR end crit */
  3464. +/* End of parsing rules
  3465. + * ==============================================
  3466. + */
  3467. +
  3468. +/* ==============================================
  3469. + * Syntactic predicates
  3470. + */
  3471. +/* End of syntactic predicates
  3472. + * ==============================================
  3473. + */
  3474. +
  3475. +
  3476. +
  3477. +
  3478. +
  3479. +
  3480. +/* End of code
  3481. + * =============================================================================
  3482. + */
  3483. diff --git a/src/pregen/DAAPParser.h b/src/pregen/DAAPParser.h
  3484. new file mode 100644
  3485. index 0000000..dcc664f
  3486. --- /dev/null
  3487. +++ b/src/pregen/DAAPParser.h
  3488. @@ -0,0 +1,226 @@
  3489. +/** \file
  3490. + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
  3491. + *
  3492. + * - From the grammar source file : DAAP.g
  3493. + * - On : 2014-09-30 21:42:39
  3494. + * - for the parser : DAAPParserParser *
  3495. + * Editing it, at least manually, is not wise.
  3496. + *
  3497. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  3498. + *
  3499. + *
  3500. + * The parser DAAPParser has the callable functions (rules) shown below,
  3501. + * which will invoke the code for the associated rule in the source grammar
  3502. + * assuming that the input stream is pointing to a token/text stream that could begin
  3503. + * this rule.
  3504. + *
  3505. + * For instance if you call the first (topmost) rule in a parser grammar, you will
  3506. + * get the results of a full parse, but calling a rule half way through the grammar will
  3507. + * allow you to pass part of a full token stream to the parser, such as for syntax checking
  3508. + * in editors and so on.
  3509. + *
  3510. + * The parser entry points are called indirectly (by function pointer to function) via
  3511. + * a parser context typedef pDAAPParser, which is returned from a call to DAAPParserNew().
  3512. + *
  3513. + * The methods in pDAAPParser are as follows:
  3514. + *
  3515. + * - DAAPParser_query_return pDAAPParser->query(pDAAPParser)
  3516. + * - DAAPParser_expr_return pDAAPParser->expr(pDAAPParser)
  3517. + * - DAAPParser_aexpr_return pDAAPParser->aexpr(pDAAPParser)
  3518. + * - DAAPParser_crit_return pDAAPParser->crit(pDAAPParser)
  3519. + *
  3520. + * The return type for any particular rule is of course determined by the source
  3521. + * grammar file.
  3522. + */
  3523. +// [The "BSD licence"]
  3524. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  3525. +// http://www.temporal-wave.com
  3526. +// http://www.linkedin.com/in/jimidle
  3527. +//
  3528. +// All rights reserved.
  3529. +//
  3530. +// Redistribution and use in source and binary forms, with or without
  3531. +// modification, are permitted provided that the following conditions
  3532. +// are met:
  3533. +// 1. Redistributions of source code must retain the above copyright
  3534. +// notice, this list of conditions and the following disclaimer.
  3535. +// 2. Redistributions in binary form must reproduce the above copyright
  3536. +// notice, this list of conditions and the following disclaimer in the
  3537. +// documentation and/or other materials provided with the distribution.
  3538. +// 3. The name of the author may not be used to endorse or promote products
  3539. +// derived from this software without specific prior written permission.
  3540. +//
  3541. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  3542. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  3543. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  3544. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  3545. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  3546. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  3547. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3548. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3549. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  3550. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3551. +
  3552. +#ifndef _DAAPParser_H
  3553. +#define _DAAPParser_H
  3554. +/* =============================================================================
  3555. + * Standard antlr3 C runtime definitions
  3556. + */
  3557. +#include <antlr3.h>
  3558. +
  3559. +/* End of standard antlr 3 runtime definitions
  3560. + * =============================================================================
  3561. + */
  3562. +
  3563. +#ifdef __cplusplus
  3564. +extern "C" {
  3565. +#endif
  3566. +
  3567. +// Forward declare the context typedef so that we can use it before it is
  3568. +// properly defined. Delegators and delegates (from import statements) are
  3569. +// interdependent and their context structures contain pointers to each other
  3570. +// C only allows such things to be declared if you pre-declare the typedef.
  3571. +//
  3572. +typedef struct DAAPParser_Ctx_struct DAAPParser, * pDAAPParser;
  3573. +
  3574. +
  3575. +
  3576. +#ifdef ANTLR3_WINDOWS
  3577. +// Disable: Unreferenced parameter, - Rules with parameters that are not used
  3578. +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
  3579. +// initialized but unused variable - tree rewrite variables declared but not needed
  3580. +// Unreferenced local variable - lexer rule declares but does not always use _type
  3581. +// potentially unitialized variable used - retval always returned from a rule
  3582. +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
  3583. +//
  3584. +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
  3585. +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
  3586. +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
  3587. +// this is a matter of orthogonality hence I disable that one.
  3588. +//
  3589. +#pragma warning( disable : 4100 )
  3590. +#pragma warning( disable : 4101 )
  3591. +#pragma warning( disable : 4127 )
  3592. +#pragma warning( disable : 4189 )
  3593. +#pragma warning( disable : 4505 )
  3594. +#pragma warning( disable : 4701 )
  3595. +#endif
  3596. +typedef struct DAAPParser_query_return_struct
  3597. +{
  3598. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  3599. + */
  3600. + pANTLR3_COMMON_TOKEN start;
  3601. + pANTLR3_COMMON_TOKEN stop;
  3602. + pANTLR3_BASE_TREE tree;
  3603. +
  3604. +}
  3605. + DAAPParser_query_return;
  3606. +
  3607. +typedef struct DAAPParser_expr_return_struct
  3608. +{
  3609. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  3610. + */
  3611. + pANTLR3_COMMON_TOKEN start;
  3612. + pANTLR3_COMMON_TOKEN stop;
  3613. + pANTLR3_BASE_TREE tree;
  3614. +
  3615. +}
  3616. + DAAPParser_expr_return;
  3617. +
  3618. +typedef struct DAAPParser_aexpr_return_struct
  3619. +{
  3620. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  3621. + */
  3622. + pANTLR3_COMMON_TOKEN start;
  3623. + pANTLR3_COMMON_TOKEN stop;
  3624. + pANTLR3_BASE_TREE tree;
  3625. +
  3626. +}
  3627. + DAAPParser_aexpr_return;
  3628. +
  3629. +typedef struct DAAPParser_crit_return_struct
  3630. +{
  3631. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  3632. + */
  3633. + pANTLR3_COMMON_TOKEN start;
  3634. + pANTLR3_COMMON_TOKEN stop;
  3635. + pANTLR3_BASE_TREE tree;
  3636. +
  3637. +}
  3638. + DAAPParser_crit_return;
  3639. +
  3640. +
  3641. +
  3642. +/** Context tracking structure for DAAPParser
  3643. + */
  3644. +struct DAAPParser_Ctx_struct
  3645. +{
  3646. + /** Built in ANTLR3 context tracker contains all the generic elements
  3647. + * required for context tracking.
  3648. + */
  3649. + pANTLR3_PARSER pParser;
  3650. +
  3651. +
  3652. + DAAPParser_query_return (*query) (struct DAAPParser_Ctx_struct * ctx);
  3653. + DAAPParser_expr_return (*expr) (struct DAAPParser_Ctx_struct * ctx);
  3654. + DAAPParser_aexpr_return (*aexpr) (struct DAAPParser_Ctx_struct * ctx);
  3655. + DAAPParser_crit_return (*crit) (struct DAAPParser_Ctx_struct * ctx);
  3656. + // Delegated rules
  3657. + const char * (*getGrammarFileName)();
  3658. + void (*free) (struct DAAPParser_Ctx_struct * ctx);
  3659. + /* @headerFile.members() */
  3660. + pANTLR3_BASE_TREE_ADAPTOR adaptor;
  3661. + pANTLR3_VECTOR_FACTORY vectors;
  3662. + /* End @headerFile.members() */
  3663. +};
  3664. +
  3665. +// Function protoypes for the constructor functions that external translation units
  3666. +// such as delegators and delegates may wish to call.
  3667. +//
  3668. +ANTLR3_API pDAAPParser DAAPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream);
  3669. +ANTLR3_API pDAAPParser DAAPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
  3670. +
  3671. +/** Symbolic definitions of all the tokens that the parser will work with.
  3672. + * \{
  3673. + *
  3674. + * Antlr will define EOF, but we can't use that as it it is too common in
  3675. + * in C header files and that would be confusing. There is no way to filter this out at the moment
  3676. + * so we just undef it here for now. That isn't the value we get back from C recognizers
  3677. + * anyway. We are looking for ANTLR3_TOKEN_EOF.
  3678. + */
  3679. +#ifdef EOF
  3680. +#undef EOF
  3681. +#endif
  3682. +#ifdef Tokens
  3683. +#undef Tokens
  3684. +#endif
  3685. +#define STR 9
  3686. +#define QUOTE 10
  3687. +#define LPAR 7
  3688. +#define NEWLINE 4
  3689. +#define OPOR 5
  3690. +#define RPAR 8
  3691. +#define ESCAPED 11
  3692. +#define OPAND 6
  3693. +#define EOF -1
  3694. +#ifdef EOF
  3695. +#undef EOF
  3696. +#define EOF ANTLR3_TOKEN_EOF
  3697. +#endif
  3698. +
  3699. +#ifndef TOKENSOURCE
  3700. +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
  3701. +#endif
  3702. +
  3703. +/* End of token definitions for DAAPParser
  3704. + * =============================================================================
  3705. + */
  3706. +/** \} */
  3707. +
  3708. +#ifdef __cplusplus
  3709. +}
  3710. +#endif
  3711. +
  3712. +#endif
  3713. +
  3714. +/* END - Note:Keep extra line feed to satisfy UNIX systems */
  3715. diff --git a/src/pregen/RSP.u b/src/pregen/RSP.u
  3716. new file mode 100644
  3717. index 0000000..89256ff
  3718. --- /dev/null
  3719. +++ b/src/pregen/RSP.u
  3720. @@ -0,0 +1,6 @@
  3721. +RSPParser.c : RSP.g
  3722. +./RSP.tokens : RSP.g
  3723. +RSPParser.h : RSP.g
  3724. +RSPLexer.c : RSP.g
  3725. +RSPLexer.h : RSP.g
  3726. +ANTLR_PRODUCTS += RSPParser.c ./RSP.tokens RSPParser.h RSPLexer.c RSPLexer.h
  3727. \ No newline at end of file
  3728. diff --git a/src/pregen/RSP2SQL.c b/src/pregen/RSP2SQL.c
  3729. new file mode 100644
  3730. index 0000000..b5c9550
  3731. --- /dev/null
  3732. +++ b/src/pregen/RSP2SQL.c
  3733. @@ -0,0 +1,2546 @@
  3734. +/** \file
  3735. + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
  3736. + *
  3737. + * - From the grammar source file : RSP2SQL.g
  3738. + * - On : 2014-09-30 21:42:42
  3739. + * - for the tree parser : RSP2SQLTreeParser *
  3740. + * Editing it, at least manually, is not wise.
  3741. + *
  3742. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  3743. + *
  3744. + *
  3745. +*/
  3746. +// [The "BSD licence"]
  3747. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  3748. +// http://www.temporal-wave.com
  3749. +// http://www.linkedin.com/in/jimidle
  3750. +//
  3751. +// All rights reserved.
  3752. +//
  3753. +// Redistribution and use in source and binary forms, with or without
  3754. +// modification, are permitted provided that the following conditions
  3755. +// are met:
  3756. +// 1. Redistributions of source code must retain the above copyright
  3757. +// notice, this list of conditions and the following disclaimer.
  3758. +// 2. Redistributions in binary form must reproduce the above copyright
  3759. +// notice, this list of conditions and the following disclaimer in the
  3760. +// documentation and/or other materials provided with the distribution.
  3761. +// 3. The name of the author may not be used to endorse or promote products
  3762. +// derived from this software without specific prior written permission.
  3763. +//
  3764. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  3765. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  3766. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  3767. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  3768. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  3769. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  3770. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3771. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3772. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  3773. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3774. +
  3775. +
  3776. +/* =============================================================================
  3777. + * This is what the grammar programmer asked us to put at the top of every file.
  3778. + */
  3779. +
  3780. + /* Needs #define _GNU_SOURCE for strptime() */
  3781. +
  3782. + #include <stdio.h>
  3783. + #include <string.h>
  3784. + #include <time.h>
  3785. + #include <stdint.h>
  3786. +
  3787. + #include "logger.h"
  3788. + #include "db.h"
  3789. + #include "misc.h"
  3790. + #include "rsp_query.h"
  3791. +
  3792. +/* End of Header action.
  3793. + * =============================================================================
  3794. + */
  3795. +/* -----------------------------------------
  3796. + * Include the ANTLR3 generated header file.
  3797. + */
  3798. +#include "RSP2SQL.h"
  3799. +/* ----------------------------------------- */
  3800. +
  3801. +
  3802. +
  3803. +
  3804. +
  3805. +/* MACROS that hide the C interface implementations from the
  3806. + * generated code, which makes it a little more understandable to the human eye.
  3807. + * I am very much against using C pre-processor macros for function calls and bits
  3808. + * of code as you cannot see what is happening when single stepping in debuggers
  3809. + * and so on. The exception (in my book at least) is for generated code, where you are
  3810. + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
  3811. + * hides some indirect calls, but is always referring to the input stream. This is
  3812. + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
  3813. + * the runtime interfaces without changing the generated code too often, without
  3814. + * confusing the reader of the generated output, who may not wish to know the gory
  3815. + * details of the interface inheritance.
  3816. + */
  3817. +
  3818. +#define CTX ctx
  3819. +
  3820. +/* Aids in accessing scopes for grammar programmers
  3821. + */
  3822. +#undef SCOPE_TYPE
  3823. +#undef SCOPE_STACK
  3824. +#undef SCOPE_TOP
  3825. +#define SCOPE_TYPE(scope) pRSP2SQL_##scope##_SCOPE
  3826. +#define SCOPE_STACK(scope) pRSP2SQL_##scope##Stack
  3827. +#define SCOPE_TOP(scope) ctx->pRSP2SQL_##scope##Top
  3828. +#define SCOPE_SIZE(scope) ctx->pRSP2SQL_##scope##Stack_limit
  3829. +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
  3830. +
  3831. +/* Macros for accessing things in the parser
  3832. + */
  3833. +
  3834. +#undef PARSER
  3835. +#undef RECOGNIZER
  3836. +#undef HAVEPARSEDRULE
  3837. +#undef INPUT
  3838. +#undef STRSTREAM
  3839. +#undef HASEXCEPTION
  3840. +#undef EXCEPTION
  3841. +#undef MATCHT
  3842. +#undef MATCHANYT
  3843. +#undef FOLLOWSTACK
  3844. +#undef FOLLOWPUSH
  3845. +#undef FOLLOWPOP
  3846. +#undef PRECOVER
  3847. +#undef PREPORTERROR
  3848. +#undef LA
  3849. +#undef LT
  3850. +#undef CONSTRUCTEX
  3851. +#undef CONSUME
  3852. +#undef MARK
  3853. +#undef REWIND
  3854. +#undef REWINDLAST
  3855. +#undef PERRORRECOVERY
  3856. +#undef HASFAILED
  3857. +#undef FAILEDFLAG
  3858. +#undef RECOVERFROMMISMATCHEDSET
  3859. +#undef RECOVERFROMMISMATCHEDELEMENT
  3860. +#undef BACKTRACKING
  3861. +#undef ADAPTOR
  3862. +#undef RULEMEMO
  3863. +#undef SEEK
  3864. +#undef INDEX
  3865. +#undef DBG
  3866. +
  3867. +#define PARSER ctx->pTreeParser
  3868. +#define RECOGNIZER PARSER->rec
  3869. +#define PSRSTATE RECOGNIZER->state
  3870. +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
  3871. +#define INPUT PARSER->ctnstream
  3872. +#define ISTREAM INPUT->tnstream->istream
  3873. +#define STRSTREAM INPUT->tnstream
  3874. +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
  3875. +#define EXCEPTION PSRSTATE->exception
  3876. +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
  3877. +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
  3878. +#define FOLLOWSTACK PSRSTATE->following
  3879. +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
  3880. +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
  3881. +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
  3882. +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
  3883. +#define LA(n) ISTREAM->_LA(ISTREAM, n)
  3884. +#define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n)
  3885. +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
  3886. +#define CONSUME() ISTREAM->consume(ISTREAM)
  3887. +#define MARK() ISTREAM->mark(ISTREAM)
  3888. +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
  3889. +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
  3890. +#define PERRORRECOVERY PSRSTATE->errorRecovery
  3891. +#define FAILEDFLAG PSRSTATE->failed
  3892. +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
  3893. +#define BACKTRACKING PSRSTATE->backtracking
  3894. +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
  3895. +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
  3896. +#define ADAPTOR INPUT->adaptor
  3897. +#define RULEMEMO PSRSTATE->ruleMemo
  3898. +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
  3899. +#define INDEX() ISTREAM->index(ISTREAM)
  3900. +#define DBG RECOGNIZER->debugger
  3901. +
  3902. +
  3903. +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
  3904. +
  3905. +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
  3906. + * then for the present you must use different names for your defines as these are hard coded
  3907. + * in the code generator. It would be better not to use such names internally, and maybe
  3908. + * we can change this in a forthcoming release. I deliberately do not #undef these
  3909. + * here as this will at least give you a redefined error somewhere if they clash.
  3910. + */
  3911. +#define UP ANTLR3_TOKEN_UP
  3912. +#define DOWN ANTLR3_TOKEN_DOWN
  3913. +#define EOR ANTLR3_TOKEN_EOR
  3914. +#define INVALID ANTLR3_TOKEN_INVALID
  3915. +
  3916. +
  3917. +/* =============================================================================
  3918. + * Functions to create and destroy scopes. First come the rule scopes, followed
  3919. + * by the global declared scopes.
  3920. + */
  3921. +
  3922. +
  3923. +
  3924. +/* ============================================================================= */
  3925. +
  3926. +/* =============================================================================
  3927. + * Start of recognizer
  3928. + */
  3929. +
  3930. +
  3931. +
  3932. +/** \brief Table of all token names in symbolic order, mainly used for
  3933. + * error reporting.
  3934. + */
  3935. +pANTLR3_UINT8 RSP2SQLTokenNames[30+4]
  3936. + = {
  3937. + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
  3938. + (pANTLR3_UINT8) "<EOR>",
  3939. + (pANTLR3_UINT8) "<DOWN>",
  3940. + (pANTLR3_UINT8) "<UP>",
  3941. + (pANTLR3_UINT8) "NEWLINE",
  3942. + (pANTLR3_UINT8) "OR",
  3943. + (pANTLR3_UINT8) "AND",
  3944. + (pANTLR3_UINT8) "LPAR",
  3945. + (pANTLR3_UINT8) "RPAR",
  3946. + (pANTLR3_UINT8) "FIELD",
  3947. + (pANTLR3_UINT8) "STR",
  3948. + (pANTLR3_UINT8) "NOT",
  3949. + (pANTLR3_UINT8) "EQUAL",
  3950. + (pANTLR3_UINT8) "INCLUDES",
  3951. + (pANTLR3_UINT8) "STARTSW",
  3952. + (pANTLR3_UINT8) "ENDSW",
  3953. + (pANTLR3_UINT8) "INT",
  3954. + (pANTLR3_UINT8) "LESS",
  3955. + (pANTLR3_UINT8) "GREATER",
  3956. + (pANTLR3_UINT8) "LTE",
  3957. + (pANTLR3_UINT8) "GTE",
  3958. + (pANTLR3_UINT8) "BEFORE",
  3959. + (pANTLR3_UINT8) "AFTER",
  3960. + (pANTLR3_UINT8) "DATE",
  3961. + (pANTLR3_UINT8) "TODAY",
  3962. + (pANTLR3_UINT8) "DAY",
  3963. + (pANTLR3_UINT8) "WEEK",
  3964. + (pANTLR3_UINT8) "MONTH",
  3965. + (pANTLR3_UINT8) "YEAR",
  3966. + (pANTLR3_UINT8) "QUOTE",
  3967. + (pANTLR3_UINT8) "WS",
  3968. + (pANTLR3_UINT8) "DIGIT19",
  3969. + (pANTLR3_UINT8) "DIGIT09",
  3970. + (pANTLR3_UINT8) "ESCAPED"
  3971. + };
  3972. +
  3973. +
  3974. +
  3975. +// Forward declare the locally static matching functions we have generated.
  3976. +//
  3977. +static pANTLR3_STRING query (pRSP2SQL ctx);
  3978. +static RSP2SQL_expr_return expr (pRSP2SQL ctx);
  3979. +static RSP2SQL_strcrit_return strcrit (pRSP2SQL ctx);
  3980. +static pANTLR3_COMMON_TOKEN strop (pRSP2SQL ctx);
  3981. +static RSP2SQL_intcrit_return intcrit (pRSP2SQL ctx);
  3982. +static pANTLR3_COMMON_TOKEN intop (pRSP2SQL ctx);
  3983. +static RSP2SQL_datecrit_return datecrit (pRSP2SQL ctx);
  3984. +static pANTLR3_COMMON_TOKEN dateop (pRSP2SQL ctx);
  3985. +static RSP2SQL_datespec_return datespec (pRSP2SQL ctx);
  3986. +static RSP2SQL_dateref_return dateref (pRSP2SQL ctx);
  3987. +static RSP2SQL_dateintval_return dateintval (pRSP2SQL ctx);
  3988. +static void RSP2SQLFree(pRSP2SQL ctx);
  3989. +/* For use in tree output where we are accumulating rule labels via label += ruleRef
  3990. + * we need a function that knows how to free a return scope when the list is destroyed.
  3991. + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
  3992. + */
  3993. +static void ANTLR3_CDECL freeScope(void * scope)
  3994. +{
  3995. + ANTLR3_FREE(scope);
  3996. +}
  3997. +
  3998. +/** \brief Name of the grammar file that generated this code
  3999. + */
  4000. +static const char fileName[] = "RSP2SQL.g";
  4001. +
  4002. +/** \brief Return the name of the grammar file that generated this code.
  4003. + */
  4004. +static const char * getGrammarFileName()
  4005. +{
  4006. + return fileName;
  4007. +}
  4008. +/** \brief Create a new RSP2SQL parser and return a context for it.
  4009. + *
  4010. + * \param[in] instream Pointer to an input stream interface.
  4011. + *
  4012. + * \return Pointer to new parser context upon success.
  4013. + */
  4014. +ANTLR3_API pRSP2SQL
  4015. +RSP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream)
  4016. +{
  4017. + // See if we can create a new parser with the standard constructor
  4018. + //
  4019. + return RSP2SQLNewSSD(instream, NULL);
  4020. +}
  4021. +
  4022. +/** \brief Create a new RSP2SQL parser and return a context for it.
  4023. + *
  4024. + * \param[in] instream Pointer to an input stream interface.
  4025. + *
  4026. + * \return Pointer to new parser context upon success.
  4027. + */
  4028. +ANTLR3_API pRSP2SQL
  4029. +RSP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
  4030. +{
  4031. + pRSP2SQL ctx; /* Context structure we will build and return */
  4032. +
  4033. + ctx = (pRSP2SQL) ANTLR3_CALLOC(1, sizeof(RSP2SQL));
  4034. +
  4035. + if (ctx == NULL)
  4036. + {
  4037. + // Failed to allocate memory for parser context
  4038. + //
  4039. + return NULL;
  4040. + }
  4041. +
  4042. + /* -------------------------------------------------------------------
  4043. + * Memory for basic structure is allocated, now to fill in
  4044. + * the base ANTLR3 structures. We initialize the function pointers
  4045. + * for the standard ANTLR3 parser function set, but upon return
  4046. + * from here, the programmer may set the pointers to provide custom
  4047. + * implementations of each function.
  4048. + *
  4049. + * We don't use the macros defined in RSP2SQL.h here, in order that you can get a sense
  4050. + * of what goes where.
  4051. + */
  4052. +
  4053. + /* Create a base Tree parser/recognizer, using the supplied tree node stream
  4054. + */
  4055. + ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state);
  4056. + /* Install the implementation of our RSP2SQL interface
  4057. + */
  4058. + ctx->query = query;
  4059. + ctx->expr = expr;
  4060. + ctx->strcrit = strcrit;
  4061. + ctx->strop = strop;
  4062. + ctx->intcrit = intcrit;
  4063. + ctx->intop = intop;
  4064. + ctx->datecrit = datecrit;
  4065. + ctx->dateop = dateop;
  4066. + ctx->datespec = datespec;
  4067. + ctx->dateref = dateref;
  4068. + ctx->dateintval = dateintval;
  4069. + ctx->free = RSP2SQLFree;
  4070. + ctx->getGrammarFileName = getGrammarFileName;
  4071. +
  4072. + /* Install the scope pushing methods.
  4073. + */
  4074. +
  4075. +
  4076. +
  4077. +
  4078. +
  4079. + /* Install the token table
  4080. + */
  4081. + PSRSTATE->tokenNames = RSP2SQLTokenNames;
  4082. +
  4083. +
  4084. + /* Return the newly built parser to the caller
  4085. + */
  4086. + return ctx;
  4087. +}
  4088. +
  4089. +/** Free the parser resources
  4090. + */
  4091. + static void
  4092. + RSP2SQLFree(pRSP2SQL ctx)
  4093. + {
  4094. + /* Free any scope memory
  4095. + */
  4096. +
  4097. +
  4098. + // Free this parser
  4099. + //
  4100. + ctx->pTreeParser->free(ctx->pTreeParser);
  4101. + ANTLR3_FREE(ctx);
  4102. +
  4103. + /* Everything is released, so we can return
  4104. + */
  4105. + return;
  4106. + }
  4107. +
  4108. +/** Return token names used by this tree parser
  4109. + *
  4110. + * The returned pointer is used as an index into the token names table (using the token
  4111. + * number as the index).
  4112. + *
  4113. + * \return Pointer to first char * in the table.
  4114. + */
  4115. +static pANTLR3_UINT8 *getTokenNames()
  4116. +{
  4117. + return RSP2SQLTokenNames;
  4118. +}
  4119. +
  4120. +
  4121. + #define RSP_TYPE_STRING 0
  4122. + #define RSP_TYPE_INT 1
  4123. + #define RSP_TYPE_DATE 2
  4124. +
  4125. + struct rsp_query_field_map {
  4126. + char *rsp_field;
  4127. + int field_type;
  4128. + /* RSP fields are named after the DB columns - or vice versa */
  4129. + };
  4130. +
  4131. + /* gperf static hash, rsp_query.gperf */
  4132. + #include "rsp_query_hash.c"
  4133. +
  4134. +
  4135. +/* Declare the bitsets
  4136. + */
  4137. +
  4138. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query70 */
  4139. +static ANTLR3_BITWORD FOLLOW_expr_in_query70_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4140. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_query70 = { FOLLOW_expr_in_query70_bits, 1 };
  4141. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_expr95 */
  4142. +static ANTLR3_BITWORD FOLLOW_AND_in_expr95_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  4143. +static ANTLR3_BITSET_LIST FOLLOW_AND_in_expr95 = { FOLLOW_AND_in_expr95_bits, 1 };
  4144. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr101 */
  4145. +static ANTLR3_BITWORD FOLLOW_expr_in_expr101_bits[] = { ANTLR3_UINT64_LIT(0x00000000007EF860) };
  4146. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr101 = { FOLLOW_expr_in_expr101_bits, 1 };
  4147. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr107 */
  4148. +static ANTLR3_BITWORD FOLLOW_expr_in_expr107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  4149. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr107 = { FOLLOW_expr_in_expr107_bits, 1 };
  4150. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expr118 */
  4151. +static ANTLR3_BITWORD FOLLOW_OR_in_expr118_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  4152. +static ANTLR3_BITSET_LIST FOLLOW_OR_in_expr118 = { FOLLOW_OR_in_expr118_bits, 1 };
  4153. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr124 */
  4154. +static ANTLR3_BITWORD FOLLOW_expr_in_expr124_bits[] = { ANTLR3_UINT64_LIT(0x00000000007EF860) };
  4155. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr124 = { FOLLOW_expr_in_expr124_bits, 1 };
  4156. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr130 */
  4157. +static ANTLR3_BITWORD FOLLOW_expr_in_expr130_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  4158. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr130 = { FOLLOW_expr_in_expr130_bits, 1 };
  4159. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_expr144 */
  4160. +static ANTLR3_BITWORD FOLLOW_strcrit_in_expr144_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4161. +static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_expr144 = { FOLLOW_strcrit_in_expr144_bits, 1 };
  4162. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_expr154 */
  4163. +static ANTLR3_BITWORD FOLLOW_NOT_in_expr154_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  4164. +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_expr154 = { FOLLOW_NOT_in_expr154_bits, 1 };
  4165. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_expr160 */
  4166. +static ANTLR3_BITWORD FOLLOW_strcrit_in_expr160_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  4167. +static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_expr160 = { FOLLOW_strcrit_in_expr160_bits, 1 };
  4168. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_expr174 */
  4169. +static ANTLR3_BITWORD FOLLOW_intcrit_in_expr174_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4170. +static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_expr174 = { FOLLOW_intcrit_in_expr174_bits, 1 };
  4171. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_expr184 */
  4172. +static ANTLR3_BITWORD FOLLOW_NOT_in_expr184_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  4173. +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_expr184 = { FOLLOW_NOT_in_expr184_bits, 1 };
  4174. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_expr190 */
  4175. +static ANTLR3_BITWORD FOLLOW_intcrit_in_expr190_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  4176. +static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_expr190 = { FOLLOW_intcrit_in_expr190_bits, 1 };
  4177. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_datecrit_in_expr204 */
  4178. +static ANTLR3_BITWORD FOLLOW_datecrit_in_expr204_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4179. +static ANTLR3_BITSET_LIST FOLLOW_datecrit_in_expr204 = { FOLLOW_datecrit_in_expr204_bits, 1 };
  4180. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit233 */
  4181. +static ANTLR3_BITWORD FOLLOW_strop_in_strcrit233_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  4182. +static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit233 = { FOLLOW_strop_in_strcrit233_bits, 1 };
  4183. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit239 */
  4184. +static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit239_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) };
  4185. +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit239 = { FOLLOW_FIELD_in_strcrit239_bits, 1 };
  4186. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit245 */
  4187. +static ANTLR3_BITWORD FOLLOW_STR_in_strcrit245_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  4188. +static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit245 = { FOLLOW_STR_in_strcrit245_bits, 1 };
  4189. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_strop274 */
  4190. +static ANTLR3_BITWORD FOLLOW_EQUAL_in_strop274_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4191. +static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_strop274 = { FOLLOW_EQUAL_in_strop274_bits, 1 };
  4192. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INCLUDES_in_strop287 */
  4193. +static ANTLR3_BITWORD FOLLOW_INCLUDES_in_strop287_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4194. +static ANTLR3_BITSET_LIST FOLLOW_INCLUDES_in_strop287 = { FOLLOW_INCLUDES_in_strop287_bits, 1 };
  4195. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STARTSW_in_strop300 */
  4196. +static ANTLR3_BITWORD FOLLOW_STARTSW_in_strop300_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4197. +static ANTLR3_BITSET_LIST FOLLOW_STARTSW_in_strop300 = { FOLLOW_STARTSW_in_strop300_bits, 1 };
  4198. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_ENDSW_in_strop313 */
  4199. +static ANTLR3_BITWORD FOLLOW_ENDSW_in_strop313_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4200. +static ANTLR3_BITSET_LIST FOLLOW_ENDSW_in_strop313 = { FOLLOW_ENDSW_in_strop313_bits, 1 };
  4201. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit342 */
  4202. +static ANTLR3_BITWORD FOLLOW_intop_in_intcrit342_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  4203. +static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit342 = { FOLLOW_intop_in_intcrit342_bits, 1 };
  4204. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit348 */
  4205. +static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit348_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) };
  4206. +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit348 = { FOLLOW_FIELD_in_intcrit348_bits, 1 };
  4207. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit354 */
  4208. +static ANTLR3_BITWORD FOLLOW_INT_in_intcrit354_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  4209. +static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit354 = { FOLLOW_INT_in_intcrit354_bits, 1 };
  4210. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_intop383 */
  4211. +static ANTLR3_BITWORD FOLLOW_EQUAL_in_intop383_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4212. +static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_intop383 = { FOLLOW_EQUAL_in_intop383_bits, 1 };
  4213. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LESS_in_intop396 */
  4214. +static ANTLR3_BITWORD FOLLOW_LESS_in_intop396_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4215. +static ANTLR3_BITSET_LIST FOLLOW_LESS_in_intop396 = { FOLLOW_LESS_in_intop396_bits, 1 };
  4216. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_GREATER_in_intop409 */
  4217. +static ANTLR3_BITWORD FOLLOW_GREATER_in_intop409_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4218. +static ANTLR3_BITSET_LIST FOLLOW_GREATER_in_intop409 = { FOLLOW_GREATER_in_intop409_bits, 1 };
  4219. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LTE_in_intop422 */
  4220. +static ANTLR3_BITWORD FOLLOW_LTE_in_intop422_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4221. +static ANTLR3_BITSET_LIST FOLLOW_LTE_in_intop422 = { FOLLOW_LTE_in_intop422_bits, 1 };
  4222. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_GTE_in_intop435 */
  4223. +static ANTLR3_BITWORD FOLLOW_GTE_in_intop435_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4224. +static ANTLR3_BITSET_LIST FOLLOW_GTE_in_intop435 = { FOLLOW_GTE_in_intop435_bits, 1 };
  4225. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datecrit464 */
  4226. +static ANTLR3_BITWORD FOLLOW_dateop_in_datecrit464_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  4227. +static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datecrit464 = { FOLLOW_dateop_in_datecrit464_bits, 1 };
  4228. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_datecrit470 */
  4229. +static ANTLR3_BITWORD FOLLOW_FIELD_in_datecrit470_bits[] = { ANTLR3_UINT64_LIT(0x0000000001FEF860) };
  4230. +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_datecrit470 = { FOLLOW_FIELD_in_datecrit470_bits, 1 };
  4231. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_datespec_in_datecrit476 */
  4232. +static ANTLR3_BITWORD FOLLOW_datespec_in_datecrit476_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  4233. +static ANTLR3_BITSET_LIST FOLLOW_datespec_in_datecrit476 = { FOLLOW_datespec_in_datecrit476_bits, 1 };
  4234. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_BEFORE_in_dateop505 */
  4235. +static ANTLR3_BITWORD FOLLOW_BEFORE_in_dateop505_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4236. +static ANTLR3_BITSET_LIST FOLLOW_BEFORE_in_dateop505 = { FOLLOW_BEFORE_in_dateop505_bits, 1 };
  4237. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AFTER_in_dateop518 */
  4238. +static ANTLR3_BITWORD FOLLOW_AFTER_in_dateop518_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4239. +static ANTLR3_BITSET_LIST FOLLOW_AFTER_in_dateop518 = { FOLLOW_AFTER_in_dateop518_bits, 1 };
  4240. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec546 */
  4241. +static ANTLR3_BITWORD FOLLOW_dateref_in_datespec546_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4242. +static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec546 = { FOLLOW_dateref_in_datespec546_bits, 1 };
  4243. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datespec560 */
  4244. +static ANTLR3_BITWORD FOLLOW_dateop_in_datespec560_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) };
  4245. +static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datespec560 = { FOLLOW_dateop_in_datespec560_bits, 1 };
  4246. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec566 */
  4247. +static ANTLR3_BITWORD FOLLOW_dateref_in_datespec566_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) };
  4248. +static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec566 = { FOLLOW_dateref_in_datespec566_bits, 1 };
  4249. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_datespec572 */
  4250. +static ANTLR3_BITWORD FOLLOW_INT_in_datespec572_bits[] = { ANTLR3_UINT64_LIT(0x000000001E000000) };
  4251. +static ANTLR3_BITSET_LIST FOLLOW_INT_in_datespec572 = { FOLLOW_INT_in_datespec572_bits, 1 };
  4252. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateintval_in_datespec578 */
  4253. +static ANTLR3_BITWORD FOLLOW_dateintval_in_datespec578_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) };
  4254. +static ANTLR3_BITSET_LIST FOLLOW_dateintval_in_datespec578 = { FOLLOW_dateintval_in_datespec578_bits, 1 };
  4255. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateref607 */
  4256. +static ANTLR3_BITWORD FOLLOW_DATE_in_dateref607_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4257. +static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateref607 = { FOLLOW_DATE_in_dateref607_bits, 1 };
  4258. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_TODAY_in_dateref616 */
  4259. +static ANTLR3_BITWORD FOLLOW_TODAY_in_dateref616_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4260. +static ANTLR3_BITSET_LIST FOLLOW_TODAY_in_dateref616 = { FOLLOW_TODAY_in_dateref616_bits, 1 };
  4261. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_DAY_in_dateintval640 */
  4262. +static ANTLR3_BITWORD FOLLOW_DAY_in_dateintval640_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4263. +static ANTLR3_BITSET_LIST FOLLOW_DAY_in_dateintval640 = { FOLLOW_DAY_in_dateintval640_bits, 1 };
  4264. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_WEEK_in_dateintval649 */
  4265. +static ANTLR3_BITWORD FOLLOW_WEEK_in_dateintval649_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4266. +static ANTLR3_BITSET_LIST FOLLOW_WEEK_in_dateintval649 = { FOLLOW_WEEK_in_dateintval649_bits, 1 };
  4267. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_MONTH_in_dateintval658 */
  4268. +static ANTLR3_BITWORD FOLLOW_MONTH_in_dateintval658_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4269. +static ANTLR3_BITSET_LIST FOLLOW_MONTH_in_dateintval658 = { FOLLOW_MONTH_in_dateintval658_bits, 1 };
  4270. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_YEAR_in_dateintval667 */
  4271. +static ANTLR3_BITWORD FOLLOW_YEAR_in_dateintval667_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  4272. +static ANTLR3_BITSET_LIST FOLLOW_YEAR_in_dateintval667 = { FOLLOW_YEAR_in_dateintval667_bits, 1 };
  4273. +
  4274. +
  4275. +
  4276. +
  4277. +/* ==============================================
  4278. + * Parsing rules
  4279. + */
  4280. +/**
  4281. + * $ANTLR start query
  4282. + * RSP2SQL.g:56:1: query returns [ pANTLR3_STRING result ] : e= expr ;
  4283. + */
  4284. +static pANTLR3_STRING
  4285. +query(pRSP2SQL ctx)
  4286. +{
  4287. + pANTLR3_STRING result = NULL;
  4288. +
  4289. + RSP2SQL_expr_return e;
  4290. + #undef RETURN_TYPE_e
  4291. + #define RETURN_TYPE_e RSP2SQL_expr_return
  4292. +
  4293. + /* Initialize rule variables
  4294. + */
  4295. +
  4296. +
  4297. + result= NULL;
  4298. + {
  4299. + // RSP2SQL.g:58:2: (e= expr )
  4300. + // RSP2SQL.g:58:4: e= expr
  4301. + {
  4302. + FOLLOWPUSH(FOLLOW_expr_in_query70);
  4303. + e=expr(ctx);
  4304. +
  4305. + FOLLOWPOP();
  4306. + if (HASEXCEPTION())
  4307. + {
  4308. + goto rulequeryEx;
  4309. + }
  4310. +
  4311. + {
  4312. +
  4313. + if (!e.valid)
  4314. + {
  4315. + result= NULL;
  4316. + }
  4317. + else
  4318. + {
  4319. + result= e.result->factory->newRaw(e.result->factory);
  4320. + result->append8(result, "(");
  4321. + result->appendS(result, e.result);
  4322. + result->append8(result, ")");
  4323. + }
  4324. +
  4325. + }
  4326. +
  4327. + }
  4328. +
  4329. + }
  4330. +
  4331. +
  4332. + // This is where rules clean up and exit
  4333. + //
  4334. + goto rulequeryEx; /* Prevent compiler warnings */
  4335. + rulequeryEx: ;
  4336. +
  4337. + if (HASEXCEPTION())
  4338. + {
  4339. + PREPORTERROR();
  4340. + PRECOVER();
  4341. + }
  4342. +
  4343. +
  4344. + return result;
  4345. +}
  4346. +/* $ANTLR end query */
  4347. +
  4348. +/**
  4349. + * $ANTLR start expr
  4350. + * RSP2SQL.g:74:1: expr returns [ pANTLR3_STRING result, int valid ] : ( ^( AND a= expr b= expr ) | ^( OR a= expr b= expr ) | c= strcrit | ^( NOT c= strcrit ) | i= intcrit | ^( NOT i= intcrit ) | d= datecrit );
  4351. + */
  4352. +static RSP2SQL_expr_return
  4353. +expr(pRSP2SQL ctx)
  4354. +{
  4355. + RSP2SQL_expr_return retval;
  4356. +
  4357. + RSP2SQL_expr_return a;
  4358. + #undef RETURN_TYPE_a
  4359. + #define RETURN_TYPE_a RSP2SQL_expr_return
  4360. +
  4361. + RSP2SQL_expr_return b;
  4362. + #undef RETURN_TYPE_b
  4363. + #define RETURN_TYPE_b RSP2SQL_expr_return
  4364. +
  4365. + RSP2SQL_strcrit_return c;
  4366. + #undef RETURN_TYPE_c
  4367. + #define RETURN_TYPE_c RSP2SQL_strcrit_return
  4368. +
  4369. + RSP2SQL_intcrit_return i;
  4370. + #undef RETURN_TYPE_i
  4371. + #define RETURN_TYPE_i RSP2SQL_intcrit_return
  4372. +
  4373. + RSP2SQL_datecrit_return d;
  4374. + #undef RETURN_TYPE_d
  4375. + #define RETURN_TYPE_d RSP2SQL_datecrit_return
  4376. +
  4377. + /* Initialize rule variables
  4378. + */
  4379. +
  4380. +
  4381. + retval.result= NULL; retval.valid= 1;
  4382. + retval.start = LT(1); retval.stop = retval.start;
  4383. +
  4384. + {
  4385. + {
  4386. + // RSP2SQL.g:76:2: ( ^( AND a= expr b= expr ) | ^( OR a= expr b= expr ) | c= strcrit | ^( NOT c= strcrit ) | i= intcrit | ^( NOT i= intcrit ) | d= datecrit )
  4387. +
  4388. + ANTLR3_UINT32 alt1;
  4389. +
  4390. + alt1=7;
  4391. +
  4392. + switch ( LA(1) )
  4393. + {
  4394. + case AND:
  4395. + {
  4396. + alt1=1;
  4397. + }
  4398. + break;
  4399. + case OR:
  4400. + {
  4401. + alt1=2;
  4402. + }
  4403. + break;
  4404. + case EQUAL:
  4405. + {
  4406. + switch ( LA(2) )
  4407. + {
  4408. + case DOWN:
  4409. + {
  4410. + switch ( LA(3) )
  4411. + {
  4412. + case FIELD:
  4413. + {
  4414. + switch ( LA(4) )
  4415. + {
  4416. + case INT:
  4417. + {
  4418. + alt1=5;
  4419. + }
  4420. + break;
  4421. + case STR:
  4422. + {
  4423. + alt1=3;
  4424. + }
  4425. + break;
  4426. +
  4427. + default:
  4428. + CONSTRUCTEX();
  4429. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  4430. + EXCEPTION->message = (void *)"";
  4431. + EXCEPTION->decisionNum = 1;
  4432. + EXCEPTION->state = 10;
  4433. +
  4434. +
  4435. + goto ruleexprEx;
  4436. + }
  4437. +
  4438. + }
  4439. + break;
  4440. +
  4441. + default:
  4442. + CONSTRUCTEX();
  4443. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  4444. + EXCEPTION->message = (void *)"";
  4445. + EXCEPTION->decisionNum = 1;
  4446. + EXCEPTION->state = 8;
  4447. +
  4448. +
  4449. + goto ruleexprEx;
  4450. + }
  4451. +
  4452. + }
  4453. + break;
  4454. +
  4455. + default:
  4456. + CONSTRUCTEX();
  4457. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  4458. + EXCEPTION->message = (void *)"";
  4459. + EXCEPTION->decisionNum = 1;
  4460. + EXCEPTION->state = 3;
  4461. +
  4462. +
  4463. + goto ruleexprEx;
  4464. + }
  4465. +
  4466. + }
  4467. + break;
  4468. + case INCLUDES:
  4469. + case STARTSW:
  4470. + case ENDSW:
  4471. + {
  4472. + alt1=3;
  4473. + }
  4474. + break;
  4475. + case NOT:
  4476. + {
  4477. + switch ( LA(2) )
  4478. + {
  4479. + case DOWN:
  4480. + {
  4481. + switch ( LA(3) )
  4482. + {
  4483. + case EQUAL:
  4484. + {
  4485. + switch ( LA(4) )
  4486. + {
  4487. + case DOWN:
  4488. + {
  4489. + switch ( LA(5) )
  4490. + {
  4491. + case FIELD:
  4492. + {
  4493. + switch ( LA(6) )
  4494. + {
  4495. + case STR:
  4496. + {
  4497. + alt1=4;
  4498. + }
  4499. + break;
  4500. + case INT:
  4501. + {
  4502. + alt1=6;
  4503. + }
  4504. + break;
  4505. +
  4506. + default:
  4507. + CONSTRUCTEX();
  4508. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  4509. + EXCEPTION->message = (void *)"";
  4510. + EXCEPTION->decisionNum = 1;
  4511. + EXCEPTION->state = 15;
  4512. +
  4513. +
  4514. + goto ruleexprEx;
  4515. + }
  4516. +
  4517. + }
  4518. + break;
  4519. +
  4520. + default:
  4521. + CONSTRUCTEX();
  4522. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  4523. + EXCEPTION->message = (void *)"";
  4524. + EXCEPTION->decisionNum = 1;
  4525. + EXCEPTION->state = 14;
  4526. +
  4527. +
  4528. + goto ruleexprEx;
  4529. + }
  4530. +
  4531. + }
  4532. + break;
  4533. +
  4534. + default:
  4535. + CONSTRUCTEX();
  4536. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  4537. + EXCEPTION->message = (void *)"";
  4538. + EXCEPTION->decisionNum = 1;
  4539. + EXCEPTION->state = 11;
  4540. +
  4541. +
  4542. + goto ruleexprEx;
  4543. + }
  4544. +
  4545. + }
  4546. + break;
  4547. + case LESS:
  4548. + case GREATER:
  4549. + case LTE:
  4550. + case GTE:
  4551. + {
  4552. + alt1=6;
  4553. + }
  4554. + break;
  4555. + case INCLUDES:
  4556. + case STARTSW:
  4557. + case ENDSW:
  4558. + {
  4559. + alt1=4;
  4560. + }
  4561. + break;
  4562. +
  4563. + default:
  4564. + CONSTRUCTEX();
  4565. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  4566. + EXCEPTION->message = (void *)"";
  4567. + EXCEPTION->decisionNum = 1;
  4568. + EXCEPTION->state = 9;
  4569. +
  4570. +
  4571. + goto ruleexprEx;
  4572. + }
  4573. +
  4574. + }
  4575. + break;
  4576. +
  4577. + default:
  4578. + CONSTRUCTEX();
  4579. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  4580. + EXCEPTION->message = (void *)"";
  4581. + EXCEPTION->decisionNum = 1;
  4582. + EXCEPTION->state = 5;
  4583. +
  4584. +
  4585. + goto ruleexprEx;
  4586. + }
  4587. +
  4588. + }
  4589. + break;
  4590. + case LESS:
  4591. + case GREATER:
  4592. + case LTE:
  4593. + case GTE:
  4594. + {
  4595. + alt1=5;
  4596. + }
  4597. + break;
  4598. + case BEFORE:
  4599. + case AFTER:
  4600. + {
  4601. + alt1=7;
  4602. + }
  4603. + break;
  4604. +
  4605. + default:
  4606. + CONSTRUCTEX();
  4607. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  4608. + EXCEPTION->message = (void *)"";
  4609. + EXCEPTION->decisionNum = 1;
  4610. + EXCEPTION->state = 0;
  4611. +
  4612. +
  4613. + goto ruleexprEx;
  4614. + }
  4615. +
  4616. + switch (alt1)
  4617. + {
  4618. + case 1:
  4619. + // RSP2SQL.g:76:4: ^( AND a= expr b= expr )
  4620. + {
  4621. + MATCHT(AND, &FOLLOW_AND_in_expr95);
  4622. + if (HASEXCEPTION())
  4623. + {
  4624. + goto ruleexprEx;
  4625. + }
  4626. +
  4627. +
  4628. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  4629. + if (HASEXCEPTION())
  4630. + {
  4631. + goto ruleexprEx;
  4632. + }
  4633. +
  4634. + FOLLOWPUSH(FOLLOW_expr_in_expr101);
  4635. + a=expr(ctx);
  4636. +
  4637. + FOLLOWPOP();
  4638. + if (HASEXCEPTION())
  4639. + {
  4640. + goto ruleexprEx;
  4641. + }
  4642. +
  4643. + FOLLOWPUSH(FOLLOW_expr_in_expr107);
  4644. + b=expr(ctx);
  4645. +
  4646. + FOLLOWPOP();
  4647. + if (HASEXCEPTION())
  4648. + {
  4649. + goto ruleexprEx;
  4650. + }
  4651. +
  4652. +
  4653. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  4654. + if (HASEXCEPTION())
  4655. + {
  4656. + goto ruleexprEx;
  4657. + }
  4658. +
  4659. + {
  4660. +
  4661. + if (!a.valid || !b.valid)
  4662. + {
  4663. + retval.valid= 0;
  4664. + }
  4665. + else
  4666. + {
  4667. + retval.result= a.result->factory->newRaw(a.result->factory);
  4668. + retval.result->append8(retval.result, "(");
  4669. + retval.result->appendS(retval.result, a.result);
  4670. + retval.result->append8(retval.result, " AND ");
  4671. + retval.result->appendS(retval.result, b.result);
  4672. + retval.result->append8(retval.result, ")");
  4673. + }
  4674. +
  4675. + }
  4676. +
  4677. + }
  4678. + break;
  4679. + case 2:
  4680. + // RSP2SQL.g:92:4: ^( OR a= expr b= expr )
  4681. + {
  4682. + MATCHT(OR, &FOLLOW_OR_in_expr118);
  4683. + if (HASEXCEPTION())
  4684. + {
  4685. + goto ruleexprEx;
  4686. + }
  4687. +
  4688. +
  4689. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  4690. + if (HASEXCEPTION())
  4691. + {
  4692. + goto ruleexprEx;
  4693. + }
  4694. +
  4695. + FOLLOWPUSH(FOLLOW_expr_in_expr124);
  4696. + a=expr(ctx);
  4697. +
  4698. + FOLLOWPOP();
  4699. + if (HASEXCEPTION())
  4700. + {
  4701. + goto ruleexprEx;
  4702. + }
  4703. +
  4704. + FOLLOWPUSH(FOLLOW_expr_in_expr130);
  4705. + b=expr(ctx);
  4706. +
  4707. + FOLLOWPOP();
  4708. + if (HASEXCEPTION())
  4709. + {
  4710. + goto ruleexprEx;
  4711. + }
  4712. +
  4713. +
  4714. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  4715. + if (HASEXCEPTION())
  4716. + {
  4717. + goto ruleexprEx;
  4718. + }
  4719. +
  4720. + {
  4721. +
  4722. + if (!a.valid || !b.valid)
  4723. + {
  4724. + retval.valid= 0;
  4725. + }
  4726. + else
  4727. + {
  4728. + retval.result= a.result->factory->newRaw(a.result->factory);
  4729. + retval.result->append8(retval.result, "(");
  4730. + retval.result->appendS(retval.result, a.result);
  4731. + retval.result->append8(retval.result, " OR ");
  4732. + retval.result->appendS(retval.result, b.result);
  4733. + retval.result->append8(retval.result, ")");
  4734. + }
  4735. +
  4736. + }
  4737. +
  4738. + }
  4739. + break;
  4740. + case 3:
  4741. + // RSP2SQL.g:108:4: c= strcrit
  4742. + {
  4743. + FOLLOWPUSH(FOLLOW_strcrit_in_expr144);
  4744. + c=strcrit(ctx);
  4745. +
  4746. + FOLLOWPOP();
  4747. + if (HASEXCEPTION())
  4748. + {
  4749. + goto ruleexprEx;
  4750. + }
  4751. +
  4752. + {
  4753. +
  4754. + retval.valid= c.valid;
  4755. + retval.result= c.result;
  4756. +
  4757. + }
  4758. +
  4759. + }
  4760. + break;
  4761. + case 4:
  4762. + // RSP2SQL.g:113:4: ^( NOT c= strcrit )
  4763. + {
  4764. + MATCHT(NOT, &FOLLOW_NOT_in_expr154);
  4765. + if (HASEXCEPTION())
  4766. + {
  4767. + goto ruleexprEx;
  4768. + }
  4769. +
  4770. +
  4771. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  4772. + if (HASEXCEPTION())
  4773. + {
  4774. + goto ruleexprEx;
  4775. + }
  4776. +
  4777. + FOLLOWPUSH(FOLLOW_strcrit_in_expr160);
  4778. + c=strcrit(ctx);
  4779. +
  4780. + FOLLOWPOP();
  4781. + if (HASEXCEPTION())
  4782. + {
  4783. + goto ruleexprEx;
  4784. + }
  4785. +
  4786. +
  4787. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  4788. + if (HASEXCEPTION())
  4789. + {
  4790. + goto ruleexprEx;
  4791. + }
  4792. +
  4793. + {
  4794. +
  4795. + if (!c.valid)
  4796. + {
  4797. + retval.valid= 0;
  4798. + }
  4799. + else
  4800. + {
  4801. + retval.result= c.result->factory->newRaw(c.result->factory);
  4802. + retval.result->append8(retval.result, "(NOT ");
  4803. + retval.result->appendS(retval.result, c.result);
  4804. + retval.result->append8(retval.result, ")");
  4805. + }
  4806. +
  4807. + }
  4808. +
  4809. + }
  4810. + break;
  4811. + case 5:
  4812. + // RSP2SQL.g:127:4: i= intcrit
  4813. + {
  4814. + FOLLOWPUSH(FOLLOW_intcrit_in_expr174);
  4815. + i=intcrit(ctx);
  4816. +
  4817. + FOLLOWPOP();
  4818. + if (HASEXCEPTION())
  4819. + {
  4820. + goto ruleexprEx;
  4821. + }
  4822. +
  4823. + {
  4824. +
  4825. + retval.valid= i.valid;
  4826. + retval.result= i.result;
  4827. +
  4828. + }
  4829. +
  4830. + }
  4831. + break;
  4832. + case 6:
  4833. + // RSP2SQL.g:132:4: ^( NOT i= intcrit )
  4834. + {
  4835. + MATCHT(NOT, &FOLLOW_NOT_in_expr184);
  4836. + if (HASEXCEPTION())
  4837. + {
  4838. + goto ruleexprEx;
  4839. + }
  4840. +
  4841. +
  4842. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  4843. + if (HASEXCEPTION())
  4844. + {
  4845. + goto ruleexprEx;
  4846. + }
  4847. +
  4848. + FOLLOWPUSH(FOLLOW_intcrit_in_expr190);
  4849. + i=intcrit(ctx);
  4850. +
  4851. + FOLLOWPOP();
  4852. + if (HASEXCEPTION())
  4853. + {
  4854. + goto ruleexprEx;
  4855. + }
  4856. +
  4857. +
  4858. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  4859. + if (HASEXCEPTION())
  4860. + {
  4861. + goto ruleexprEx;
  4862. + }
  4863. +
  4864. + {
  4865. +
  4866. + if (!i.valid)
  4867. + {
  4868. + retval.valid= 0;
  4869. + }
  4870. + else
  4871. + {
  4872. + retval.result= i.result->factory->newRaw(i.result->factory);
  4873. + retval.result->append8(retval.result, "(NOT ");
  4874. + retval.result->appendS(retval.result, i.result);
  4875. + retval.result->append8(retval.result, ")");
  4876. + }
  4877. +
  4878. + }
  4879. +
  4880. + }
  4881. + break;
  4882. + case 7:
  4883. + // RSP2SQL.g:146:4: d= datecrit
  4884. + {
  4885. + FOLLOWPUSH(FOLLOW_datecrit_in_expr204);
  4886. + d=datecrit(ctx);
  4887. +
  4888. + FOLLOWPOP();
  4889. + if (HASEXCEPTION())
  4890. + {
  4891. + goto ruleexprEx;
  4892. + }
  4893. +
  4894. + {
  4895. +
  4896. + retval.valid= d.valid;
  4897. + retval.result= d.result;
  4898. +
  4899. + }
  4900. +
  4901. + }
  4902. + break;
  4903. +
  4904. + }
  4905. + }
  4906. + }
  4907. +
  4908. +
  4909. + // This is where rules clean up and exit
  4910. + //
  4911. + goto ruleexprEx; /* Prevent compiler warnings */
  4912. + ruleexprEx: ;
  4913. +
  4914. + if (HASEXCEPTION())
  4915. + {
  4916. + PREPORTERROR();
  4917. + PRECOVER();
  4918. + }
  4919. +
  4920. +
  4921. + return retval;
  4922. +}
  4923. +/* $ANTLR end expr */
  4924. +
  4925. +/**
  4926. + * $ANTLR start strcrit
  4927. + * RSP2SQL.g:153:1: strcrit returns [ pANTLR3_STRING result, int valid ] : ^(o= strop f= FIELD s= STR ) ;
  4928. + */
  4929. +static RSP2SQL_strcrit_return
  4930. +strcrit(pRSP2SQL ctx)
  4931. +{
  4932. + RSP2SQL_strcrit_return retval;
  4933. +
  4934. + pANTLR3_BASE_TREE f;
  4935. + pANTLR3_BASE_TREE s;
  4936. + pANTLR3_COMMON_TOKEN o;
  4937. + #undef RETURN_TYPE_o
  4938. + #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN
  4939. +
  4940. + /* Initialize rule variables
  4941. + */
  4942. +
  4943. +
  4944. + retval.result= NULL; retval.valid= 1;
  4945. + f = NULL;
  4946. + s = NULL;
  4947. + o = NULL;
  4948. + retval.start = LT(1); retval.stop = retval.start;
  4949. +
  4950. + {
  4951. + // RSP2SQL.g:155:2: ( ^(o= strop f= FIELD s= STR ) )
  4952. + // RSP2SQL.g:155:4: ^(o= strop f= FIELD s= STR )
  4953. + {
  4954. + FOLLOWPUSH(FOLLOW_strop_in_strcrit233);
  4955. + o=strop(ctx);
  4956. +
  4957. + FOLLOWPOP();
  4958. + if (HASEXCEPTION())
  4959. + {
  4960. + goto rulestrcritEx;
  4961. + }
  4962. +
  4963. +
  4964. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  4965. + if (HASEXCEPTION())
  4966. + {
  4967. + goto rulestrcritEx;
  4968. + }
  4969. +
  4970. + f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit239);
  4971. + if (HASEXCEPTION())
  4972. + {
  4973. + goto rulestrcritEx;
  4974. + }
  4975. +
  4976. + s = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_strcrit245);
  4977. + if (HASEXCEPTION())
  4978. + {
  4979. + goto rulestrcritEx;
  4980. + }
  4981. +
  4982. +
  4983. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  4984. + if (HASEXCEPTION())
  4985. + {
  4986. + goto rulestrcritEx;
  4987. + }
  4988. +
  4989. + {
  4990. +
  4991. + char *op;
  4992. + const struct rsp_query_field_map *rqfp;
  4993. + pANTLR3_STRING field;
  4994. + char *escaped;
  4995. + ANTLR3_UINT32 optok;
  4996. +
  4997. + escaped = NULL;
  4998. +
  4999. + op = NULL;
  5000. + optok = o->getType(o);
  5001. + switch (optok)
  5002. + {
  5003. + case EQUAL:
  5004. + op = " = ";
  5005. + break;
  5006. +
  5007. + case INCLUDES:
  5008. + case STARTSW:
  5009. + case ENDSW:
  5010. + op = " LIKE ";
  5011. + break;
  5012. + }
  5013. +
  5014. + field = f->getText(f);
  5015. +
  5016. + /* Field lookup */
  5017. + rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars));
  5018. + if (!rqfp)
  5019. + {
  5020. + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars);
  5021. + retval.valid= 0;
  5022. + goto strcrit_valid_0; /* ABORT */
  5023. + }
  5024. +
  5025. + /* Check field type */
  5026. + if (rqfp->field_type != RSP_TYPE_STRING)
  5027. + {
  5028. + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a string field\n", field->chars);
  5029. + retval.valid= 0;
  5030. + goto strcrit_valid_0; /* ABORT */
  5031. + }
  5032. +
  5033. + escaped = db_escape_string((char *)s->getText(s)->chars);
  5034. + if (!escaped)
  5035. + {
  5036. + DPRINTF(E_LOG, L_RSP, "Could not escape value\n");
  5037. + retval.valid= 0;
  5038. + goto strcrit_valid_0; /* ABORT */
  5039. + }
  5040. +
  5041. + retval.result= field->factory->newRaw(field->factory);
  5042. + retval.result->append8(retval.result, "f.");
  5043. + retval.result->appendS(retval.result, field);
  5044. + retval.result->append8(retval.result, op);
  5045. + retval.result->append8(retval.result, "'");
  5046. + if ((optok == INCLUDES) || (optok == STARTSW))
  5047. + retval.result->append8(retval.result, "%");
  5048. +
  5049. + retval.result->append8(retval.result, escaped);
  5050. +
  5051. + if ((optok == INCLUDES) || (optok == ENDSW))
  5052. + retval.result->append8(retval.result, "%");
  5053. + retval.result->append8(retval.result, "'");
  5054. +
  5055. + strcrit_valid_0:
  5056. + ;
  5057. +
  5058. + if (escaped)
  5059. + free(escaped);
  5060. +
  5061. + }
  5062. +
  5063. + }
  5064. +
  5065. + }
  5066. +
  5067. +
  5068. + // This is where rules clean up and exit
  5069. + //
  5070. + goto rulestrcritEx; /* Prevent compiler warnings */
  5071. + rulestrcritEx: ;
  5072. +
  5073. + if (HASEXCEPTION())
  5074. + {
  5075. + PREPORTERROR();
  5076. + PRECOVER();
  5077. + }
  5078. +
  5079. +
  5080. + return retval;
  5081. +}
  5082. +/* $ANTLR end strcrit */
  5083. +
  5084. +/**
  5085. + * $ANTLR start strop
  5086. + * RSP2SQL.g:229:1: strop returns [ pANTLR3_COMMON_TOKEN op ] : (n= EQUAL | n= INCLUDES | n= STARTSW | n= ENDSW );
  5087. + */
  5088. +static pANTLR3_COMMON_TOKEN
  5089. +strop(pRSP2SQL ctx)
  5090. +{
  5091. + pANTLR3_COMMON_TOKEN op = NULL;
  5092. +
  5093. + pANTLR3_BASE_TREE n;
  5094. +
  5095. + /* Initialize rule variables
  5096. + */
  5097. +
  5098. +
  5099. + op= NULL;
  5100. + n = NULL;
  5101. +
  5102. + {
  5103. + {
  5104. + // RSP2SQL.g:231:2: (n= EQUAL | n= INCLUDES | n= STARTSW | n= ENDSW )
  5105. +
  5106. + ANTLR3_UINT32 alt2;
  5107. +
  5108. + alt2=4;
  5109. +
  5110. + switch ( LA(1) )
  5111. + {
  5112. + case EQUAL:
  5113. + {
  5114. + alt2=1;
  5115. + }
  5116. + break;
  5117. + case INCLUDES:
  5118. + {
  5119. + alt2=2;
  5120. + }
  5121. + break;
  5122. + case STARTSW:
  5123. + {
  5124. + alt2=3;
  5125. + }
  5126. + break;
  5127. + case ENDSW:
  5128. + {
  5129. + alt2=4;
  5130. + }
  5131. + break;
  5132. +
  5133. + default:
  5134. + CONSTRUCTEX();
  5135. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  5136. + EXCEPTION->message = (void *)"";
  5137. + EXCEPTION->decisionNum = 2;
  5138. + EXCEPTION->state = 0;
  5139. +
  5140. +
  5141. + goto rulestropEx;
  5142. + }
  5143. +
  5144. + switch (alt2)
  5145. + {
  5146. + case 1:
  5147. + // RSP2SQL.g:231:4: n= EQUAL
  5148. + {
  5149. + n = (pANTLR3_BASE_TREE) MATCHT(EQUAL, &FOLLOW_EQUAL_in_strop274);
  5150. + if (HASEXCEPTION())
  5151. + {
  5152. + goto rulestropEx;
  5153. + }
  5154. +
  5155. + {
  5156. + op= n->getToken(n);
  5157. + }
  5158. +
  5159. + }
  5160. + break;
  5161. + case 2:
  5162. + // RSP2SQL.g:233:4: n= INCLUDES
  5163. + {
  5164. + n = (pANTLR3_BASE_TREE) MATCHT(INCLUDES, &FOLLOW_INCLUDES_in_strop287);
  5165. + if (HASEXCEPTION())
  5166. + {
  5167. + goto rulestropEx;
  5168. + }
  5169. +
  5170. + {
  5171. + op= n->getToken(n);
  5172. + }
  5173. +
  5174. + }
  5175. + break;
  5176. + case 3:
  5177. + // RSP2SQL.g:235:4: n= STARTSW
  5178. + {
  5179. + n = (pANTLR3_BASE_TREE) MATCHT(STARTSW, &FOLLOW_STARTSW_in_strop300);
  5180. + if (HASEXCEPTION())
  5181. + {
  5182. + goto rulestropEx;
  5183. + }
  5184. +
  5185. + {
  5186. + op= n->getToken(n);
  5187. + }
  5188. +
  5189. + }
  5190. + break;
  5191. + case 4:
  5192. + // RSP2SQL.g:237:4: n= ENDSW
  5193. + {
  5194. + n = (pANTLR3_BASE_TREE) MATCHT(ENDSW, &FOLLOW_ENDSW_in_strop313);
  5195. + if (HASEXCEPTION())
  5196. + {
  5197. + goto rulestropEx;
  5198. + }
  5199. +
  5200. + {
  5201. + op= n->getToken(n);
  5202. + }
  5203. +
  5204. + }
  5205. + break;
  5206. +
  5207. + }
  5208. + }
  5209. + }
  5210. +
  5211. +
  5212. + // This is where rules clean up and exit
  5213. + //
  5214. + goto rulestropEx; /* Prevent compiler warnings */
  5215. + rulestropEx: ;
  5216. +
  5217. + if (HASEXCEPTION())
  5218. + {
  5219. + PREPORTERROR();
  5220. + PRECOVER();
  5221. + }
  5222. +
  5223. +
  5224. + return op;
  5225. +}
  5226. +/* $ANTLR end strop */
  5227. +
  5228. +/**
  5229. + * $ANTLR start intcrit
  5230. + * RSP2SQL.g:241:1: intcrit returns [ pANTLR3_STRING result, int valid ] : ^(o= intop f= FIELD i= INT ) ;
  5231. + */
  5232. +static RSP2SQL_intcrit_return
  5233. +intcrit(pRSP2SQL ctx)
  5234. +{
  5235. + RSP2SQL_intcrit_return retval;
  5236. +
  5237. + pANTLR3_BASE_TREE f;
  5238. + pANTLR3_BASE_TREE i;
  5239. + pANTLR3_COMMON_TOKEN o;
  5240. + #undef RETURN_TYPE_o
  5241. + #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN
  5242. +
  5243. + /* Initialize rule variables
  5244. + */
  5245. +
  5246. +
  5247. + retval.result= NULL; retval.valid= 1;
  5248. + f = NULL;
  5249. + i = NULL;
  5250. + o = NULL;
  5251. + retval.start = LT(1); retval.stop = retval.start;
  5252. +
  5253. + {
  5254. + // RSP2SQL.g:243:2: ( ^(o= intop f= FIELD i= INT ) )
  5255. + // RSP2SQL.g:243:4: ^(o= intop f= FIELD i= INT )
  5256. + {
  5257. + FOLLOWPUSH(FOLLOW_intop_in_intcrit342);
  5258. + o=intop(ctx);
  5259. +
  5260. + FOLLOWPOP();
  5261. + if (HASEXCEPTION())
  5262. + {
  5263. + goto ruleintcritEx;
  5264. + }
  5265. +
  5266. +
  5267. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  5268. + if (HASEXCEPTION())
  5269. + {
  5270. + goto ruleintcritEx;
  5271. + }
  5272. +
  5273. + f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit348);
  5274. + if (HASEXCEPTION())
  5275. + {
  5276. + goto ruleintcritEx;
  5277. + }
  5278. +
  5279. + i = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_intcrit354);
  5280. + if (HASEXCEPTION())
  5281. + {
  5282. + goto ruleintcritEx;
  5283. + }
  5284. +
  5285. +
  5286. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  5287. + if (HASEXCEPTION())
  5288. + {
  5289. + goto ruleintcritEx;
  5290. + }
  5291. +
  5292. + {
  5293. +
  5294. + char *op;
  5295. + const struct rsp_query_field_map *rqfp;
  5296. + pANTLR3_STRING field;
  5297. +
  5298. + op = NULL;
  5299. + switch (o->getType(o))
  5300. + {
  5301. + case EQUAL:
  5302. + op = " = ";
  5303. + break;
  5304. +
  5305. + case LESS:
  5306. + op = " < ";
  5307. + break;
  5308. +
  5309. + case GREATER:
  5310. + op = " > ";
  5311. + break;
  5312. +
  5313. + case LTE:
  5314. + op = " <= ";
  5315. + break;
  5316. +
  5317. + case GTE:
  5318. + op = " >= ";
  5319. + break;
  5320. + }
  5321. +
  5322. + field = f->getText(f);
  5323. +
  5324. + /* Field lookup */
  5325. + rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars));
  5326. + if (!rqfp)
  5327. + {
  5328. + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars);
  5329. + retval.valid= 0;
  5330. + goto intcrit_valid_0; /* ABORT */
  5331. + }
  5332. +
  5333. + /* Check field type */
  5334. + if (rqfp->field_type != RSP_TYPE_INT)
  5335. + {
  5336. + DPRINTF(E_LOG, L_RSP, "Field '%s' is not an integer field\n", field->chars);
  5337. + retval.valid= 0;
  5338. + goto intcrit_valid_0; /* ABORT */
  5339. + }
  5340. +
  5341. + retval.result= field->factory->newRaw(field->factory);
  5342. + retval.result->append8(retval.result, "f.");
  5343. + retval.result->appendS(retval.result, field);
  5344. + retval.result->append8(retval.result, op);
  5345. + retval.result->appendS(retval.result, i->getText(i));
  5346. +
  5347. + intcrit_valid_0:
  5348. + ;
  5349. +
  5350. + }
  5351. +
  5352. + }
  5353. +
  5354. + }
  5355. +
  5356. +
  5357. + // This is where rules clean up and exit
  5358. + //
  5359. + goto ruleintcritEx; /* Prevent compiler warnings */
  5360. + ruleintcritEx: ;
  5361. +
  5362. + if (HASEXCEPTION())
  5363. + {
  5364. + PREPORTERROR();
  5365. + PRECOVER();
  5366. + }
  5367. +
  5368. +
  5369. + return retval;
  5370. +}
  5371. +/* $ANTLR end intcrit */
  5372. +
  5373. +/**
  5374. + * $ANTLR start intop
  5375. + * RSP2SQL.g:303:1: intop returns [ pANTLR3_COMMON_TOKEN op ] : (n= EQUAL | n= LESS | n= GREATER | n= LTE | n= GTE );
  5376. + */
  5377. +static pANTLR3_COMMON_TOKEN
  5378. +intop(pRSP2SQL ctx)
  5379. +{
  5380. + pANTLR3_COMMON_TOKEN op = NULL;
  5381. +
  5382. + pANTLR3_BASE_TREE n;
  5383. +
  5384. + /* Initialize rule variables
  5385. + */
  5386. +
  5387. +
  5388. + op= NULL;
  5389. + n = NULL;
  5390. +
  5391. + {
  5392. + {
  5393. + // RSP2SQL.g:305:2: (n= EQUAL | n= LESS | n= GREATER | n= LTE | n= GTE )
  5394. +
  5395. + ANTLR3_UINT32 alt3;
  5396. +
  5397. + alt3=5;
  5398. +
  5399. + switch ( LA(1) )
  5400. + {
  5401. + case EQUAL:
  5402. + {
  5403. + alt3=1;
  5404. + }
  5405. + break;
  5406. + case LESS:
  5407. + {
  5408. + alt3=2;
  5409. + }
  5410. + break;
  5411. + case GREATER:
  5412. + {
  5413. + alt3=3;
  5414. + }
  5415. + break;
  5416. + case LTE:
  5417. + {
  5418. + alt3=4;
  5419. + }
  5420. + break;
  5421. + case GTE:
  5422. + {
  5423. + alt3=5;
  5424. + }
  5425. + break;
  5426. +
  5427. + default:
  5428. + CONSTRUCTEX();
  5429. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  5430. + EXCEPTION->message = (void *)"";
  5431. + EXCEPTION->decisionNum = 3;
  5432. + EXCEPTION->state = 0;
  5433. +
  5434. +
  5435. + goto ruleintopEx;
  5436. + }
  5437. +
  5438. + switch (alt3)
  5439. + {
  5440. + case 1:
  5441. + // RSP2SQL.g:305:4: n= EQUAL
  5442. + {
  5443. + n = (pANTLR3_BASE_TREE) MATCHT(EQUAL, &FOLLOW_EQUAL_in_intop383);
  5444. + if (HASEXCEPTION())
  5445. + {
  5446. + goto ruleintopEx;
  5447. + }
  5448. +
  5449. + {
  5450. + op= n->getToken(n);
  5451. + }
  5452. +
  5453. + }
  5454. + break;
  5455. + case 2:
  5456. + // RSP2SQL.g:307:4: n= LESS
  5457. + {
  5458. + n = (pANTLR3_BASE_TREE) MATCHT(LESS, &FOLLOW_LESS_in_intop396);
  5459. + if (HASEXCEPTION())
  5460. + {
  5461. + goto ruleintopEx;
  5462. + }
  5463. +
  5464. + {
  5465. + op= n->getToken(n);
  5466. + }
  5467. +
  5468. + }
  5469. + break;
  5470. + case 3:
  5471. + // RSP2SQL.g:309:4: n= GREATER
  5472. + {
  5473. + n = (pANTLR3_BASE_TREE) MATCHT(GREATER, &FOLLOW_GREATER_in_intop409);
  5474. + if (HASEXCEPTION())
  5475. + {
  5476. + goto ruleintopEx;
  5477. + }
  5478. +
  5479. + {
  5480. + op= n->getToken(n);
  5481. + }
  5482. +
  5483. + }
  5484. + break;
  5485. + case 4:
  5486. + // RSP2SQL.g:311:4: n= LTE
  5487. + {
  5488. + n = (pANTLR3_BASE_TREE) MATCHT(LTE, &FOLLOW_LTE_in_intop422);
  5489. + if (HASEXCEPTION())
  5490. + {
  5491. + goto ruleintopEx;
  5492. + }
  5493. +
  5494. + {
  5495. + op= n->getToken(n);
  5496. + }
  5497. +
  5498. + }
  5499. + break;
  5500. + case 5:
  5501. + // RSP2SQL.g:313:4: n= GTE
  5502. + {
  5503. + n = (pANTLR3_BASE_TREE) MATCHT(GTE, &FOLLOW_GTE_in_intop435);
  5504. + if (HASEXCEPTION())
  5505. + {
  5506. + goto ruleintopEx;
  5507. + }
  5508. +
  5509. + {
  5510. + op= n->getToken(n);
  5511. + }
  5512. +
  5513. + }
  5514. + break;
  5515. +
  5516. + }
  5517. + }
  5518. + }
  5519. +
  5520. +
  5521. + // This is where rules clean up and exit
  5522. + //
  5523. + goto ruleintopEx; /* Prevent compiler warnings */
  5524. + ruleintopEx: ;
  5525. +
  5526. + if (HASEXCEPTION())
  5527. + {
  5528. + PREPORTERROR();
  5529. + PRECOVER();
  5530. + }
  5531. +
  5532. +
  5533. + return op;
  5534. +}
  5535. +/* $ANTLR end intop */
  5536. +
  5537. +/**
  5538. + * $ANTLR start datecrit
  5539. + * RSP2SQL.g:317:1: datecrit returns [ pANTLR3_STRING result, int valid ] : ^(o= dateop f= FIELD d= datespec ) ;
  5540. + */
  5541. +static RSP2SQL_datecrit_return
  5542. +datecrit(pRSP2SQL ctx)
  5543. +{
  5544. + RSP2SQL_datecrit_return retval;
  5545. +
  5546. + pANTLR3_BASE_TREE f;
  5547. + pANTLR3_COMMON_TOKEN o;
  5548. + #undef RETURN_TYPE_o
  5549. + #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN
  5550. +
  5551. + RSP2SQL_datespec_return d;
  5552. + #undef RETURN_TYPE_d
  5553. + #define RETURN_TYPE_d RSP2SQL_datespec_return
  5554. +
  5555. + /* Initialize rule variables
  5556. + */
  5557. +
  5558. +
  5559. + retval.result= NULL; retval.valid= 1;
  5560. + f = NULL;
  5561. + o = NULL;
  5562. + retval.start = LT(1); retval.stop = retval.start;
  5563. +
  5564. + {
  5565. + // RSP2SQL.g:319:2: ( ^(o= dateop f= FIELD d= datespec ) )
  5566. + // RSP2SQL.g:319:4: ^(o= dateop f= FIELD d= datespec )
  5567. + {
  5568. + FOLLOWPUSH(FOLLOW_dateop_in_datecrit464);
  5569. + o=dateop(ctx);
  5570. +
  5571. + FOLLOWPOP();
  5572. + if (HASEXCEPTION())
  5573. + {
  5574. + goto ruledatecritEx;
  5575. + }
  5576. +
  5577. +
  5578. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  5579. + if (HASEXCEPTION())
  5580. + {
  5581. + goto ruledatecritEx;
  5582. + }
  5583. +
  5584. + f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_datecrit470);
  5585. + if (HASEXCEPTION())
  5586. + {
  5587. + goto ruledatecritEx;
  5588. + }
  5589. +
  5590. + FOLLOWPUSH(FOLLOW_datespec_in_datecrit476);
  5591. + d=datespec(ctx);
  5592. +
  5593. + FOLLOWPOP();
  5594. + if (HASEXCEPTION())
  5595. + {
  5596. + goto ruledatecritEx;
  5597. + }
  5598. +
  5599. +
  5600. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  5601. + if (HASEXCEPTION())
  5602. + {
  5603. + goto ruledatecritEx;
  5604. + }
  5605. +
  5606. + {
  5607. +
  5608. + char *op;
  5609. + const struct rsp_query_field_map *rqfp;
  5610. + pANTLR3_STRING field;
  5611. + char buf[32];
  5612. + int ret;
  5613. +
  5614. + op = NULL;
  5615. + switch (o->getType(o))
  5616. + {
  5617. + case BEFORE:
  5618. + op = " < ";
  5619. + break;
  5620. +
  5621. + case AFTER:
  5622. + op = " > ";
  5623. + break;
  5624. + }
  5625. +
  5626. + field = f->getText(f);
  5627. +
  5628. + /* Field lookup */
  5629. + rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars));
  5630. + if (!rqfp)
  5631. + {
  5632. + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars);
  5633. + retval.valid= 0;
  5634. + goto datecrit_valid_0; /* ABORT */
  5635. + }
  5636. +
  5637. + /* Check field type */
  5638. + if (rqfp->field_type != RSP_TYPE_DATE)
  5639. + {
  5640. + DPRINTF(E_LOG, L_RSP, "Field '%s' is not a date field\n", field->chars);
  5641. + retval.valid= 0;
  5642. + goto datecrit_valid_0; /* ABORT */
  5643. + }
  5644. +
  5645. + ret = snprintf(buf, sizeof(buf), "%ld", d.date);
  5646. + if ((ret < 0) || (ret >= sizeof(buf)))
  5647. + {
  5648. + DPRINTF(E_LOG, L_RSP, "Date %ld too large for buffer, oops!\n", d.date);
  5649. + retval.valid= 0;
  5650. + goto datecrit_valid_0; /* ABORT */
  5651. + }
  5652. +
  5653. + retval.result= field->factory->newRaw(field->factory);
  5654. + retval.result->append8(retval.result, "f.");
  5655. + retval.result->appendS(retval.result, field);
  5656. + retval.result->append8(retval.result, op);
  5657. + retval.result->append8(retval.result, buf);
  5658. +
  5659. + datecrit_valid_0:
  5660. + ;
  5661. +
  5662. + }
  5663. +
  5664. + }
  5665. +
  5666. + }
  5667. +
  5668. +
  5669. + // This is where rules clean up and exit
  5670. + //
  5671. + goto ruledatecritEx; /* Prevent compiler warnings */
  5672. + ruledatecritEx: ;
  5673. +
  5674. + if (HASEXCEPTION())
  5675. + {
  5676. + PREPORTERROR();
  5677. + PRECOVER();
  5678. + }
  5679. +
  5680. +
  5681. + return retval;
  5682. +}
  5683. +/* $ANTLR end datecrit */
  5684. +
  5685. +/**
  5686. + * $ANTLR start dateop
  5687. + * RSP2SQL.g:377:1: dateop returns [ pANTLR3_COMMON_TOKEN op ] : (n= BEFORE | n= AFTER );
  5688. + */
  5689. +static pANTLR3_COMMON_TOKEN
  5690. +dateop(pRSP2SQL ctx)
  5691. +{
  5692. + pANTLR3_COMMON_TOKEN op = NULL;
  5693. +
  5694. + pANTLR3_BASE_TREE n;
  5695. +
  5696. + /* Initialize rule variables
  5697. + */
  5698. +
  5699. +
  5700. + op= NULL;
  5701. + n = NULL;
  5702. +
  5703. + {
  5704. + {
  5705. + // RSP2SQL.g:379:2: (n= BEFORE | n= AFTER )
  5706. +
  5707. + ANTLR3_UINT32 alt4;
  5708. +
  5709. + alt4=2;
  5710. +
  5711. + switch ( LA(1) )
  5712. + {
  5713. + case BEFORE:
  5714. + {
  5715. + alt4=1;
  5716. + }
  5717. + break;
  5718. + case AFTER:
  5719. + {
  5720. + alt4=2;
  5721. + }
  5722. + break;
  5723. +
  5724. + default:
  5725. + CONSTRUCTEX();
  5726. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  5727. + EXCEPTION->message = (void *)"";
  5728. + EXCEPTION->decisionNum = 4;
  5729. + EXCEPTION->state = 0;
  5730. +
  5731. +
  5732. + goto ruledateopEx;
  5733. + }
  5734. +
  5735. + switch (alt4)
  5736. + {
  5737. + case 1:
  5738. + // RSP2SQL.g:379:4: n= BEFORE
  5739. + {
  5740. + n = (pANTLR3_BASE_TREE) MATCHT(BEFORE, &FOLLOW_BEFORE_in_dateop505);
  5741. + if (HASEXCEPTION())
  5742. + {
  5743. + goto ruledateopEx;
  5744. + }
  5745. +
  5746. + {
  5747. + op= n->getToken(n);
  5748. + }
  5749. +
  5750. + }
  5751. + break;
  5752. + case 2:
  5753. + // RSP2SQL.g:381:4: n= AFTER
  5754. + {
  5755. + n = (pANTLR3_BASE_TREE) MATCHT(AFTER, &FOLLOW_AFTER_in_dateop518);
  5756. + if (HASEXCEPTION())
  5757. + {
  5758. + goto ruledateopEx;
  5759. + }
  5760. +
  5761. + {
  5762. + op= n->getToken(n);
  5763. + }
  5764. +
  5765. + }
  5766. + break;
  5767. +
  5768. + }
  5769. + }
  5770. + }
  5771. +
  5772. +
  5773. + // This is where rules clean up and exit
  5774. + //
  5775. + goto ruledateopEx; /* Prevent compiler warnings */
  5776. + ruledateopEx: ;
  5777. +
  5778. + if (HASEXCEPTION())
  5779. + {
  5780. + PREPORTERROR();
  5781. + PRECOVER();
  5782. + }
  5783. +
  5784. +
  5785. + return op;
  5786. +}
  5787. +/* $ANTLR end dateop */
  5788. +
  5789. +/**
  5790. + * $ANTLR start datespec
  5791. + * RSP2SQL.g:385:1: datespec returns [ time_t date, int valid ] : (r= dateref | ^(o= dateop r= dateref m= INT i= dateintval ) );
  5792. + */
  5793. +static RSP2SQL_datespec_return
  5794. +datespec(pRSP2SQL ctx)
  5795. +{
  5796. + RSP2SQL_datespec_return retval;
  5797. +
  5798. + pANTLR3_BASE_TREE m;
  5799. + RSP2SQL_dateref_return r;
  5800. + #undef RETURN_TYPE_r
  5801. + #define RETURN_TYPE_r RSP2SQL_dateref_return
  5802. +
  5803. + pANTLR3_COMMON_TOKEN o;
  5804. + #undef RETURN_TYPE_o
  5805. + #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN
  5806. +
  5807. + RSP2SQL_dateintval_return i;
  5808. + #undef RETURN_TYPE_i
  5809. + #define RETURN_TYPE_i RSP2SQL_dateintval_return
  5810. +
  5811. + /* Initialize rule variables
  5812. + */
  5813. +
  5814. +
  5815. + retval.date= 0; retval.valid= 1;
  5816. + m = NULL;
  5817. + o = NULL;
  5818. + retval.start = LT(1); retval.stop = retval.start;
  5819. +
  5820. + {
  5821. + {
  5822. + // RSP2SQL.g:387:2: (r= dateref | ^(o= dateop r= dateref m= INT i= dateintval ) )
  5823. +
  5824. + ANTLR3_UINT32 alt5;
  5825. +
  5826. + alt5=2;
  5827. +
  5828. + switch ( LA(1) )
  5829. + {
  5830. + case DATE:
  5831. + case TODAY:
  5832. + {
  5833. + alt5=1;
  5834. + }
  5835. + break;
  5836. + case BEFORE:
  5837. + case AFTER:
  5838. + {
  5839. + alt5=2;
  5840. + }
  5841. + break;
  5842. +
  5843. + default:
  5844. + CONSTRUCTEX();
  5845. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  5846. + EXCEPTION->message = (void *)"";
  5847. + EXCEPTION->decisionNum = 5;
  5848. + EXCEPTION->state = 0;
  5849. +
  5850. +
  5851. + goto ruledatespecEx;
  5852. + }
  5853. +
  5854. + switch (alt5)
  5855. + {
  5856. + case 1:
  5857. + // RSP2SQL.g:387:4: r= dateref
  5858. + {
  5859. + FOLLOWPUSH(FOLLOW_dateref_in_datespec546);
  5860. + r=dateref(ctx);
  5861. +
  5862. + FOLLOWPOP();
  5863. + if (HASEXCEPTION())
  5864. + {
  5865. + goto ruledatespecEx;
  5866. + }
  5867. +
  5868. + {
  5869. +
  5870. + if (!r.valid)
  5871. + retval.valid= 0;
  5872. + else
  5873. + retval.date= r.date;
  5874. +
  5875. + }
  5876. +
  5877. + }
  5878. + break;
  5879. + case 2:
  5880. + // RSP2SQL.g:394:4: ^(o= dateop r= dateref m= INT i= dateintval )
  5881. + {
  5882. + FOLLOWPUSH(FOLLOW_dateop_in_datespec560);
  5883. + o=dateop(ctx);
  5884. +
  5885. + FOLLOWPOP();
  5886. + if (HASEXCEPTION())
  5887. + {
  5888. + goto ruledatespecEx;
  5889. + }
  5890. +
  5891. +
  5892. + MATCHT(ANTLR3_TOKEN_DOWN, NULL);
  5893. + if (HASEXCEPTION())
  5894. + {
  5895. + goto ruledatespecEx;
  5896. + }
  5897. +
  5898. + FOLLOWPUSH(FOLLOW_dateref_in_datespec566);
  5899. + r=dateref(ctx);
  5900. +
  5901. + FOLLOWPOP();
  5902. + if (HASEXCEPTION())
  5903. + {
  5904. + goto ruledatespecEx;
  5905. + }
  5906. +
  5907. + m = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_datespec572);
  5908. + if (HASEXCEPTION())
  5909. + {
  5910. + goto ruledatespecEx;
  5911. + }
  5912. +
  5913. + FOLLOWPUSH(FOLLOW_dateintval_in_datespec578);
  5914. + i=dateintval(ctx);
  5915. +
  5916. + FOLLOWPOP();
  5917. + if (HASEXCEPTION())
  5918. + {
  5919. + goto ruledatespecEx;
  5920. + }
  5921. +
  5922. +
  5923. + MATCHT(ANTLR3_TOKEN_UP, NULL);
  5924. + if (HASEXCEPTION())
  5925. + {
  5926. + goto ruledatespecEx;
  5927. + }
  5928. +
  5929. + {
  5930. +
  5931. + int32_t val;
  5932. + int ret;
  5933. +
  5934. + if (!r.valid || !i.valid)
  5935. + {
  5936. + retval.valid= 0;
  5937. + goto datespec_valid_0; /* ABORT */
  5938. + }
  5939. +
  5940. + ret = safe_atoi32((char *)m->getText(m)->chars, &val);
  5941. + if (ret < 0)
  5942. + {
  5943. + DPRINTF(E_LOG, L_RSP, "Could not convert '%s' to integer\n", (char *)m->getText(m));
  5944. + retval.valid= 0;
  5945. + goto datespec_valid_0; /* ABORT */
  5946. + }
  5947. +
  5948. + switch (o->getType(o))
  5949. + {
  5950. + case BEFORE:
  5951. + retval.date= r.date - (val * i.period);
  5952. + break;
  5953. +
  5954. + case AFTER:
  5955. + retval.date= r.date + (val * i.period);
  5956. + break;
  5957. + }
  5958. +
  5959. + datespec_valid_0:
  5960. + ;
  5961. +
  5962. + }
  5963. +
  5964. + }
  5965. + break;
  5966. +
  5967. + }
  5968. + }
  5969. + }
  5970. +
  5971. +
  5972. + // This is where rules clean up and exit
  5973. + //
  5974. + goto ruledatespecEx; /* Prevent compiler warnings */
  5975. + ruledatespecEx: ;
  5976. +
  5977. + if (HASEXCEPTION())
  5978. + {
  5979. + PREPORTERROR();
  5980. + PRECOVER();
  5981. + }
  5982. +
  5983. +
  5984. + return retval;
  5985. +}
  5986. +/* $ANTLR end datespec */
  5987. +
  5988. +/**
  5989. + * $ANTLR start dateref
  5990. + * RSP2SQL.g:429:1: dateref returns [ time_t date, int valid ] : (n= DATE | TODAY );
  5991. + */
  5992. +static RSP2SQL_dateref_return
  5993. +dateref(pRSP2SQL ctx)
  5994. +{
  5995. + RSP2SQL_dateref_return retval;
  5996. +
  5997. + pANTLR3_BASE_TREE n;
  5998. +
  5999. + /* Initialize rule variables
  6000. + */
  6001. +
  6002. +
  6003. + retval.date= 0; retval.valid= 1;
  6004. + n = NULL;
  6005. + retval.start = LT(1); retval.stop = retval.start;
  6006. +
  6007. + {
  6008. + {
  6009. + // RSP2SQL.g:431:2: (n= DATE | TODAY )
  6010. +
  6011. + ANTLR3_UINT32 alt6;
  6012. +
  6013. + alt6=2;
  6014. +
  6015. + switch ( LA(1) )
  6016. + {
  6017. + case DATE:
  6018. + {
  6019. + alt6=1;
  6020. + }
  6021. + break;
  6022. + case TODAY:
  6023. + {
  6024. + alt6=2;
  6025. + }
  6026. + break;
  6027. +
  6028. + default:
  6029. + CONSTRUCTEX();
  6030. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  6031. + EXCEPTION->message = (void *)"";
  6032. + EXCEPTION->decisionNum = 6;
  6033. + EXCEPTION->state = 0;
  6034. +
  6035. +
  6036. + goto ruledaterefEx;
  6037. + }
  6038. +
  6039. + switch (alt6)
  6040. + {
  6041. + case 1:
  6042. + // RSP2SQL.g:431:4: n= DATE
  6043. + {
  6044. + n = (pANTLR3_BASE_TREE) MATCHT(DATE, &FOLLOW_DATE_in_dateref607);
  6045. + if (HASEXCEPTION())
  6046. + {
  6047. + goto ruledaterefEx;
  6048. + }
  6049. +
  6050. + {
  6051. +
  6052. + struct tm tm;
  6053. + char *ret;
  6054. +
  6055. + ret = strptime((char *)n->getText(n), "%Y-%m-%d", &tm);
  6056. + if (!ret)
  6057. + {
  6058. + DPRINTF(E_LOG, L_RSP, "Date '%s' could not be interpreted\n", (char *)n->getText(n));
  6059. + retval.valid= 0;
  6060. + goto dateref_valid_0; /* ABORT */
  6061. + }
  6062. + else
  6063. + {
  6064. + if (*ret != '\0')
  6065. + DPRINTF(E_LOG, L_RSP, "Garbage at end of date '%s' ?!\n", (char *)n->getText(n));
  6066. +
  6067. + retval.date= mktime(&tm);
  6068. + if (retval.date == (time_t) -1)
  6069. + {
  6070. + DPRINTF(E_LOG, L_RSP, "Date '%s' could not be converted to an epoch\n", (char *)n->getText(n));
  6071. + retval.valid= 0;
  6072. + goto dateref_valid_0; /* ABORT */
  6073. + }
  6074. + }
  6075. +
  6076. + dateref_valid_0:
  6077. + ;
  6078. +
  6079. + }
  6080. +
  6081. + }
  6082. + break;
  6083. + case 2:
  6084. + // RSP2SQL.g:460:4: TODAY
  6085. + {
  6086. + MATCHT(TODAY, &FOLLOW_TODAY_in_dateref616);
  6087. + if (HASEXCEPTION())
  6088. + {
  6089. + goto ruledaterefEx;
  6090. + }
  6091. +
  6092. + {
  6093. + retval.date= time(NULL);
  6094. + }
  6095. +
  6096. + }
  6097. + break;
  6098. +
  6099. + }
  6100. + }
  6101. + }
  6102. +
  6103. +
  6104. + // This is where rules clean up and exit
  6105. + //
  6106. + goto ruledaterefEx; /* Prevent compiler warnings */
  6107. + ruledaterefEx: ;
  6108. +
  6109. + if (HASEXCEPTION())
  6110. + {
  6111. + PREPORTERROR();
  6112. + PRECOVER();
  6113. + }
  6114. +
  6115. +
  6116. + return retval;
  6117. +}
  6118. +/* $ANTLR end dateref */
  6119. +
  6120. +/**
  6121. + * $ANTLR start dateintval
  6122. + * RSP2SQL.g:464:1: dateintval returns [ time_t period, int valid ] : ( DAY | WEEK | MONTH | YEAR );
  6123. + */
  6124. +static RSP2SQL_dateintval_return
  6125. +dateintval(pRSP2SQL ctx)
  6126. +{
  6127. + RSP2SQL_dateintval_return retval;
  6128. +
  6129. + /* Initialize rule variables
  6130. + */
  6131. +
  6132. +
  6133. + retval.period= 0; retval.valid= 1;
  6134. + retval.start = LT(1); retval.stop = retval.start;
  6135. +
  6136. + {
  6137. + {
  6138. + // RSP2SQL.g:466:2: ( DAY | WEEK | MONTH | YEAR )
  6139. +
  6140. + ANTLR3_UINT32 alt7;
  6141. +
  6142. + alt7=4;
  6143. +
  6144. + switch ( LA(1) )
  6145. + {
  6146. + case DAY:
  6147. + {
  6148. + alt7=1;
  6149. + }
  6150. + break;
  6151. + case WEEK:
  6152. + {
  6153. + alt7=2;
  6154. + }
  6155. + break;
  6156. + case MONTH:
  6157. + {
  6158. + alt7=3;
  6159. + }
  6160. + break;
  6161. + case YEAR:
  6162. + {
  6163. + alt7=4;
  6164. + }
  6165. + break;
  6166. +
  6167. + default:
  6168. + CONSTRUCTEX();
  6169. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  6170. + EXCEPTION->message = (void *)"";
  6171. + EXCEPTION->decisionNum = 7;
  6172. + EXCEPTION->state = 0;
  6173. +
  6174. +
  6175. + goto ruledateintvalEx;
  6176. + }
  6177. +
  6178. + switch (alt7)
  6179. + {
  6180. + case 1:
  6181. + // RSP2SQL.g:466:4: DAY
  6182. + {
  6183. + MATCHT(DAY, &FOLLOW_DAY_in_dateintval640);
  6184. + if (HASEXCEPTION())
  6185. + {
  6186. + goto ruledateintvalEx;
  6187. + }
  6188. +
  6189. + {
  6190. + retval.period= 24 * 60 * 60;
  6191. + }
  6192. +
  6193. + }
  6194. + break;
  6195. + case 2:
  6196. + // RSP2SQL.g:468:4: WEEK
  6197. + {
  6198. + MATCHT(WEEK, &FOLLOW_WEEK_in_dateintval649);
  6199. + if (HASEXCEPTION())
  6200. + {
  6201. + goto ruledateintvalEx;
  6202. + }
  6203. +
  6204. + {
  6205. + retval.period= 7 * 24 * 60 * 60;
  6206. + }
  6207. +
  6208. + }
  6209. + break;
  6210. + case 3:
  6211. + // RSP2SQL.g:470:4: MONTH
  6212. + {
  6213. + MATCHT(MONTH, &FOLLOW_MONTH_in_dateintval658);
  6214. + if (HASEXCEPTION())
  6215. + {
  6216. + goto ruledateintvalEx;
  6217. + }
  6218. +
  6219. + {
  6220. + retval.period= 30 * 24 * 60 * 60;
  6221. + }
  6222. +
  6223. + }
  6224. + break;
  6225. + case 4:
  6226. + // RSP2SQL.g:472:4: YEAR
  6227. + {
  6228. + MATCHT(YEAR, &FOLLOW_YEAR_in_dateintval667);
  6229. + if (HASEXCEPTION())
  6230. + {
  6231. + goto ruledateintvalEx;
  6232. + }
  6233. +
  6234. + {
  6235. + retval.period= 365 * 24 * 60 * 60;
  6236. + }
  6237. +
  6238. + }
  6239. + break;
  6240. +
  6241. + }
  6242. + }
  6243. + }
  6244. +
  6245. +
  6246. + // This is where rules clean up and exit
  6247. + //
  6248. + goto ruledateintvalEx; /* Prevent compiler warnings */
  6249. + ruledateintvalEx: ;
  6250. +
  6251. + if (HASEXCEPTION())
  6252. + {
  6253. + PREPORTERROR();
  6254. + PRECOVER();
  6255. + }
  6256. +
  6257. +
  6258. + return retval;
  6259. +}
  6260. +/* $ANTLR end dateintval */
  6261. +/* End of parsing rules
  6262. + * ==============================================
  6263. + */
  6264. +
  6265. +/* ==============================================
  6266. + * Syntactic predicates
  6267. + */
  6268. +/* End of syntactic predicates
  6269. + * ==============================================
  6270. + */
  6271. +
  6272. +
  6273. +
  6274. +
  6275. +
  6276. +
  6277. +/* End of code
  6278. + * =============================================================================
  6279. + */
  6280. diff --git a/src/pregen/RSP2SQL.h b/src/pregen/RSP2SQL.h
  6281. new file mode 100644
  6282. index 0000000..2789fc7
  6283. --- /dev/null
  6284. +++ b/src/pregen/RSP2SQL.h
  6285. @@ -0,0 +1,291 @@
  6286. +/** \file
  6287. + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
  6288. + *
  6289. + * - From the grammar source file : RSP2SQL.g
  6290. + * - On : 2014-09-30 21:42:42
  6291. + * - for the tree parser : RSP2SQLTreeParser *
  6292. + * Editing it, at least manually, is not wise.
  6293. + *
  6294. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  6295. + *
  6296. + *
  6297. + * The tree parser RSP2SQL has the callable functions (rules) shown below,
  6298. + * which will invoke the code for the associated rule in the source grammar
  6299. + * assuming that the input stream is pointing to a token/text stream that could begin
  6300. + * this rule.
  6301. + *
  6302. + * For instance if you call the first (topmost) rule in a parser grammar, you will
  6303. + * get the results of a full parse, but calling a rule half way through the grammar will
  6304. + * allow you to pass part of a full token stream to the parser, such as for syntax checking
  6305. + * in editors and so on.
  6306. + *
  6307. + * The parser entry points are called indirectly (by function pointer to function) via
  6308. + * a parser context typedef pRSP2SQL, which is returned from a call to RSP2SQLNew().
  6309. + *
  6310. + * The methods in pRSP2SQL are as follows:
  6311. + *
  6312. + * - pANTLR3_STRING pRSP2SQL->query(pRSP2SQL)
  6313. + * - RSP2SQL_expr_return pRSP2SQL->expr(pRSP2SQL)
  6314. + * - RSP2SQL_strcrit_return pRSP2SQL->strcrit(pRSP2SQL)
  6315. + * - pANTLR3_COMMON_TOKEN pRSP2SQL->strop(pRSP2SQL)
  6316. + * - RSP2SQL_intcrit_return pRSP2SQL->intcrit(pRSP2SQL)
  6317. + * - pANTLR3_COMMON_TOKEN pRSP2SQL->intop(pRSP2SQL)
  6318. + * - RSP2SQL_datecrit_return pRSP2SQL->datecrit(pRSP2SQL)
  6319. + * - pANTLR3_COMMON_TOKEN pRSP2SQL->dateop(pRSP2SQL)
  6320. + * - RSP2SQL_datespec_return pRSP2SQL->datespec(pRSP2SQL)
  6321. + * - RSP2SQL_dateref_return pRSP2SQL->dateref(pRSP2SQL)
  6322. + * - RSP2SQL_dateintval_return pRSP2SQL->dateintval(pRSP2SQL)
  6323. + *
  6324. + * The return type for any particular rule is of course determined by the source
  6325. + * grammar file.
  6326. + */
  6327. +// [The "BSD licence"]
  6328. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  6329. +// http://www.temporal-wave.com
  6330. +// http://www.linkedin.com/in/jimidle
  6331. +//
  6332. +// All rights reserved.
  6333. +//
  6334. +// Redistribution and use in source and binary forms, with or without
  6335. +// modification, are permitted provided that the following conditions
  6336. +// are met:
  6337. +// 1. Redistributions of source code must retain the above copyright
  6338. +// notice, this list of conditions and the following disclaimer.
  6339. +// 2. Redistributions in binary form must reproduce the above copyright
  6340. +// notice, this list of conditions and the following disclaimer in the
  6341. +// documentation and/or other materials provided with the distribution.
  6342. +// 3. The name of the author may not be used to endorse or promote products
  6343. +// derived from this software without specific prior written permission.
  6344. +//
  6345. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  6346. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  6347. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  6348. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  6349. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  6350. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  6351. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6352. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6353. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  6354. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6355. +
  6356. +#ifndef _RSP2SQL_H
  6357. +#define _RSP2SQL_H
  6358. +/* =============================================================================
  6359. + * Standard antlr3 C runtime definitions
  6360. + */
  6361. +#include <antlr3.h>
  6362. +
  6363. +/* End of standard antlr 3 runtime definitions
  6364. + * =============================================================================
  6365. + */
  6366. +
  6367. +#ifdef __cplusplus
  6368. +extern "C" {
  6369. +#endif
  6370. +
  6371. +// Forward declare the context typedef so that we can use it before it is
  6372. +// properly defined. Delegators and delegates (from import statements) are
  6373. +// interdependent and their context structures contain pointers to each other
  6374. +// C only allows such things to be declared if you pre-declare the typedef.
  6375. +//
  6376. +typedef struct RSP2SQL_Ctx_struct RSP2SQL, * pRSP2SQL;
  6377. +
  6378. +
  6379. +
  6380. + /* Needs #define _GNU_SOURCE for strptime() */
  6381. +
  6382. + #include <stdio.h>
  6383. + #include <string.h>
  6384. + #include <time.h>
  6385. + #include <stdint.h>
  6386. +
  6387. + #include "logger.h"
  6388. + #include "db.h"
  6389. + #include "misc.h"
  6390. + #include "rsp_query.h"
  6391. +
  6392. +
  6393. +#ifdef ANTLR3_WINDOWS
  6394. +// Disable: Unreferenced parameter, - Rules with parameters that are not used
  6395. +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
  6396. +// initialized but unused variable - tree rewrite variables declared but not needed
  6397. +// Unreferenced local variable - lexer rule declares but does not always use _type
  6398. +// potentially unitialized variable used - retval always returned from a rule
  6399. +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
  6400. +//
  6401. +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
  6402. +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
  6403. +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
  6404. +// this is a matter of orthogonality hence I disable that one.
  6405. +//
  6406. +#pragma warning( disable : 4100 )
  6407. +#pragma warning( disable : 4101 )
  6408. +#pragma warning( disable : 4127 )
  6409. +#pragma warning( disable : 4189 )
  6410. +#pragma warning( disable : 4505 )
  6411. +#pragma warning( disable : 4701 )
  6412. +#endif
  6413. +typedef struct RSP2SQL_expr_return_struct
  6414. +{
  6415. + pANTLR3_BASE_TREE start;
  6416. + pANTLR3_BASE_TREE stop;
  6417. + pANTLR3_STRING result;
  6418. + int valid;
  6419. +}
  6420. + RSP2SQL_expr_return;
  6421. +
  6422. +typedef struct RSP2SQL_strcrit_return_struct
  6423. +{
  6424. + pANTLR3_BASE_TREE start;
  6425. + pANTLR3_BASE_TREE stop;
  6426. + pANTLR3_STRING result;
  6427. + int valid;
  6428. +}
  6429. + RSP2SQL_strcrit_return;
  6430. +
  6431. +typedef struct RSP2SQL_intcrit_return_struct
  6432. +{
  6433. + pANTLR3_BASE_TREE start;
  6434. + pANTLR3_BASE_TREE stop;
  6435. + pANTLR3_STRING result;
  6436. + int valid;
  6437. +}
  6438. + RSP2SQL_intcrit_return;
  6439. +
  6440. +typedef struct RSP2SQL_datecrit_return_struct
  6441. +{
  6442. + pANTLR3_BASE_TREE start;
  6443. + pANTLR3_BASE_TREE stop;
  6444. + pANTLR3_STRING result;
  6445. + int valid;
  6446. +}
  6447. + RSP2SQL_datecrit_return;
  6448. +
  6449. +typedef struct RSP2SQL_datespec_return_struct
  6450. +{
  6451. + pANTLR3_BASE_TREE start;
  6452. + pANTLR3_BASE_TREE stop;
  6453. + time_t date;
  6454. + int valid;
  6455. +}
  6456. + RSP2SQL_datespec_return;
  6457. +
  6458. +typedef struct RSP2SQL_dateref_return_struct
  6459. +{
  6460. + pANTLR3_BASE_TREE start;
  6461. + pANTLR3_BASE_TREE stop;
  6462. + time_t date;
  6463. + int valid;
  6464. +}
  6465. + RSP2SQL_dateref_return;
  6466. +
  6467. +typedef struct RSP2SQL_dateintval_return_struct
  6468. +{
  6469. + pANTLR3_BASE_TREE start;
  6470. + pANTLR3_BASE_TREE stop;
  6471. + time_t period;
  6472. + int valid;
  6473. +}
  6474. + RSP2SQL_dateintval_return;
  6475. +
  6476. +
  6477. +
  6478. +/** Context tracking structure for RSP2SQL
  6479. + */
  6480. +struct RSP2SQL_Ctx_struct
  6481. +{
  6482. + /** Built in ANTLR3 context tracker contains all the generic elements
  6483. + * required for context tracking.
  6484. + */
  6485. + pANTLR3_TREE_PARSER pTreeParser;
  6486. +
  6487. +
  6488. + pANTLR3_STRING (*query) (struct RSP2SQL_Ctx_struct * ctx);
  6489. + RSP2SQL_expr_return (*expr) (struct RSP2SQL_Ctx_struct * ctx);
  6490. + RSP2SQL_strcrit_return (*strcrit) (struct RSP2SQL_Ctx_struct * ctx);
  6491. + pANTLR3_COMMON_TOKEN (*strop) (struct RSP2SQL_Ctx_struct * ctx);
  6492. + RSP2SQL_intcrit_return (*intcrit) (struct RSP2SQL_Ctx_struct * ctx);
  6493. + pANTLR3_COMMON_TOKEN (*intop) (struct RSP2SQL_Ctx_struct * ctx);
  6494. + RSP2SQL_datecrit_return (*datecrit) (struct RSP2SQL_Ctx_struct * ctx);
  6495. + pANTLR3_COMMON_TOKEN (*dateop) (struct RSP2SQL_Ctx_struct * ctx);
  6496. + RSP2SQL_datespec_return (*datespec) (struct RSP2SQL_Ctx_struct * ctx);
  6497. + RSP2SQL_dateref_return (*dateref) (struct RSP2SQL_Ctx_struct * ctx);
  6498. + RSP2SQL_dateintval_return (*dateintval) (struct RSP2SQL_Ctx_struct * ctx);
  6499. + // Delegated rules
  6500. + const char * (*getGrammarFileName)();
  6501. + void (*free) (struct RSP2SQL_Ctx_struct * ctx);
  6502. +
  6503. +};
  6504. +
  6505. +// Function protoypes for the constructor functions that external translation units
  6506. +// such as delegators and delegates may wish to call.
  6507. +//
  6508. +ANTLR3_API pRSP2SQL RSP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream);
  6509. +ANTLR3_API pRSP2SQL RSP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
  6510. +
  6511. +/** Symbolic definitions of all the tokens that the tree parser will work with.
  6512. + * \{
  6513. + *
  6514. + * Antlr will define EOF, but we can't use that as it it is too common in
  6515. + * in C header files and that would be confusing. There is no way to filter this out at the moment
  6516. + * so we just undef it here for now. That isn't the value we get back from C recognizers
  6517. + * anyway. We are looking for ANTLR3_TOKEN_EOF.
  6518. + */
  6519. +#ifdef EOF
  6520. +#undef EOF
  6521. +#endif
  6522. +#ifdef Tokens
  6523. +#undef Tokens
  6524. +#endif
  6525. +#define STARTSW 14
  6526. +#define WEEK 26
  6527. +#define TODAY 24
  6528. +#define YEAR 28
  6529. +#define ENDSW 15
  6530. +#define GTE 20
  6531. +#define BEFORE 21
  6532. +#define DAY 25
  6533. +#define INT 16
  6534. +#define NOT 11
  6535. +#define AFTER 22
  6536. +#define AND 6
  6537. +#define EOF -1
  6538. +#define LTE 19
  6539. +#define MONTH 27
  6540. +#define DIGIT19 31
  6541. +#define INCLUDES 13
  6542. +#define STR 10
  6543. +#define QUOTE 29
  6544. +#define GREATER 18
  6545. +#define WS 30
  6546. +#define LPAR 7
  6547. +#define NEWLINE 4
  6548. +#define EQUAL 12
  6549. +#define OR 5
  6550. +#define LESS 17
  6551. +#define FIELD 9
  6552. +#define RPAR 8
  6553. +#define ESCAPED 33
  6554. +#define DATE 23
  6555. +#define DIGIT09 32
  6556. +#ifdef EOF
  6557. +#undef EOF
  6558. +#define EOF ANTLR3_TOKEN_EOF
  6559. +#endif
  6560. +
  6561. +#ifndef TOKENSOURCE
  6562. +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
  6563. +#endif
  6564. +
  6565. +/* End of token definitions for RSP2SQL
  6566. + * =============================================================================
  6567. + */
  6568. +/** \} */
  6569. +
  6570. +#ifdef __cplusplus
  6571. +}
  6572. +#endif
  6573. +
  6574. +#endif
  6575. +
  6576. +/* END - Note:Keep extra line feed to satisfy UNIX systems */
  6577. diff --git a/src/pregen/RSP2SQL.u b/src/pregen/RSP2SQL.u
  6578. new file mode 100644
  6579. index 0000000..53d8cda
  6580. --- /dev/null
  6581. +++ b/src/pregen/RSP2SQL.u
  6582. @@ -0,0 +1,5 @@
  6583. +RSP2SQL.g: RSP.tokens
  6584. +RSP2SQL.c : RSP2SQL.g
  6585. +./RSP2SQL.tokens : RSP2SQL.g
  6586. +RSP2SQL.h : RSP2SQL.g
  6587. +ANTLR_PRODUCTS += RSP2SQL.c ./RSP2SQL.tokens RSP2SQL.h
  6588. \ No newline at end of file
  6589. diff --git a/src/pregen/RSPLexer.c b/src/pregen/RSPLexer.c
  6590. new file mode 100644
  6591. index 0000000..ee23c08
  6592. --- /dev/null
  6593. +++ b/src/pregen/RSPLexer.c
  6594. @@ -0,0 +1,4867 @@
  6595. +/** \file
  6596. + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
  6597. + *
  6598. + * - From the grammar source file : RSP.g
  6599. + * - On : 2014-09-30 21:42:41
  6600. + * - for the lexer : RSPLexerLexer *
  6601. + * Editing it, at least manually, is not wise.
  6602. + *
  6603. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  6604. + *
  6605. + *
  6606. +*/
  6607. +// [The "BSD licence"]
  6608. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  6609. +// http://www.temporal-wave.com
  6610. +// http://www.linkedin.com/in/jimidle
  6611. +//
  6612. +// All rights reserved.
  6613. +//
  6614. +// Redistribution and use in source and binary forms, with or without
  6615. +// modification, are permitted provided that the following conditions
  6616. +// are met:
  6617. +// 1. Redistributions of source code must retain the above copyright
  6618. +// notice, this list of conditions and the following disclaimer.
  6619. +// 2. Redistributions in binary form must reproduce the above copyright
  6620. +// notice, this list of conditions and the following disclaimer in the
  6621. +// documentation and/or other materials provided with the distribution.
  6622. +// 3. The name of the author may not be used to endorse or promote products
  6623. +// derived from this software without specific prior written permission.
  6624. +//
  6625. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  6626. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  6627. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  6628. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  6629. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  6630. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  6631. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6632. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6633. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  6634. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6635. +
  6636. +/* -----------------------------------------
  6637. + * Include the ANTLR3 generated header file.
  6638. + */
  6639. +#include "RSPLexer.h"
  6640. +/* ----------------------------------------- */
  6641. +
  6642. +
  6643. +/** String literals used by RSPLexer that we must do things like MATCHS() with.
  6644. + * C will normally just lay down 8 bit characters, and you can use L"xxx" to
  6645. + * get wchar_t, but wchar_t is 16 bits on Windows, which is not UTF32 and so
  6646. + * we perform this little trick of defining the literals as arrays of UINT32
  6647. + * and passing in the address of these.
  6648. + */
  6649. +static ANTLR3_UCHAR lit_1[] = { 0x61, 0x6E, 0x64, ANTLR3_STRING_TERMINATOR};
  6650. +static ANTLR3_UCHAR lit_2[] = { 0x6F, 0x72, ANTLR3_STRING_TERMINATOR};
  6651. +static ANTLR3_UCHAR lit_3[] = { 0x69, 0x6E, 0x63, 0x6C, 0x75, 0x64, 0x65, 0x73, ANTLR3_STRING_TERMINATOR};
  6652. +static ANTLR3_UCHAR lit_4[] = { 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x77, 0x69, 0x74, 0x68, ANTLR3_STRING_TERMINATOR};
  6653. +static ANTLR3_UCHAR lit_5[] = { 0x65, 0x6E, 0x64, 0x73, 0x77, 0x69, 0x74, 0x68, ANTLR3_STRING_TERMINATOR};
  6654. +static ANTLR3_UCHAR lit_6[] = { 0x3E, 0x3D, ANTLR3_STRING_TERMINATOR};
  6655. +static ANTLR3_UCHAR lit_7[] = { 0x3C, 0x3D, ANTLR3_STRING_TERMINATOR};
  6656. +static ANTLR3_UCHAR lit_8[] = { 0x62, 0x65, 0x66, 0x6F, 0x72, 0x65, ANTLR3_STRING_TERMINATOR};
  6657. +static ANTLR3_UCHAR lit_9[] = { 0x61, 0x66, 0x74, 0x65, 0x72, ANTLR3_STRING_TERMINATOR};
  6658. +static ANTLR3_UCHAR lit_10[] = { 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR};
  6659. +static ANTLR3_UCHAR lit_11[] = { 0x64, 0x61, 0x79, 0x73, ANTLR3_STRING_TERMINATOR};
  6660. +static ANTLR3_UCHAR lit_12[] = { 0x77, 0x65, 0x65, 0x6B, ANTLR3_STRING_TERMINATOR};
  6661. +static ANTLR3_UCHAR lit_13[] = { 0x77, 0x65, 0x65, 0x6B, 0x73, ANTLR3_STRING_TERMINATOR};
  6662. +static ANTLR3_UCHAR lit_14[] = { 0x6D, 0x6F, 0x6E, 0x74, 0x68, ANTLR3_STRING_TERMINATOR};
  6663. +static ANTLR3_UCHAR lit_15[] = { 0x6D, 0x6F, 0x6E, 0x74, 0x68, 0x73, ANTLR3_STRING_TERMINATOR};
  6664. +static ANTLR3_UCHAR lit_16[] = { 0x79, 0x65, 0x61, 0x72, ANTLR3_STRING_TERMINATOR};
  6665. +static ANTLR3_UCHAR lit_17[] = { 0x79, 0x65, 0x61, 0x72, 0x73, ANTLR3_STRING_TERMINATOR};
  6666. +static ANTLR3_UCHAR lit_18[] = { 0x74, 0x6F, 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR};
  6667. +
  6668. +
  6669. +
  6670. +
  6671. +/* MACROS that hide the C interface implementations from the
  6672. + * generated code, which makes it a little more understandable to the human eye.
  6673. + * I am very much against using C pre-processor macros for function calls and bits
  6674. + * of code as you cannot see what is happening when single stepping in debuggers
  6675. + * and so on. The exception (in my book at least) is for generated code, where you are
  6676. + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
  6677. + * hides some indirect calls, but is always referring to the input stream. This is
  6678. + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
  6679. + * the runtime interfaces without changing the generated code too often, without
  6680. + * confusing the reader of the generated output, who may not wish to know the gory
  6681. + * details of the interface inheritance.
  6682. + */
  6683. +
  6684. +#define CTX ctx
  6685. +
  6686. +/* Aids in accessing scopes for grammar programmers
  6687. + */
  6688. +#undef SCOPE_TYPE
  6689. +#undef SCOPE_STACK
  6690. +#undef SCOPE_TOP
  6691. +#define SCOPE_TYPE(scope) pRSPLexer_##scope##_SCOPE
  6692. +#define SCOPE_STACK(scope) pRSPLexer_##scope##Stack
  6693. +#define SCOPE_TOP(scope) ctx->pRSPLexer_##scope##Top
  6694. +#define SCOPE_SIZE(scope) ctx->pRSPLexer_##scope##Stack_limit
  6695. +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
  6696. +
  6697. +
  6698. +/* Macros for accessing things in a lexer
  6699. + */
  6700. +#undef LEXER
  6701. +#undef RECOGNIZER
  6702. +#undef RULEMEMO
  6703. +#undef GETCHARINDEX
  6704. +#undef GETLINE
  6705. +#undef GETCHARPOSITIONINLINE
  6706. +#undef EMIT
  6707. +#undef EMITNEW
  6708. +#undef MATCHC
  6709. +#undef MATCHS
  6710. +#undef MATCHRANGE
  6711. +#undef LTOKEN
  6712. +#undef HASFAILED
  6713. +#undef FAILEDFLAG
  6714. +#undef INPUT
  6715. +#undef STRSTREAM
  6716. +#undef LA
  6717. +#undef HASEXCEPTION
  6718. +#undef EXCEPTION
  6719. +#undef CONSTRUCTEX
  6720. +#undef CONSUME
  6721. +#undef LRECOVER
  6722. +#undef MARK
  6723. +#undef REWIND
  6724. +#undef REWINDLAST
  6725. +#undef BACKTRACKING
  6726. +#undef MATCHANY
  6727. +#undef MEMOIZE
  6728. +#undef HAVEPARSEDRULE
  6729. +#undef GETTEXT
  6730. +#undef INDEX
  6731. +#undef SEEK
  6732. +#undef PUSHSTREAM
  6733. +#undef POPSTREAM
  6734. +#undef SETTEXT
  6735. +#undef SETTEXT8
  6736. +
  6737. +#define LEXER ctx->pLexer
  6738. +#define RECOGNIZER LEXER->rec
  6739. +#define LEXSTATE RECOGNIZER->state
  6740. +#define TOKSOURCE LEXSTATE->tokSource
  6741. +#define GETCHARINDEX() LEXER->getCharIndex(LEXER)
  6742. +#define GETLINE() LEXER->getLine(LEXER)
  6743. +#define GETTEXT() LEXER->getText(LEXER)
  6744. +#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER)
  6745. +#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER)
  6746. +#define EMITNEW(t) LEXER->emitNew(LEXER, t)
  6747. +#define MATCHC(c) LEXER->matchc(LEXER, c)
  6748. +#define MATCHS(s) LEXER->matchs(LEXER, s)
  6749. +#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2)
  6750. +#define MATCHANY() LEXER->matchAny(LEXER)
  6751. +#define LTOKEN LEXSTATE->token
  6752. +#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE)
  6753. +#define BACKTRACKING LEXSTATE->backtracking
  6754. +#define FAILEDFLAG LEXSTATE->failed
  6755. +#define INPUT LEXER->input
  6756. +#define STRSTREAM INPUT
  6757. +#define ISTREAM INPUT->istream
  6758. +#define INDEX() ISTREAM->index(ISTREAM)
  6759. +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
  6760. +#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken)
  6761. +#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE)
  6762. +#define EXCEPTION LEXSTATE->exception
  6763. +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
  6764. +#define LRECOVER() LEXER->recover(LEXER)
  6765. +#define MARK() ISTREAM->mark(ISTREAM)
  6766. +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
  6767. +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
  6768. +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
  6769. +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
  6770. +#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str)
  6771. +#define POPSTREAM() LEXER->popCharStream(LEXER)
  6772. +#define SETTEXT(str) LEXSTATE->text = str
  6773. +#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken)
  6774. +#define USER1 LEXSTATE->user1
  6775. +#define USER2 LEXSTATE->user2
  6776. +#define USER3 LEXSTATE->user3
  6777. +#define CUSTOM LEXSTATE->custom
  6778. +#define RULEMEMO LEXSTATE->ruleMemo
  6779. +#define DBG RECOGNIZER->debugger
  6780. +
  6781. +/* If we have been told we can rely on the standard 8 bit or 16 bit input
  6782. + * stream, then we can define our macros to use the direct pointers
  6783. + * in the input object, which is much faster than indirect calls. This
  6784. + * is really only significant to lexers with a lot of fragment rules (which
  6785. + * do not place LA(1) in a temporary at the moment) and even then
  6786. + * only if there is a lot of input (order of say 1M or so).
  6787. + */
  6788. +#if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16)
  6789. +
  6790. +# ifdef ANTLR3_INLINE_INPUT_ASCII
  6791. +
  6792. +/* 8 bit "ASCII" (actually any 8 bit character set) */
  6793. +
  6794. +# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar))
  6795. +# define DATAP ((pANTLR3_UINT8)(INPUT->data))
  6796. +
  6797. +# else
  6798. +
  6799. +# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar))
  6800. +# define DATAP ((pANTLR3_UINT16)(INPUT->data))
  6801. +
  6802. +# endif
  6803. +
  6804. +# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1)))
  6805. +# define CONSUME() \
  6806. +{ \
  6807. + if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \
  6808. + { \
  6809. + INPUT->charPositionInLine++; \
  6810. + if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \
  6811. + { \
  6812. + INPUT->line++; \
  6813. + INPUT->charPositionInLine = 0; \
  6814. + INPUT->currentLine = (void *)(NEXTCHAR + 1); \
  6815. + } \
  6816. + INPUT->nextChar = (void *)(NEXTCHAR + 1); \
  6817. + } \
  6818. +}
  6819. +
  6820. +#else
  6821. +
  6822. +// Pick up the input character by calling the input stream implementation.
  6823. +//
  6824. +#define CONSUME() INPUT->istream->consume(INPUT->istream)
  6825. +#define LA(n) INPUT->istream->_LA(INPUT->istream, n)
  6826. +
  6827. +#endif
  6828. +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
  6829. +
  6830. +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
  6831. + * then for the present you must use different names for your defines as these are hard coded
  6832. + * in the code generator. It would be better not to use such names internally, and maybe
  6833. + * we can change this in a forthcoming release. I deliberately do not #undef these
  6834. + * here as this will at least give you a redefined error somewhere if they clash.
  6835. + */
  6836. +#define UP ANTLR3_TOKEN_UP
  6837. +#define DOWN ANTLR3_TOKEN_DOWN
  6838. +#define EOR ANTLR3_TOKEN_EOR
  6839. +#define INVALID ANTLR3_TOKEN_INVALID
  6840. +
  6841. +
  6842. +/* =============================================================================
  6843. + * Functions to create and destroy scopes. First come the rule scopes, followed
  6844. + * by the global declared scopes.
  6845. + */
  6846. +
  6847. +
  6848. +
  6849. +/* ============================================================================= */
  6850. +
  6851. +/* =============================================================================
  6852. + * Start of recognizer
  6853. + */
  6854. +
  6855. +
  6856. +/* Forward declare the locally static matching functions we have generated and any predicate functions.
  6857. + */
  6858. +static ANTLR3_INLINE void mQUOTE (pRSPLexer ctx);
  6859. +static ANTLR3_INLINE void mLPAR (pRSPLexer ctx);
  6860. +static ANTLR3_INLINE void mRPAR (pRSPLexer ctx);
  6861. +static ANTLR3_INLINE void mAND (pRSPLexer ctx);
  6862. +static ANTLR3_INLINE void mOR (pRSPLexer ctx);
  6863. +static ANTLR3_INLINE void mNOT (pRSPLexer ctx);
  6864. +static ANTLR3_INLINE void mEQUAL (pRSPLexer ctx);
  6865. +static ANTLR3_INLINE void mINCLUDES (pRSPLexer ctx);
  6866. +static ANTLR3_INLINE void mSTARTSW (pRSPLexer ctx);
  6867. +static ANTLR3_INLINE void mENDSW (pRSPLexer ctx);
  6868. +static ANTLR3_INLINE void mGREATER (pRSPLexer ctx);
  6869. +static ANTLR3_INLINE void mLESS (pRSPLexer ctx);
  6870. +static ANTLR3_INLINE void mGTE (pRSPLexer ctx);
  6871. +static ANTLR3_INLINE void mLTE (pRSPLexer ctx);
  6872. +static ANTLR3_INLINE void mBEFORE (pRSPLexer ctx);
  6873. +static ANTLR3_INLINE void mAFTER (pRSPLexer ctx);
  6874. +static ANTLR3_INLINE void mDAY (pRSPLexer ctx);
  6875. +static ANTLR3_INLINE void mWEEK (pRSPLexer ctx);
  6876. +static ANTLR3_INLINE void mMONTH (pRSPLexer ctx);
  6877. +static ANTLR3_INLINE void mYEAR (pRSPLexer ctx);
  6878. +static ANTLR3_INLINE void mTODAY (pRSPLexer ctx);
  6879. +static ANTLR3_INLINE void mNEWLINE (pRSPLexer ctx);
  6880. +static ANTLR3_INLINE void mWS (pRSPLexer ctx);
  6881. +static ANTLR3_INLINE void mFIELD (pRSPLexer ctx);
  6882. +static ANTLR3_INLINE void mINT (pRSPLexer ctx);
  6883. +static ANTLR3_INLINE void mDATE (pRSPLexer ctx);
  6884. +static ANTLR3_INLINE void mSTR (pRSPLexer ctx);
  6885. +static ANTLR3_INLINE void mESCAPED (pRSPLexer ctx);
  6886. +static ANTLR3_INLINE void mDIGIT09 (pRSPLexer ctx);
  6887. +static ANTLR3_INLINE void mDIGIT19 (pRSPLexer ctx);
  6888. +static ANTLR3_INLINE void mTokens (pRSPLexer ctx);
  6889. +static void RSPLexerFree(pRSPLexer ctx);
  6890. +
  6891. +/* =========================================================================
  6892. + * Lexer matching rules end.
  6893. + * =========================================================================
  6894. + */
  6895. +
  6896. +
  6897. +
  6898. +static void
  6899. +RSPLexerFree (pRSPLexer ctx)
  6900. +{
  6901. + LEXER->free(LEXER);
  6902. +
  6903. + ANTLR3_FREE(ctx);
  6904. +}
  6905. +
  6906. +/** \brief Name of the grammar file that generated this code
  6907. + */
  6908. +static const char fileName[] = "RSP.g";
  6909. +
  6910. +/** \brief Return the name of the grammar file that generated this code.
  6911. + */
  6912. +static const char * getGrammarFileName()
  6913. +{
  6914. + return fileName;
  6915. +}
  6916. +
  6917. +/** \brief Create a new lexer called RSPLexer
  6918. + *
  6919. + * \param[in] instream Pointer to an initialized input stream
  6920. + * \return
  6921. + * - Success pRSPLexer initialized for the lex start
  6922. + * - Fail NULL
  6923. + */
  6924. +ANTLR3_API pRSPLexer RSPLexerNew
  6925. +(pANTLR3_INPUT_STREAM instream)
  6926. +{
  6927. + // See if we can create a new lexer with the standard constructor
  6928. + //
  6929. + return RSPLexerNewSSD(instream, NULL);
  6930. +}
  6931. +
  6932. +/** \brief Create a new lexer called RSPLexer
  6933. + *
  6934. + * \param[in] instream Pointer to an initialized input stream
  6935. + * \param[state] state Previously created shared recognizer stat
  6936. + * \return
  6937. + * - Success pRSPLexer initialized for the lex start
  6938. + * - Fail NULL
  6939. + */
  6940. +ANTLR3_API pRSPLexer RSPLexerNewSSD
  6941. +(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
  6942. +{
  6943. + pRSPLexer ctx; // Context structure we will build and return
  6944. +
  6945. + ctx = (pRSPLexer) ANTLR3_CALLOC(1, sizeof(RSPLexer));
  6946. +
  6947. + if (ctx == NULL)
  6948. + {
  6949. + // Failed to allocate memory for lexer context
  6950. + return NULL;
  6951. + }
  6952. +
  6953. + /* -------------------------------------------------------------------
  6954. + * Memory for basic structure is allocated, now to fill in
  6955. + * in base ANTLR3 structures. We initialize the function pointers
  6956. + * for the standard ANTLR3 lexer function set, but upon return
  6957. + * from here, the programmer may set the pointers to provide custom
  6958. + * implementations of each function.
  6959. + *
  6960. + * We don't use the macros defined in RSPLexer.h here so you can get a sense
  6961. + * of what goes where.
  6962. + */
  6963. +
  6964. + /* Create a base lexer, using the supplied input stream
  6965. + */
  6966. + ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state);
  6967. +
  6968. + /* Check that we allocated the memory correctly
  6969. + */
  6970. + if (ctx->pLexer == NULL)
  6971. + {
  6972. + ANTLR3_FREE(ctx);
  6973. + return NULL;
  6974. + }
  6975. + /* Install the implementation of our RSPLexer interface
  6976. + */
  6977. + ctx->mQUOTE = mQUOTE;
  6978. + ctx->mLPAR = mLPAR;
  6979. + ctx->mRPAR = mRPAR;
  6980. + ctx->mAND = mAND;
  6981. + ctx->mOR = mOR;
  6982. + ctx->mNOT = mNOT;
  6983. + ctx->mEQUAL = mEQUAL;
  6984. + ctx->mINCLUDES = mINCLUDES;
  6985. + ctx->mSTARTSW = mSTARTSW;
  6986. + ctx->mENDSW = mENDSW;
  6987. + ctx->mGREATER = mGREATER;
  6988. + ctx->mLESS = mLESS;
  6989. + ctx->mGTE = mGTE;
  6990. + ctx->mLTE = mLTE;
  6991. + ctx->mBEFORE = mBEFORE;
  6992. + ctx->mAFTER = mAFTER;
  6993. + ctx->mDAY = mDAY;
  6994. + ctx->mWEEK = mWEEK;
  6995. + ctx->mMONTH = mMONTH;
  6996. + ctx->mYEAR = mYEAR;
  6997. + ctx->mTODAY = mTODAY;
  6998. + ctx->mNEWLINE = mNEWLINE;
  6999. + ctx->mWS = mWS;
  7000. + ctx->mFIELD = mFIELD;
  7001. + ctx->mINT = mINT;
  7002. + ctx->mDATE = mDATE;
  7003. + ctx->mSTR = mSTR;
  7004. + ctx->mESCAPED = mESCAPED;
  7005. + ctx->mDIGIT09 = mDIGIT09;
  7006. + ctx->mDIGIT19 = mDIGIT19;
  7007. + ctx->mTokens = mTokens;
  7008. +
  7009. + /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE
  7010. + * it will call mTokens() in this generated code, and will pass it the ctx
  7011. + * pointer of this lexer, not the context of the base lexer, so store that now.
  7012. + */
  7013. + ctx->pLexer->ctx = ctx;
  7014. +
  7015. + /**Install the token matching function
  7016. + */
  7017. + ctx->pLexer->mTokens = (void (*) (void *))(mTokens);
  7018. +
  7019. + ctx->getGrammarFileName = getGrammarFileName;
  7020. + ctx->free = RSPLexerFree;
  7021. +
  7022. +
  7023. +
  7024. +
  7025. +
  7026. + /* Return the newly built lexer to the caller
  7027. + */
  7028. + return ctx;
  7029. +}
  7030. +
  7031. +
  7032. +/* =========================================================================
  7033. + * Functions to match the lexer grammar defined tokens from the input stream
  7034. + */
  7035. +
  7036. +// Comes from: 85:7: ( '\"' )
  7037. +/** \brief Lexer rule generated by ANTLR3
  7038. + *
  7039. + * $ANTLR start QUOTE
  7040. + *
  7041. + * Looks to match the characters the constitute the token QUOTE
  7042. + * from the attached input stream.
  7043. + *
  7044. + *
  7045. + * \remark
  7046. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7047. + */
  7048. +static ANTLR3_INLINE
  7049. +void mQUOTE(pRSPLexer ctx)
  7050. +{
  7051. + ANTLR3_UINT32 _type;
  7052. +
  7053. + _type = QUOTE;
  7054. +
  7055. +
  7056. + // RSP.g:85:7: ( '\"' )
  7057. + // RSP.g:85:9: '\"'
  7058. + {
  7059. + MATCHC('"');
  7060. + if (HASEXCEPTION())
  7061. + {
  7062. + goto ruleQUOTEEx;
  7063. + }
  7064. +
  7065. +
  7066. + }
  7067. +
  7068. + LEXSTATE->type = _type;
  7069. +
  7070. + // This is where rules clean up and exit
  7071. + //
  7072. + goto ruleQUOTEEx; /* Prevent compiler warnings */
  7073. + ruleQUOTEEx: ;
  7074. +
  7075. +}
  7076. +// $ANTLR end QUOTE
  7077. +
  7078. +// Comes from: 86:6: ( '(' )
  7079. +/** \brief Lexer rule generated by ANTLR3
  7080. + *
  7081. + * $ANTLR start LPAR
  7082. + *
  7083. + * Looks to match the characters the constitute the token LPAR
  7084. + * from the attached input stream.
  7085. + *
  7086. + *
  7087. + * \remark
  7088. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7089. + */
  7090. +static ANTLR3_INLINE
  7091. +void mLPAR(pRSPLexer ctx)
  7092. +{
  7093. + ANTLR3_UINT32 _type;
  7094. +
  7095. + _type = LPAR;
  7096. +
  7097. +
  7098. + // RSP.g:86:6: ( '(' )
  7099. + // RSP.g:86:8: '('
  7100. + {
  7101. + MATCHC('(');
  7102. + if (HASEXCEPTION())
  7103. + {
  7104. + goto ruleLPAREx;
  7105. + }
  7106. +
  7107. +
  7108. + }
  7109. +
  7110. + LEXSTATE->type = _type;
  7111. +
  7112. + // This is where rules clean up and exit
  7113. + //
  7114. + goto ruleLPAREx; /* Prevent compiler warnings */
  7115. + ruleLPAREx: ;
  7116. +
  7117. +}
  7118. +// $ANTLR end LPAR
  7119. +
  7120. +// Comes from: 87:6: ( ')' )
  7121. +/** \brief Lexer rule generated by ANTLR3
  7122. + *
  7123. + * $ANTLR start RPAR
  7124. + *
  7125. + * Looks to match the characters the constitute the token RPAR
  7126. + * from the attached input stream.
  7127. + *
  7128. + *
  7129. + * \remark
  7130. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7131. + */
  7132. +static ANTLR3_INLINE
  7133. +void mRPAR(pRSPLexer ctx)
  7134. +{
  7135. + ANTLR3_UINT32 _type;
  7136. +
  7137. + _type = RPAR;
  7138. +
  7139. +
  7140. + // RSP.g:87:6: ( ')' )
  7141. + // RSP.g:87:8: ')'
  7142. + {
  7143. + MATCHC(')');
  7144. + if (HASEXCEPTION())
  7145. + {
  7146. + goto ruleRPAREx;
  7147. + }
  7148. +
  7149. +
  7150. + }
  7151. +
  7152. + LEXSTATE->type = _type;
  7153. +
  7154. + // This is where rules clean up and exit
  7155. + //
  7156. + goto ruleRPAREx; /* Prevent compiler warnings */
  7157. + ruleRPAREx: ;
  7158. +
  7159. +}
  7160. +// $ANTLR end RPAR
  7161. +
  7162. +// Comes from: 89:5: ( 'and' )
  7163. +/** \brief Lexer rule generated by ANTLR3
  7164. + *
  7165. + * $ANTLR start AND
  7166. + *
  7167. + * Looks to match the characters the constitute the token AND
  7168. + * from the attached input stream.
  7169. + *
  7170. + *
  7171. + * \remark
  7172. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7173. + */
  7174. +static ANTLR3_INLINE
  7175. +void mAND(pRSPLexer ctx)
  7176. +{
  7177. + ANTLR3_UINT32 _type;
  7178. +
  7179. + _type = AND;
  7180. +
  7181. +
  7182. + // RSP.g:89:5: ( 'and' )
  7183. + // RSP.g:89:7: 'and'
  7184. + {
  7185. + MATCHS(lit_1);
  7186. + if (HASEXCEPTION())
  7187. + {
  7188. + goto ruleANDEx;
  7189. + }
  7190. +
  7191. +
  7192. +
  7193. + }
  7194. +
  7195. + LEXSTATE->type = _type;
  7196. +
  7197. + // This is where rules clean up and exit
  7198. + //
  7199. + goto ruleANDEx; /* Prevent compiler warnings */
  7200. + ruleANDEx: ;
  7201. +
  7202. +}
  7203. +// $ANTLR end AND
  7204. +
  7205. +// Comes from: 90:4: ( 'or' )
  7206. +/** \brief Lexer rule generated by ANTLR3
  7207. + *
  7208. + * $ANTLR start OR
  7209. + *
  7210. + * Looks to match the characters the constitute the token OR
  7211. + * from the attached input stream.
  7212. + *
  7213. + *
  7214. + * \remark
  7215. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7216. + */
  7217. +static ANTLR3_INLINE
  7218. +void mOR(pRSPLexer ctx)
  7219. +{
  7220. + ANTLR3_UINT32 _type;
  7221. +
  7222. + _type = OR;
  7223. +
  7224. +
  7225. + // RSP.g:90:4: ( 'or' )
  7226. + // RSP.g:90:6: 'or'
  7227. + {
  7228. + MATCHS(lit_2);
  7229. + if (HASEXCEPTION())
  7230. + {
  7231. + goto ruleOREx;
  7232. + }
  7233. +
  7234. +
  7235. +
  7236. + }
  7237. +
  7238. + LEXSTATE->type = _type;
  7239. +
  7240. + // This is where rules clean up and exit
  7241. + //
  7242. + goto ruleOREx; /* Prevent compiler warnings */
  7243. + ruleOREx: ;
  7244. +
  7245. +}
  7246. +// $ANTLR end OR
  7247. +
  7248. +// Comes from: 91:5: ( '!' )
  7249. +/** \brief Lexer rule generated by ANTLR3
  7250. + *
  7251. + * $ANTLR start NOT
  7252. + *
  7253. + * Looks to match the characters the constitute the token NOT
  7254. + * from the attached input stream.
  7255. + *
  7256. + *
  7257. + * \remark
  7258. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7259. + */
  7260. +static ANTLR3_INLINE
  7261. +void mNOT(pRSPLexer ctx)
  7262. +{
  7263. + ANTLR3_UINT32 _type;
  7264. +
  7265. + _type = NOT;
  7266. +
  7267. +
  7268. + // RSP.g:91:5: ( '!' )
  7269. + // RSP.g:91:7: '!'
  7270. + {
  7271. + MATCHC('!');
  7272. + if (HASEXCEPTION())
  7273. + {
  7274. + goto ruleNOTEx;
  7275. + }
  7276. +
  7277. +
  7278. + }
  7279. +
  7280. + LEXSTATE->type = _type;
  7281. +
  7282. + // This is where rules clean up and exit
  7283. + //
  7284. + goto ruleNOTEx; /* Prevent compiler warnings */
  7285. + ruleNOTEx: ;
  7286. +
  7287. +}
  7288. +// $ANTLR end NOT
  7289. +
  7290. +// Comes from: 94:7: ( '=' )
  7291. +/** \brief Lexer rule generated by ANTLR3
  7292. + *
  7293. + * $ANTLR start EQUAL
  7294. + *
  7295. + * Looks to match the characters the constitute the token EQUAL
  7296. + * from the attached input stream.
  7297. + *
  7298. + *
  7299. + * \remark
  7300. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7301. + */
  7302. +static ANTLR3_INLINE
  7303. +void mEQUAL(pRSPLexer ctx)
  7304. +{
  7305. + ANTLR3_UINT32 _type;
  7306. +
  7307. + _type = EQUAL;
  7308. +
  7309. +
  7310. + // RSP.g:94:7: ( '=' )
  7311. + // RSP.g:94:9: '='
  7312. + {
  7313. + MATCHC('=');
  7314. + if (HASEXCEPTION())
  7315. + {
  7316. + goto ruleEQUALEx;
  7317. + }
  7318. +
  7319. +
  7320. + }
  7321. +
  7322. + LEXSTATE->type = _type;
  7323. +
  7324. + // This is where rules clean up and exit
  7325. + //
  7326. + goto ruleEQUALEx; /* Prevent compiler warnings */
  7327. + ruleEQUALEx: ;
  7328. +
  7329. +}
  7330. +// $ANTLR end EQUAL
  7331. +
  7332. +// Comes from: 97:9: ( 'includes' )
  7333. +/** \brief Lexer rule generated by ANTLR3
  7334. + *
  7335. + * $ANTLR start INCLUDES
  7336. + *
  7337. + * Looks to match the characters the constitute the token INCLUDES
  7338. + * from the attached input stream.
  7339. + *
  7340. + *
  7341. + * \remark
  7342. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7343. + */
  7344. +static ANTLR3_INLINE
  7345. +void mINCLUDES(pRSPLexer ctx)
  7346. +{
  7347. + ANTLR3_UINT32 _type;
  7348. +
  7349. + _type = INCLUDES;
  7350. +
  7351. +
  7352. + // RSP.g:97:9: ( 'includes' )
  7353. + // RSP.g:97:11: 'includes'
  7354. + {
  7355. + MATCHS(lit_3);
  7356. + if (HASEXCEPTION())
  7357. + {
  7358. + goto ruleINCLUDESEx;
  7359. + }
  7360. +
  7361. +
  7362. +
  7363. + }
  7364. +
  7365. + LEXSTATE->type = _type;
  7366. +
  7367. + // This is where rules clean up and exit
  7368. + //
  7369. + goto ruleINCLUDESEx; /* Prevent compiler warnings */
  7370. + ruleINCLUDESEx: ;
  7371. +
  7372. +}
  7373. +// $ANTLR end INCLUDES
  7374. +
  7375. +// Comes from: 98:9: ( 'startswith' )
  7376. +/** \brief Lexer rule generated by ANTLR3
  7377. + *
  7378. + * $ANTLR start STARTSW
  7379. + *
  7380. + * Looks to match the characters the constitute the token STARTSW
  7381. + * from the attached input stream.
  7382. + *
  7383. + *
  7384. + * \remark
  7385. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7386. + */
  7387. +static ANTLR3_INLINE
  7388. +void mSTARTSW(pRSPLexer ctx)
  7389. +{
  7390. + ANTLR3_UINT32 _type;
  7391. +
  7392. + _type = STARTSW;
  7393. +
  7394. +
  7395. + // RSP.g:98:9: ( 'startswith' )
  7396. + // RSP.g:98:11: 'startswith'
  7397. + {
  7398. + MATCHS(lit_4);
  7399. + if (HASEXCEPTION())
  7400. + {
  7401. + goto ruleSTARTSWEx;
  7402. + }
  7403. +
  7404. +
  7405. +
  7406. + }
  7407. +
  7408. + LEXSTATE->type = _type;
  7409. +
  7410. + // This is where rules clean up and exit
  7411. + //
  7412. + goto ruleSTARTSWEx; /* Prevent compiler warnings */
  7413. + ruleSTARTSWEx: ;
  7414. +
  7415. +}
  7416. +// $ANTLR end STARTSW
  7417. +
  7418. +// Comes from: 99:7: ( 'endswith' )
  7419. +/** \brief Lexer rule generated by ANTLR3
  7420. + *
  7421. + * $ANTLR start ENDSW
  7422. + *
  7423. + * Looks to match the characters the constitute the token ENDSW
  7424. + * from the attached input stream.
  7425. + *
  7426. + *
  7427. + * \remark
  7428. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7429. + */
  7430. +static ANTLR3_INLINE
  7431. +void mENDSW(pRSPLexer ctx)
  7432. +{
  7433. + ANTLR3_UINT32 _type;
  7434. +
  7435. + _type = ENDSW;
  7436. +
  7437. +
  7438. + // RSP.g:99:7: ( 'endswith' )
  7439. + // RSP.g:99:9: 'endswith'
  7440. + {
  7441. + MATCHS(lit_5);
  7442. + if (HASEXCEPTION())
  7443. + {
  7444. + goto ruleENDSWEx;
  7445. + }
  7446. +
  7447. +
  7448. +
  7449. + }
  7450. +
  7451. + LEXSTATE->type = _type;
  7452. +
  7453. + // This is where rules clean up and exit
  7454. + //
  7455. + goto ruleENDSWEx; /* Prevent compiler warnings */
  7456. + ruleENDSWEx: ;
  7457. +
  7458. +}
  7459. +// $ANTLR end ENDSW
  7460. +
  7461. +// Comes from: 102:9: ( '>' )
  7462. +/** \brief Lexer rule generated by ANTLR3
  7463. + *
  7464. + * $ANTLR start GREATER
  7465. + *
  7466. + * Looks to match the characters the constitute the token GREATER
  7467. + * from the attached input stream.
  7468. + *
  7469. + *
  7470. + * \remark
  7471. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7472. + */
  7473. +static ANTLR3_INLINE
  7474. +void mGREATER(pRSPLexer ctx)
  7475. +{
  7476. + ANTLR3_UINT32 _type;
  7477. +
  7478. + _type = GREATER;
  7479. +
  7480. +
  7481. + // RSP.g:102:9: ( '>' )
  7482. + // RSP.g:102:11: '>'
  7483. + {
  7484. + MATCHC('>');
  7485. + if (HASEXCEPTION())
  7486. + {
  7487. + goto ruleGREATEREx;
  7488. + }
  7489. +
  7490. +
  7491. + }
  7492. +
  7493. + LEXSTATE->type = _type;
  7494. +
  7495. + // This is where rules clean up and exit
  7496. + //
  7497. + goto ruleGREATEREx; /* Prevent compiler warnings */
  7498. + ruleGREATEREx: ;
  7499. +
  7500. +}
  7501. +// $ANTLR end GREATER
  7502. +
  7503. +// Comes from: 103:6: ( '<' )
  7504. +/** \brief Lexer rule generated by ANTLR3
  7505. + *
  7506. + * $ANTLR start LESS
  7507. + *
  7508. + * Looks to match the characters the constitute the token LESS
  7509. + * from the attached input stream.
  7510. + *
  7511. + *
  7512. + * \remark
  7513. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7514. + */
  7515. +static ANTLR3_INLINE
  7516. +void mLESS(pRSPLexer ctx)
  7517. +{
  7518. + ANTLR3_UINT32 _type;
  7519. +
  7520. + _type = LESS;
  7521. +
  7522. +
  7523. + // RSP.g:103:6: ( '<' )
  7524. + // RSP.g:103:8: '<'
  7525. + {
  7526. + MATCHC('<');
  7527. + if (HASEXCEPTION())
  7528. + {
  7529. + goto ruleLESSEx;
  7530. + }
  7531. +
  7532. +
  7533. + }
  7534. +
  7535. + LEXSTATE->type = _type;
  7536. +
  7537. + // This is where rules clean up and exit
  7538. + //
  7539. + goto ruleLESSEx; /* Prevent compiler warnings */
  7540. + ruleLESSEx: ;
  7541. +
  7542. +}
  7543. +// $ANTLR end LESS
  7544. +
  7545. +// Comes from: 104:5: ( '>=' )
  7546. +/** \brief Lexer rule generated by ANTLR3
  7547. + *
  7548. + * $ANTLR start GTE
  7549. + *
  7550. + * Looks to match the characters the constitute the token GTE
  7551. + * from the attached input stream.
  7552. + *
  7553. + *
  7554. + * \remark
  7555. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7556. + */
  7557. +static ANTLR3_INLINE
  7558. +void mGTE(pRSPLexer ctx)
  7559. +{
  7560. + ANTLR3_UINT32 _type;
  7561. +
  7562. + _type = GTE;
  7563. +
  7564. +
  7565. + // RSP.g:104:5: ( '>=' )
  7566. + // RSP.g:104:7: '>='
  7567. + {
  7568. + MATCHS(lit_6);
  7569. + if (HASEXCEPTION())
  7570. + {
  7571. + goto ruleGTEEx;
  7572. + }
  7573. +
  7574. +
  7575. +
  7576. + }
  7577. +
  7578. + LEXSTATE->type = _type;
  7579. +
  7580. + // This is where rules clean up and exit
  7581. + //
  7582. + goto ruleGTEEx; /* Prevent compiler warnings */
  7583. + ruleGTEEx: ;
  7584. +
  7585. +}
  7586. +// $ANTLR end GTE
  7587. +
  7588. +// Comes from: 105:5: ( '<=' )
  7589. +/** \brief Lexer rule generated by ANTLR3
  7590. + *
  7591. + * $ANTLR start LTE
  7592. + *
  7593. + * Looks to match the characters the constitute the token LTE
  7594. + * from the attached input stream.
  7595. + *
  7596. + *
  7597. + * \remark
  7598. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7599. + */
  7600. +static ANTLR3_INLINE
  7601. +void mLTE(pRSPLexer ctx)
  7602. +{
  7603. + ANTLR3_UINT32 _type;
  7604. +
  7605. + _type = LTE;
  7606. +
  7607. +
  7608. + // RSP.g:105:5: ( '<=' )
  7609. + // RSP.g:105:7: '<='
  7610. + {
  7611. + MATCHS(lit_7);
  7612. + if (HASEXCEPTION())
  7613. + {
  7614. + goto ruleLTEEx;
  7615. + }
  7616. +
  7617. +
  7618. +
  7619. + }
  7620. +
  7621. + LEXSTATE->type = _type;
  7622. +
  7623. + // This is where rules clean up and exit
  7624. + //
  7625. + goto ruleLTEEx; /* Prevent compiler warnings */
  7626. + ruleLTEEx: ;
  7627. +
  7628. +}
  7629. +// $ANTLR end LTE
  7630. +
  7631. +// Comes from: 108:8: ( 'before' )
  7632. +/** \brief Lexer rule generated by ANTLR3
  7633. + *
  7634. + * $ANTLR start BEFORE
  7635. + *
  7636. + * Looks to match the characters the constitute the token BEFORE
  7637. + * from the attached input stream.
  7638. + *
  7639. + *
  7640. + * \remark
  7641. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7642. + */
  7643. +static ANTLR3_INLINE
  7644. +void mBEFORE(pRSPLexer ctx)
  7645. +{
  7646. + ANTLR3_UINT32 _type;
  7647. +
  7648. + _type = BEFORE;
  7649. +
  7650. +
  7651. + // RSP.g:108:8: ( 'before' )
  7652. + // RSP.g:108:10: 'before'
  7653. + {
  7654. + MATCHS(lit_8);
  7655. + if (HASEXCEPTION())
  7656. + {
  7657. + goto ruleBEFOREEx;
  7658. + }
  7659. +
  7660. +
  7661. +
  7662. + }
  7663. +
  7664. + LEXSTATE->type = _type;
  7665. +
  7666. + // This is where rules clean up and exit
  7667. + //
  7668. + goto ruleBEFOREEx; /* Prevent compiler warnings */
  7669. + ruleBEFOREEx: ;
  7670. +
  7671. +}
  7672. +// $ANTLR end BEFORE
  7673. +
  7674. +// Comes from: 109:7: ( 'after' )
  7675. +/** \brief Lexer rule generated by ANTLR3
  7676. + *
  7677. + * $ANTLR start AFTER
  7678. + *
  7679. + * Looks to match the characters the constitute the token AFTER
  7680. + * from the attached input stream.
  7681. + *
  7682. + *
  7683. + * \remark
  7684. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7685. + */
  7686. +static ANTLR3_INLINE
  7687. +void mAFTER(pRSPLexer ctx)
  7688. +{
  7689. + ANTLR3_UINT32 _type;
  7690. +
  7691. + _type = AFTER;
  7692. +
  7693. +
  7694. + // RSP.g:109:7: ( 'after' )
  7695. + // RSP.g:109:9: 'after'
  7696. + {
  7697. + MATCHS(lit_9);
  7698. + if (HASEXCEPTION())
  7699. + {
  7700. + goto ruleAFTEREx;
  7701. + }
  7702. +
  7703. +
  7704. +
  7705. + }
  7706. +
  7707. + LEXSTATE->type = _type;
  7708. +
  7709. + // This is where rules clean up and exit
  7710. + //
  7711. + goto ruleAFTEREx; /* Prevent compiler warnings */
  7712. + ruleAFTEREx: ;
  7713. +
  7714. +}
  7715. +// $ANTLR end AFTER
  7716. +
  7717. +// Comes from: 110:5: ( 'day' | 'days' )
  7718. +/** \brief Lexer rule generated by ANTLR3
  7719. + *
  7720. + * $ANTLR start DAY
  7721. + *
  7722. + * Looks to match the characters the constitute the token DAY
  7723. + * from the attached input stream.
  7724. + *
  7725. + *
  7726. + * \remark
  7727. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7728. + */
  7729. +static ANTLR3_INLINE
  7730. +void mDAY(pRSPLexer ctx)
  7731. +{
  7732. + ANTLR3_UINT32 _type;
  7733. +
  7734. + _type = DAY;
  7735. +
  7736. +
  7737. + {
  7738. + // RSP.g:110:5: ( 'day' | 'days' )
  7739. +
  7740. + ANTLR3_UINT32 alt1;
  7741. +
  7742. + alt1=2;
  7743. +
  7744. + switch ( LA(1) )
  7745. + {
  7746. + case 'd':
  7747. + {
  7748. + switch ( LA(2) )
  7749. + {
  7750. + case 'a':
  7751. + {
  7752. + switch ( LA(3) )
  7753. + {
  7754. + case 'y':
  7755. + {
  7756. + switch ( LA(4) )
  7757. + {
  7758. + case 's':
  7759. + {
  7760. + alt1=2;
  7761. + }
  7762. + break;
  7763. +
  7764. + default:
  7765. + alt1=1;}
  7766. +
  7767. + }
  7768. + break;
  7769. +
  7770. + default:
  7771. + CONSTRUCTEX();
  7772. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  7773. + EXCEPTION->message = (void *)"";
  7774. + EXCEPTION->decisionNum = 1;
  7775. + EXCEPTION->state = 2;
  7776. +
  7777. +
  7778. + goto ruleDAYEx;
  7779. + }
  7780. +
  7781. + }
  7782. + break;
  7783. +
  7784. + default:
  7785. + CONSTRUCTEX();
  7786. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  7787. + EXCEPTION->message = (void *)"";
  7788. + EXCEPTION->decisionNum = 1;
  7789. + EXCEPTION->state = 1;
  7790. +
  7791. +
  7792. + goto ruleDAYEx;
  7793. + }
  7794. +
  7795. + }
  7796. + break;
  7797. +
  7798. + default:
  7799. + CONSTRUCTEX();
  7800. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  7801. + EXCEPTION->message = (void *)"";
  7802. + EXCEPTION->decisionNum = 1;
  7803. + EXCEPTION->state = 0;
  7804. +
  7805. +
  7806. + goto ruleDAYEx;
  7807. + }
  7808. +
  7809. + switch (alt1)
  7810. + {
  7811. + case 1:
  7812. + // RSP.g:110:7: 'day'
  7813. + {
  7814. + MATCHS(lit_10);
  7815. + if (HASEXCEPTION())
  7816. + {
  7817. + goto ruleDAYEx;
  7818. + }
  7819. +
  7820. +
  7821. +
  7822. + }
  7823. + break;
  7824. + case 2:
  7825. + // RSP.g:110:15: 'days'
  7826. + {
  7827. + MATCHS(lit_11);
  7828. + if (HASEXCEPTION())
  7829. + {
  7830. + goto ruleDAYEx;
  7831. + }
  7832. +
  7833. +
  7834. +
  7835. + }
  7836. + break;
  7837. +
  7838. + }
  7839. + }
  7840. + LEXSTATE->type = _type;
  7841. +
  7842. + // This is where rules clean up and exit
  7843. + //
  7844. + goto ruleDAYEx; /* Prevent compiler warnings */
  7845. + ruleDAYEx: ;
  7846. +
  7847. +}
  7848. +// $ANTLR end DAY
  7849. +
  7850. +// Comes from: 111:6: ( 'week' | 'weeks' )
  7851. +/** \brief Lexer rule generated by ANTLR3
  7852. + *
  7853. + * $ANTLR start WEEK
  7854. + *
  7855. + * Looks to match the characters the constitute the token WEEK
  7856. + * from the attached input stream.
  7857. + *
  7858. + *
  7859. + * \remark
  7860. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  7861. + */
  7862. +static ANTLR3_INLINE
  7863. +void mWEEK(pRSPLexer ctx)
  7864. +{
  7865. + ANTLR3_UINT32 _type;
  7866. +
  7867. + _type = WEEK;
  7868. +
  7869. +
  7870. + {
  7871. + // RSP.g:111:6: ( 'week' | 'weeks' )
  7872. +
  7873. + ANTLR3_UINT32 alt2;
  7874. +
  7875. + alt2=2;
  7876. +
  7877. + switch ( LA(1) )
  7878. + {
  7879. + case 'w':
  7880. + {
  7881. + switch ( LA(2) )
  7882. + {
  7883. + case 'e':
  7884. + {
  7885. + switch ( LA(3) )
  7886. + {
  7887. + case 'e':
  7888. + {
  7889. + switch ( LA(4) )
  7890. + {
  7891. + case 'k':
  7892. + {
  7893. + switch ( LA(5) )
  7894. + {
  7895. + case 's':
  7896. + {
  7897. + alt2=2;
  7898. + }
  7899. + break;
  7900. +
  7901. + default:
  7902. + alt2=1;}
  7903. +
  7904. + }
  7905. + break;
  7906. +
  7907. + default:
  7908. + CONSTRUCTEX();
  7909. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  7910. + EXCEPTION->message = (void *)"";
  7911. + EXCEPTION->decisionNum = 2;
  7912. + EXCEPTION->state = 3;
  7913. +
  7914. +
  7915. + goto ruleWEEKEx;
  7916. + }
  7917. +
  7918. + }
  7919. + break;
  7920. +
  7921. + default:
  7922. + CONSTRUCTEX();
  7923. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  7924. + EXCEPTION->message = (void *)"";
  7925. + EXCEPTION->decisionNum = 2;
  7926. + EXCEPTION->state = 2;
  7927. +
  7928. +
  7929. + goto ruleWEEKEx;
  7930. + }
  7931. +
  7932. + }
  7933. + break;
  7934. +
  7935. + default:
  7936. + CONSTRUCTEX();
  7937. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  7938. + EXCEPTION->message = (void *)"";
  7939. + EXCEPTION->decisionNum = 2;
  7940. + EXCEPTION->state = 1;
  7941. +
  7942. +
  7943. + goto ruleWEEKEx;
  7944. + }
  7945. +
  7946. + }
  7947. + break;
  7948. +
  7949. + default:
  7950. + CONSTRUCTEX();
  7951. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  7952. + EXCEPTION->message = (void *)"";
  7953. + EXCEPTION->decisionNum = 2;
  7954. + EXCEPTION->state = 0;
  7955. +
  7956. +
  7957. + goto ruleWEEKEx;
  7958. + }
  7959. +
  7960. + switch (alt2)
  7961. + {
  7962. + case 1:
  7963. + // RSP.g:111:8: 'week'
  7964. + {
  7965. + MATCHS(lit_12);
  7966. + if (HASEXCEPTION())
  7967. + {
  7968. + goto ruleWEEKEx;
  7969. + }
  7970. +
  7971. +
  7972. +
  7973. + }
  7974. + break;
  7975. + case 2:
  7976. + // RSP.g:111:17: 'weeks'
  7977. + {
  7978. + MATCHS(lit_13);
  7979. + if (HASEXCEPTION())
  7980. + {
  7981. + goto ruleWEEKEx;
  7982. + }
  7983. +
  7984. +
  7985. +
  7986. + }
  7987. + break;
  7988. +
  7989. + }
  7990. + }
  7991. + LEXSTATE->type = _type;
  7992. +
  7993. + // This is where rules clean up and exit
  7994. + //
  7995. + goto ruleWEEKEx; /* Prevent compiler warnings */
  7996. + ruleWEEKEx: ;
  7997. +
  7998. +}
  7999. +// $ANTLR end WEEK
  8000. +
  8001. +// Comes from: 112:7: ( 'month' | 'months' )
  8002. +/** \brief Lexer rule generated by ANTLR3
  8003. + *
  8004. + * $ANTLR start MONTH
  8005. + *
  8006. + * Looks to match the characters the constitute the token MONTH
  8007. + * from the attached input stream.
  8008. + *
  8009. + *
  8010. + * \remark
  8011. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  8012. + */
  8013. +static ANTLR3_INLINE
  8014. +void mMONTH(pRSPLexer ctx)
  8015. +{
  8016. + ANTLR3_UINT32 _type;
  8017. +
  8018. + _type = MONTH;
  8019. +
  8020. +
  8021. + {
  8022. + // RSP.g:112:7: ( 'month' | 'months' )
  8023. +
  8024. + ANTLR3_UINT32 alt3;
  8025. +
  8026. + alt3=2;
  8027. +
  8028. + switch ( LA(1) )
  8029. + {
  8030. + case 'm':
  8031. + {
  8032. + switch ( LA(2) )
  8033. + {
  8034. + case 'o':
  8035. + {
  8036. + switch ( LA(3) )
  8037. + {
  8038. + case 'n':
  8039. + {
  8040. + switch ( LA(4) )
  8041. + {
  8042. + case 't':
  8043. + {
  8044. + switch ( LA(5) )
  8045. + {
  8046. + case 'h':
  8047. + {
  8048. + switch ( LA(6) )
  8049. + {
  8050. + case 's':
  8051. + {
  8052. + alt3=2;
  8053. + }
  8054. + break;
  8055. +
  8056. + default:
  8057. + alt3=1;}
  8058. +
  8059. + }
  8060. + break;
  8061. +
  8062. + default:
  8063. + CONSTRUCTEX();
  8064. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8065. + EXCEPTION->message = (void *)"";
  8066. + EXCEPTION->decisionNum = 3;
  8067. + EXCEPTION->state = 4;
  8068. +
  8069. +
  8070. + goto ruleMONTHEx;
  8071. + }
  8072. +
  8073. + }
  8074. + break;
  8075. +
  8076. + default:
  8077. + CONSTRUCTEX();
  8078. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8079. + EXCEPTION->message = (void *)"";
  8080. + EXCEPTION->decisionNum = 3;
  8081. + EXCEPTION->state = 3;
  8082. +
  8083. +
  8084. + goto ruleMONTHEx;
  8085. + }
  8086. +
  8087. + }
  8088. + break;
  8089. +
  8090. + default:
  8091. + CONSTRUCTEX();
  8092. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8093. + EXCEPTION->message = (void *)"";
  8094. + EXCEPTION->decisionNum = 3;
  8095. + EXCEPTION->state = 2;
  8096. +
  8097. +
  8098. + goto ruleMONTHEx;
  8099. + }
  8100. +
  8101. + }
  8102. + break;
  8103. +
  8104. + default:
  8105. + CONSTRUCTEX();
  8106. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8107. + EXCEPTION->message = (void *)"";
  8108. + EXCEPTION->decisionNum = 3;
  8109. + EXCEPTION->state = 1;
  8110. +
  8111. +
  8112. + goto ruleMONTHEx;
  8113. + }
  8114. +
  8115. + }
  8116. + break;
  8117. +
  8118. + default:
  8119. + CONSTRUCTEX();
  8120. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8121. + EXCEPTION->message = (void *)"";
  8122. + EXCEPTION->decisionNum = 3;
  8123. + EXCEPTION->state = 0;
  8124. +
  8125. +
  8126. + goto ruleMONTHEx;
  8127. + }
  8128. +
  8129. + switch (alt3)
  8130. + {
  8131. + case 1:
  8132. + // RSP.g:112:9: 'month'
  8133. + {
  8134. + MATCHS(lit_14);
  8135. + if (HASEXCEPTION())
  8136. + {
  8137. + goto ruleMONTHEx;
  8138. + }
  8139. +
  8140. +
  8141. +
  8142. + }
  8143. + break;
  8144. + case 2:
  8145. + // RSP.g:112:19: 'months'
  8146. + {
  8147. + MATCHS(lit_15);
  8148. + if (HASEXCEPTION())
  8149. + {
  8150. + goto ruleMONTHEx;
  8151. + }
  8152. +
  8153. +
  8154. +
  8155. + }
  8156. + break;
  8157. +
  8158. + }
  8159. + }
  8160. + LEXSTATE->type = _type;
  8161. +
  8162. + // This is where rules clean up and exit
  8163. + //
  8164. + goto ruleMONTHEx; /* Prevent compiler warnings */
  8165. + ruleMONTHEx: ;
  8166. +
  8167. +}
  8168. +// $ANTLR end MONTH
  8169. +
  8170. +// Comes from: 113:6: ( 'year' | 'years' )
  8171. +/** \brief Lexer rule generated by ANTLR3
  8172. + *
  8173. + * $ANTLR start YEAR
  8174. + *
  8175. + * Looks to match the characters the constitute the token YEAR
  8176. + * from the attached input stream.
  8177. + *
  8178. + *
  8179. + * \remark
  8180. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  8181. + */
  8182. +static ANTLR3_INLINE
  8183. +void mYEAR(pRSPLexer ctx)
  8184. +{
  8185. + ANTLR3_UINT32 _type;
  8186. +
  8187. + _type = YEAR;
  8188. +
  8189. +
  8190. + {
  8191. + // RSP.g:113:6: ( 'year' | 'years' )
  8192. +
  8193. + ANTLR3_UINT32 alt4;
  8194. +
  8195. + alt4=2;
  8196. +
  8197. + switch ( LA(1) )
  8198. + {
  8199. + case 'y':
  8200. + {
  8201. + switch ( LA(2) )
  8202. + {
  8203. + case 'e':
  8204. + {
  8205. + switch ( LA(3) )
  8206. + {
  8207. + case 'a':
  8208. + {
  8209. + switch ( LA(4) )
  8210. + {
  8211. + case 'r':
  8212. + {
  8213. + switch ( LA(5) )
  8214. + {
  8215. + case 's':
  8216. + {
  8217. + alt4=2;
  8218. + }
  8219. + break;
  8220. +
  8221. + default:
  8222. + alt4=1;}
  8223. +
  8224. + }
  8225. + break;
  8226. +
  8227. + default:
  8228. + CONSTRUCTEX();
  8229. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8230. + EXCEPTION->message = (void *)"";
  8231. + EXCEPTION->decisionNum = 4;
  8232. + EXCEPTION->state = 3;
  8233. +
  8234. +
  8235. + goto ruleYEAREx;
  8236. + }
  8237. +
  8238. + }
  8239. + break;
  8240. +
  8241. + default:
  8242. + CONSTRUCTEX();
  8243. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8244. + EXCEPTION->message = (void *)"";
  8245. + EXCEPTION->decisionNum = 4;
  8246. + EXCEPTION->state = 2;
  8247. +
  8248. +
  8249. + goto ruleYEAREx;
  8250. + }
  8251. +
  8252. + }
  8253. + break;
  8254. +
  8255. + default:
  8256. + CONSTRUCTEX();
  8257. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8258. + EXCEPTION->message = (void *)"";
  8259. + EXCEPTION->decisionNum = 4;
  8260. + EXCEPTION->state = 1;
  8261. +
  8262. +
  8263. + goto ruleYEAREx;
  8264. + }
  8265. +
  8266. + }
  8267. + break;
  8268. +
  8269. + default:
  8270. + CONSTRUCTEX();
  8271. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8272. + EXCEPTION->message = (void *)"";
  8273. + EXCEPTION->decisionNum = 4;
  8274. + EXCEPTION->state = 0;
  8275. +
  8276. +
  8277. + goto ruleYEAREx;
  8278. + }
  8279. +
  8280. + switch (alt4)
  8281. + {
  8282. + case 1:
  8283. + // RSP.g:113:8: 'year'
  8284. + {
  8285. + MATCHS(lit_16);
  8286. + if (HASEXCEPTION())
  8287. + {
  8288. + goto ruleYEAREx;
  8289. + }
  8290. +
  8291. +
  8292. +
  8293. + }
  8294. + break;
  8295. + case 2:
  8296. + // RSP.g:113:17: 'years'
  8297. + {
  8298. + MATCHS(lit_17);
  8299. + if (HASEXCEPTION())
  8300. + {
  8301. + goto ruleYEAREx;
  8302. + }
  8303. +
  8304. +
  8305. +
  8306. + }
  8307. + break;
  8308. +
  8309. + }
  8310. + }
  8311. + LEXSTATE->type = _type;
  8312. +
  8313. + // This is where rules clean up and exit
  8314. + //
  8315. + goto ruleYEAREx; /* Prevent compiler warnings */
  8316. + ruleYEAREx: ;
  8317. +
  8318. +}
  8319. +// $ANTLR end YEAR
  8320. +
  8321. +// Comes from: 114:7: ( 'today' )
  8322. +/** \brief Lexer rule generated by ANTLR3
  8323. + *
  8324. + * $ANTLR start TODAY
  8325. + *
  8326. + * Looks to match the characters the constitute the token TODAY
  8327. + * from the attached input stream.
  8328. + *
  8329. + *
  8330. + * \remark
  8331. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  8332. + */
  8333. +static ANTLR3_INLINE
  8334. +void mTODAY(pRSPLexer ctx)
  8335. +{
  8336. + ANTLR3_UINT32 _type;
  8337. +
  8338. + _type = TODAY;
  8339. +
  8340. +
  8341. + // RSP.g:114:7: ( 'today' )
  8342. + // RSP.g:114:9: 'today'
  8343. + {
  8344. + MATCHS(lit_18);
  8345. + if (HASEXCEPTION())
  8346. + {
  8347. + goto ruleTODAYEx;
  8348. + }
  8349. +
  8350. +
  8351. +
  8352. + }
  8353. +
  8354. + LEXSTATE->type = _type;
  8355. +
  8356. + // This is where rules clean up and exit
  8357. + //
  8358. + goto ruleTODAYEx; /* Prevent compiler warnings */
  8359. + ruleTODAYEx: ;
  8360. +
  8361. +}
  8362. +// $ANTLR end TODAY
  8363. +
  8364. +// Comes from: 116:9: ( ( '\\r' )? '\\n' )
  8365. +/** \brief Lexer rule generated by ANTLR3
  8366. + *
  8367. + * $ANTLR start NEWLINE
  8368. + *
  8369. + * Looks to match the characters the constitute the token NEWLINE
  8370. + * from the attached input stream.
  8371. + *
  8372. + *
  8373. + * \remark
  8374. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  8375. + */
  8376. +static ANTLR3_INLINE
  8377. +void mNEWLINE(pRSPLexer ctx)
  8378. +{
  8379. + ANTLR3_UINT32 _type;
  8380. +
  8381. + _type = NEWLINE;
  8382. +
  8383. +
  8384. + // RSP.g:116:9: ( ( '\\r' )? '\\n' )
  8385. + // RSP.g:116:11: ( '\\r' )? '\\n'
  8386. + {
  8387. +
  8388. + // RSP.g:116:11: ( '\\r' )?
  8389. + {
  8390. + int alt5=2;
  8391. + switch ( LA(1) )
  8392. + {
  8393. + case '\r':
  8394. + {
  8395. + alt5=1;
  8396. + }
  8397. + break;
  8398. + }
  8399. +
  8400. + switch (alt5)
  8401. + {
  8402. + case 1:
  8403. + // RSP.g:116:11: '\\r'
  8404. + {
  8405. + MATCHC('\r');
  8406. + if (HASEXCEPTION())
  8407. + {
  8408. + goto ruleNEWLINEEx;
  8409. + }
  8410. +
  8411. +
  8412. + }
  8413. + break;
  8414. +
  8415. + }
  8416. + }
  8417. + MATCHC('\n');
  8418. + if (HASEXCEPTION())
  8419. + {
  8420. + goto ruleNEWLINEEx;
  8421. + }
  8422. +
  8423. +
  8424. + }
  8425. +
  8426. + LEXSTATE->type = _type;
  8427. +
  8428. + // This is where rules clean up and exit
  8429. + //
  8430. + goto ruleNEWLINEEx; /* Prevent compiler warnings */
  8431. + ruleNEWLINEEx: ;
  8432. +
  8433. +}
  8434. +// $ANTLR end NEWLINE
  8435. +
  8436. +// Comes from: 118:4: ( ( ' ' | '\\t' ) )
  8437. +/** \brief Lexer rule generated by ANTLR3
  8438. + *
  8439. + * $ANTLR start WS
  8440. + *
  8441. + * Looks to match the characters the constitute the token WS
  8442. + * from the attached input stream.
  8443. + *
  8444. + *
  8445. + * \remark
  8446. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  8447. + */
  8448. +static ANTLR3_INLINE
  8449. +void mWS(pRSPLexer ctx)
  8450. +{
  8451. + ANTLR3_UINT32 _type;
  8452. +
  8453. + _type = WS;
  8454. +
  8455. +
  8456. + // RSP.g:118:4: ( ( ' ' | '\\t' ) )
  8457. + // RSP.g:118:6: ( ' ' | '\\t' )
  8458. + {
  8459. + if ( LA(1) == '\t' || LA(1) == ' ' )
  8460. + {
  8461. + CONSUME();
  8462. +
  8463. + }
  8464. + else
  8465. + {
  8466. + CONSTRUCTEX();
  8467. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  8468. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  8469. +
  8470. + LRECOVER(); goto ruleWSEx;
  8471. + }
  8472. +
  8473. + {
  8474. + LEXSTATE->channel = HIDDEN;
  8475. + }
  8476. +
  8477. + }
  8478. +
  8479. + LEXSTATE->type = _type;
  8480. +
  8481. + // This is where rules clean up and exit
  8482. + //
  8483. + goto ruleWSEx; /* Prevent compiler warnings */
  8484. + ruleWSEx: ;
  8485. +
  8486. +}
  8487. +// $ANTLR end WS
  8488. +
  8489. +// Comes from: 120:7: ( 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' )
  8490. +/** \brief Lexer rule generated by ANTLR3
  8491. + *
  8492. + * $ANTLR start FIELD
  8493. + *
  8494. + * Looks to match the characters the constitute the token FIELD
  8495. + * from the attached input stream.
  8496. + *
  8497. + *
  8498. + * \remark
  8499. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  8500. + */
  8501. +static ANTLR3_INLINE
  8502. +void mFIELD(pRSPLexer ctx)
  8503. +{
  8504. + ANTLR3_UINT32 _type;
  8505. +
  8506. + _type = FIELD;
  8507. +
  8508. +
  8509. + // RSP.g:120:7: ( 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' )
  8510. + // RSP.g:120:9: 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z'
  8511. + {
  8512. + MATCHRANGE('a', 'z');
  8513. + if (HASEXCEPTION())
  8514. + {
  8515. + goto ruleFIELDEx;
  8516. + }
  8517. +
  8518. +
  8519. + // RSP.g:120:18: ( 'a' .. 'z' | '_' )*
  8520. +
  8521. + for (;;)
  8522. + {
  8523. + int alt6=2;
  8524. + switch ( LA(1) )
  8525. + {
  8526. + case 'a':
  8527. + case 'b':
  8528. + case 'c':
  8529. + case 'd':
  8530. + case 'e':
  8531. + case 'f':
  8532. + case 'g':
  8533. + case 'h':
  8534. + case 'i':
  8535. + case 'j':
  8536. + case 'k':
  8537. + case 'l':
  8538. + case 'm':
  8539. + case 'n':
  8540. + case 'o':
  8541. + case 'p':
  8542. + case 'q':
  8543. + case 'r':
  8544. + case 's':
  8545. + case 't':
  8546. + case 'u':
  8547. + case 'v':
  8548. + case 'w':
  8549. + case 'x':
  8550. + case 'y':
  8551. + case 'z':
  8552. + {
  8553. + switch ( LA(2) )
  8554. + {
  8555. + case '_':
  8556. + case 'a':
  8557. + case 'b':
  8558. + case 'c':
  8559. + case 'd':
  8560. + case 'e':
  8561. + case 'f':
  8562. + case 'g':
  8563. + case 'h':
  8564. + case 'i':
  8565. + case 'j':
  8566. + case 'k':
  8567. + case 'l':
  8568. + case 'm':
  8569. + case 'n':
  8570. + case 'o':
  8571. + case 'p':
  8572. + case 'q':
  8573. + case 'r':
  8574. + case 's':
  8575. + case 't':
  8576. + case 'u':
  8577. + case 'v':
  8578. + case 'w':
  8579. + case 'x':
  8580. + case 'y':
  8581. + case 'z':
  8582. + {
  8583. + alt6=1;
  8584. + }
  8585. + break;
  8586. +
  8587. + }
  8588. +
  8589. + }
  8590. + break;
  8591. + case '_':
  8592. + {
  8593. + alt6=1;
  8594. + }
  8595. + break;
  8596. +
  8597. + }
  8598. +
  8599. + switch (alt6)
  8600. + {
  8601. + case 1:
  8602. + // RSP.g:
  8603. + {
  8604. + if ( LA(1) == '_' || ((LA(1) >= 'a') && (LA(1) <= 'z')) )
  8605. + {
  8606. + CONSUME();
  8607. +
  8608. + }
  8609. + else
  8610. + {
  8611. + CONSTRUCTEX();
  8612. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  8613. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  8614. +
  8615. + LRECOVER(); goto ruleFIELDEx;
  8616. + }
  8617. +
  8618. +
  8619. + }
  8620. + break;
  8621. +
  8622. + default:
  8623. + goto loop6; /* break out of the loop */
  8624. + break;
  8625. + }
  8626. + }
  8627. + loop6: ; /* Jump out to here if this rule does not match */
  8628. +
  8629. + MATCHRANGE('a', 'z');
  8630. + if (HASEXCEPTION())
  8631. + {
  8632. + goto ruleFIELDEx;
  8633. + }
  8634. +
  8635. +
  8636. + }
  8637. +
  8638. + LEXSTATE->type = _type;
  8639. +
  8640. + // This is where rules clean up and exit
  8641. + //
  8642. + goto ruleFIELDEx; /* Prevent compiler warnings */
  8643. + ruleFIELDEx: ;
  8644. +
  8645. +}
  8646. +// $ANTLR end FIELD
  8647. +
  8648. +// Comes from: 122:5: ( DIGIT19 ( DIGIT09 )* )
  8649. +/** \brief Lexer rule generated by ANTLR3
  8650. + *
  8651. + * $ANTLR start INT
  8652. + *
  8653. + * Looks to match the characters the constitute the token INT
  8654. + * from the attached input stream.
  8655. + *
  8656. + *
  8657. + * \remark
  8658. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  8659. + */
  8660. +static ANTLR3_INLINE
  8661. +void mINT(pRSPLexer ctx)
  8662. +{
  8663. + ANTLR3_UINT32 _type;
  8664. +
  8665. + _type = INT;
  8666. +
  8667. +
  8668. + // RSP.g:122:5: ( DIGIT19 ( DIGIT09 )* )
  8669. + // RSP.g:122:7: DIGIT19 ( DIGIT09 )*
  8670. + {
  8671. + /* 122:7: DIGIT19 ( DIGIT09 )* */
  8672. + mDIGIT19(ctx );
  8673. + if (HASEXCEPTION())
  8674. + {
  8675. + goto ruleINTEx;
  8676. + }
  8677. +
  8678. +
  8679. + // RSP.g:122:15: ( DIGIT09 )*
  8680. +
  8681. + for (;;)
  8682. + {
  8683. + int alt7=2;
  8684. + switch ( LA(1) )
  8685. + {
  8686. + case '0':
  8687. + case '1':
  8688. + case '2':
  8689. + case '3':
  8690. + case '4':
  8691. + case '5':
  8692. + case '6':
  8693. + case '7':
  8694. + case '8':
  8695. + case '9':
  8696. + {
  8697. + alt7=1;
  8698. + }
  8699. + break;
  8700. +
  8701. + }
  8702. +
  8703. + switch (alt7)
  8704. + {
  8705. + case 1:
  8706. + // RSP.g:122:15: DIGIT09
  8707. + {
  8708. + /* 122:15: DIGIT09 */
  8709. + mDIGIT09(ctx );
  8710. + if (HASEXCEPTION())
  8711. + {
  8712. + goto ruleINTEx;
  8713. + }
  8714. +
  8715. +
  8716. + }
  8717. + break;
  8718. +
  8719. + default:
  8720. + goto loop7; /* break out of the loop */
  8721. + break;
  8722. + }
  8723. + }
  8724. + loop7: ; /* Jump out to here if this rule does not match */
  8725. +
  8726. +
  8727. + }
  8728. +
  8729. + LEXSTATE->type = _type;
  8730. +
  8731. + // This is where rules clean up and exit
  8732. + //
  8733. + goto ruleINTEx; /* Prevent compiler warnings */
  8734. + ruleINTEx: ;
  8735. +
  8736. +}
  8737. +// $ANTLR end INT
  8738. +
  8739. +// Comes from: 125:6: ( DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) )
  8740. +/** \brief Lexer rule generated by ANTLR3
  8741. + *
  8742. + * $ANTLR start DATE
  8743. + *
  8744. + * Looks to match the characters the constitute the token DATE
  8745. + * from the attached input stream.
  8746. + *
  8747. + *
  8748. + * \remark
  8749. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  8750. + */
  8751. +static ANTLR3_INLINE
  8752. +void mDATE(pRSPLexer ctx)
  8753. +{
  8754. + ANTLR3_UINT32 _type;
  8755. +
  8756. + _type = DATE;
  8757. +
  8758. +
  8759. + // RSP.g:125:6: ( DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) )
  8760. + // RSP.g:125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' )
  8761. + {
  8762. + /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */
  8763. + mDIGIT19(ctx );
  8764. + if (HASEXCEPTION())
  8765. + {
  8766. + goto ruleDATEEx;
  8767. + }
  8768. +
  8769. + /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */
  8770. + mDIGIT09(ctx );
  8771. + if (HASEXCEPTION())
  8772. + {
  8773. + goto ruleDATEEx;
  8774. + }
  8775. +
  8776. + /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */
  8777. + mDIGIT09(ctx );
  8778. + if (HASEXCEPTION())
  8779. + {
  8780. + goto ruleDATEEx;
  8781. + }
  8782. +
  8783. + /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */
  8784. + mDIGIT09(ctx );
  8785. + if (HASEXCEPTION())
  8786. + {
  8787. + goto ruleDATEEx;
  8788. + }
  8789. +
  8790. + MATCHC('-');
  8791. + if (HASEXCEPTION())
  8792. + {
  8793. + goto ruleDATEEx;
  8794. + }
  8795. +
  8796. +
  8797. + // RSP.g:125:44: ( '0' DIGIT19 | '1' '0' .. '2' )
  8798. + {
  8799. + int alt8=2;
  8800. + switch ( LA(1) )
  8801. + {
  8802. + case '0':
  8803. + {
  8804. + alt8=1;
  8805. + }
  8806. + break;
  8807. + case '1':
  8808. + {
  8809. + alt8=2;
  8810. + }
  8811. + break;
  8812. +
  8813. + default:
  8814. + CONSTRUCTEX();
  8815. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8816. + EXCEPTION->message = (void *)"";
  8817. + EXCEPTION->decisionNum = 8;
  8818. + EXCEPTION->state = 0;
  8819. +
  8820. +
  8821. + goto ruleDATEEx;
  8822. + }
  8823. +
  8824. + switch (alt8)
  8825. + {
  8826. + case 1:
  8827. + // RSP.g:125:45: '0' DIGIT19
  8828. + {
  8829. + MATCHC('0');
  8830. + if (HASEXCEPTION())
  8831. + {
  8832. + goto ruleDATEEx;
  8833. + }
  8834. +
  8835. + /* 125:45: '0' DIGIT19 */
  8836. + mDIGIT19(ctx );
  8837. + if (HASEXCEPTION())
  8838. + {
  8839. + goto ruleDATEEx;
  8840. + }
  8841. +
  8842. +
  8843. + }
  8844. + break;
  8845. + case 2:
  8846. + // RSP.g:125:59: '1' '0' .. '2'
  8847. + {
  8848. + MATCHC('1');
  8849. + if (HASEXCEPTION())
  8850. + {
  8851. + goto ruleDATEEx;
  8852. + }
  8853. +
  8854. + MATCHRANGE('0', '2');
  8855. + if (HASEXCEPTION())
  8856. + {
  8857. + goto ruleDATEEx;
  8858. + }
  8859. +
  8860. +
  8861. + }
  8862. + break;
  8863. +
  8864. + }
  8865. + }
  8866. + MATCHC('-');
  8867. + if (HASEXCEPTION())
  8868. + {
  8869. + goto ruleDATEEx;
  8870. + }
  8871. +
  8872. +
  8873. + // RSP.g:125:77: ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' )
  8874. + {
  8875. + int alt9=3;
  8876. + switch ( LA(1) )
  8877. + {
  8878. + case '0':
  8879. + {
  8880. + alt9=1;
  8881. + }
  8882. + break;
  8883. + case '1':
  8884. + case '2':
  8885. + {
  8886. + alt9=2;
  8887. + }
  8888. + break;
  8889. + case '3':
  8890. + {
  8891. + alt9=3;
  8892. + }
  8893. + break;
  8894. +
  8895. + default:
  8896. + CONSTRUCTEX();
  8897. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  8898. + EXCEPTION->message = (void *)"";
  8899. + EXCEPTION->decisionNum = 9;
  8900. + EXCEPTION->state = 0;
  8901. +
  8902. +
  8903. + goto ruleDATEEx;
  8904. + }
  8905. +
  8906. + switch (alt9)
  8907. + {
  8908. + case 1:
  8909. + // RSP.g:125:78: '0' DIGIT19
  8910. + {
  8911. + MATCHC('0');
  8912. + if (HASEXCEPTION())
  8913. + {
  8914. + goto ruleDATEEx;
  8915. + }
  8916. +
  8917. + /* 125:78: '0' DIGIT19 */
  8918. + mDIGIT19(ctx );
  8919. + if (HASEXCEPTION())
  8920. + {
  8921. + goto ruleDATEEx;
  8922. + }
  8923. +
  8924. +
  8925. + }
  8926. + break;
  8927. + case 2:
  8928. + // RSP.g:125:92: '1' .. '2' DIGIT09
  8929. + {
  8930. + MATCHRANGE('1', '2');
  8931. + if (HASEXCEPTION())
  8932. + {
  8933. + goto ruleDATEEx;
  8934. + }
  8935. +
  8936. + /* 125:92: '1' .. '2' DIGIT09 */
  8937. + mDIGIT09(ctx );
  8938. + if (HASEXCEPTION())
  8939. + {
  8940. + goto ruleDATEEx;
  8941. + }
  8942. +
  8943. +
  8944. + }
  8945. + break;
  8946. + case 3:
  8947. + // RSP.g:125:111: '3' '0' .. '1'
  8948. + {
  8949. + MATCHC('3');
  8950. + if (HASEXCEPTION())
  8951. + {
  8952. + goto ruleDATEEx;
  8953. + }
  8954. +
  8955. + MATCHRANGE('0', '1');
  8956. + if (HASEXCEPTION())
  8957. + {
  8958. + goto ruleDATEEx;
  8959. + }
  8960. +
  8961. +
  8962. + }
  8963. + break;
  8964. +
  8965. + }
  8966. + }
  8967. +
  8968. + }
  8969. +
  8970. + LEXSTATE->type = _type;
  8971. +
  8972. + // This is where rules clean up and exit
  8973. + //
  8974. + goto ruleDATEEx; /* Prevent compiler warnings */
  8975. + ruleDATEEx: ;
  8976. +
  8977. +}
  8978. +// $ANTLR end DATE
  8979. +
  8980. +// Comes from: 133:2: ( QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE )
  8981. +/** \brief Lexer rule generated by ANTLR3
  8982. + *
  8983. + * $ANTLR start STR
  8984. + *
  8985. + * Looks to match the characters the constitute the token STR
  8986. + * from the attached input stream.
  8987. + *
  8988. + *
  8989. + * \remark
  8990. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  8991. + */
  8992. +static ANTLR3_INLINE
  8993. +void mSTR(pRSPLexer ctx)
  8994. +{
  8995. + ANTLR3_UINT32 _type;
  8996. + pANTLR3_COMMON_TOKEN esc;
  8997. + ANTLR3_UINT32 reg;
  8998. +
  8999. +
  9000. + esc = NULL;
  9001. +
  9002. + _type = STR;
  9003. +
  9004. + pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory);
  9005. +
  9006. + // RSP.g:133:2: ( QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE )
  9007. + // RSP.g:133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE
  9008. + {
  9009. + /* 133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE */
  9010. + mQUOTE(ctx );
  9011. + if (HASEXCEPTION())
  9012. + {
  9013. + goto ruleSTREx;
  9014. + }
  9015. +
  9016. + // RSP.g:133:10: (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+
  9017. + {
  9018. + int cnt10=0;
  9019. +
  9020. + for (;;)
  9021. + {
  9022. + int alt10=3;
  9023. + {
  9024. + /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState)
  9025. + */
  9026. + int LA10_0 = LA(1);
  9027. + if ( (((LA10_0 >= 0x0000) && (LA10_0 <= '!')) || ((LA10_0 >= '#') && (LA10_0 <= '[')) || ((LA10_0 >= ']') && (LA10_0 <= 0xFFFF))) )
  9028. + {
  9029. + alt10=1;
  9030. + }
  9031. + else if ( (LA10_0 == '\\') )
  9032. + {
  9033. + alt10=2;
  9034. + }
  9035. +
  9036. + }
  9037. + switch (alt10)
  9038. + {
  9039. + case 1:
  9040. + // RSP.g:133:12: reg=~ ( '\\\\' | '\"' )
  9041. + {
  9042. + reg= LA(1);
  9043. + if ( ((LA(1) >= 0x0000) && (LA(1) <= '!')) || ((LA(1) >= '#') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) )
  9044. + {
  9045. + CONSUME();
  9046. +
  9047. + }
  9048. + else
  9049. + {
  9050. + CONSTRUCTEX();
  9051. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  9052. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  9053. +
  9054. + LRECOVER(); goto ruleSTREx;
  9055. + }
  9056. +
  9057. + {
  9058. + unesc->addc(unesc, reg);
  9059. + }
  9060. +
  9061. + }
  9062. + break;
  9063. + case 2:
  9064. + // RSP.g:134:6: esc= ESCAPED
  9065. + {
  9066. + /* 134:6: esc= ESCAPED */
  9067. + {
  9068. + ANTLR3_MARKER escStart381 = GETCHARINDEX();
  9069. + mESCAPED(ctx );
  9070. + if (HASEXCEPTION())
  9071. + {
  9072. + goto ruleSTREx;
  9073. + }
  9074. +
  9075. + esc = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory);
  9076. + esc->setType(esc, ANTLR3_TOKEN_INVALID);
  9077. + esc->setStartIndex(esc, escStart381);
  9078. + esc->setStopIndex(esc, GETCHARINDEX()-1);
  9079. + esc->input = INPUT;
  9080. + }
  9081. + {
  9082. + unesc->appendS(unesc, GETTEXT());
  9083. + }
  9084. +
  9085. + }
  9086. + break;
  9087. +
  9088. + default:
  9089. +
  9090. + if ( cnt10 >= 1 )
  9091. + {
  9092. + goto loop10;
  9093. + }
  9094. + /* mismatchedSetEx()
  9095. + */
  9096. + CONSTRUCTEX();
  9097. + EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
  9098. + EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;
  9099. +
  9100. +
  9101. + goto ruleSTREx;
  9102. + }
  9103. + cnt10++;
  9104. + }
  9105. + loop10: ; /* Jump to here if this rule does not match */
  9106. + }
  9107. + /* 133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE */
  9108. + mQUOTE(ctx );
  9109. + if (HASEXCEPTION())
  9110. + {
  9111. + goto ruleSTREx;
  9112. + }
  9113. +
  9114. + {
  9115. + SETTEXT(unesc);
  9116. + }
  9117. +
  9118. + }
  9119. +
  9120. + LEXSTATE->type = _type;
  9121. +
  9122. + // This is where rules clean up and exit
  9123. + //
  9124. + goto ruleSTREx; /* Prevent compiler warnings */
  9125. + ruleSTREx: ;
  9126. +
  9127. + esc = NULL;
  9128. +
  9129. +}
  9130. +// $ANTLR end STR
  9131. +
  9132. +// Comes from: 138:9: ( '\\\\' ( '\\\\' | '\"' ) )
  9133. +/** \brief Lexer rule generated by ANTLR3
  9134. + *
  9135. + * $ANTLR start ESCAPED
  9136. + *
  9137. + * Looks to match the characters the constitute the token ESCAPED
  9138. + * from the attached input stream.
  9139. + *
  9140. + *
  9141. + * \remark
  9142. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  9143. + */
  9144. +static ANTLR3_INLINE
  9145. +void mESCAPED(pRSPLexer ctx)
  9146. +{
  9147. + ANTLR3_UINT32 _type;
  9148. +
  9149. +
  9150. + // RSP.g:138:9: ( '\\\\' ( '\\\\' | '\"' ) )
  9151. + // RSP.g:138:11: '\\\\' ( '\\\\' | '\"' )
  9152. + {
  9153. + MATCHC('\\');
  9154. + if (HASEXCEPTION())
  9155. + {
  9156. + goto ruleESCAPEDEx;
  9157. + }
  9158. +
  9159. +
  9160. + // RSP.g:139:3: ( '\\\\' | '\"' )
  9161. + {
  9162. + int alt11=2;
  9163. + switch ( LA(1) )
  9164. + {
  9165. + case '\\':
  9166. + {
  9167. + alt11=1;
  9168. + }
  9169. + break;
  9170. + case '"':
  9171. + {
  9172. + alt11=2;
  9173. + }
  9174. + break;
  9175. +
  9176. + default:
  9177. + CONSTRUCTEX();
  9178. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  9179. + EXCEPTION->message = (void *)"";
  9180. + EXCEPTION->decisionNum = 11;
  9181. + EXCEPTION->state = 0;
  9182. +
  9183. +
  9184. + goto ruleESCAPEDEx;
  9185. + }
  9186. +
  9187. + switch (alt11)
  9188. + {
  9189. + case 1:
  9190. + // RSP.g:139:5: '\\\\'
  9191. + {
  9192. + MATCHC('\\');
  9193. + if (HASEXCEPTION())
  9194. + {
  9195. + goto ruleESCAPEDEx;
  9196. + }
  9197. +
  9198. + {
  9199. + SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\"));
  9200. + }
  9201. +
  9202. + }
  9203. + break;
  9204. + case 2:
  9205. + // RSP.g:140:5: '\"'
  9206. + {
  9207. + MATCHC('"');
  9208. + if (HASEXCEPTION())
  9209. + {
  9210. + goto ruleESCAPEDEx;
  9211. + }
  9212. +
  9213. + {
  9214. + SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\""));
  9215. + }
  9216. +
  9217. + }
  9218. + break;
  9219. +
  9220. + }
  9221. + }
  9222. +
  9223. + }
  9224. +
  9225. +
  9226. +
  9227. + // This is where rules clean up and exit
  9228. + //
  9229. + goto ruleESCAPEDEx; /* Prevent compiler warnings */
  9230. + ruleESCAPEDEx: ;
  9231. +
  9232. +}
  9233. +// $ANTLR end ESCAPED
  9234. +
  9235. +// Comes from: 145:9: ( '0' .. '9' )
  9236. +/** \brief Lexer rule generated by ANTLR3
  9237. + *
  9238. + * $ANTLR start DIGIT09
  9239. + *
  9240. + * Looks to match the characters the constitute the token DIGIT09
  9241. + * from the attached input stream.
  9242. + *
  9243. + *
  9244. + * \remark
  9245. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  9246. + */
  9247. +static ANTLR3_INLINE
  9248. +void mDIGIT09(pRSPLexer ctx)
  9249. +{
  9250. + ANTLR3_UINT32 _type;
  9251. +
  9252. +
  9253. + // RSP.g:145:9: ( '0' .. '9' )
  9254. + // RSP.g:145:11: '0' .. '9'
  9255. + {
  9256. + MATCHRANGE('0', '9');
  9257. + if (HASEXCEPTION())
  9258. + {
  9259. + goto ruleDIGIT09Ex;
  9260. + }
  9261. +
  9262. +
  9263. + }
  9264. +
  9265. +
  9266. +
  9267. + // This is where rules clean up and exit
  9268. + //
  9269. + goto ruleDIGIT09Ex; /* Prevent compiler warnings */
  9270. + ruleDIGIT09Ex: ;
  9271. +
  9272. +}
  9273. +// $ANTLR end DIGIT09
  9274. +
  9275. +// Comes from: 148:9: ( '1' .. '9' )
  9276. +/** \brief Lexer rule generated by ANTLR3
  9277. + *
  9278. + * $ANTLR start DIGIT19
  9279. + *
  9280. + * Looks to match the characters the constitute the token DIGIT19
  9281. + * from the attached input stream.
  9282. + *
  9283. + *
  9284. + * \remark
  9285. + * - lexer->error == ANTLR3_TRUE if an exception was thrown.
  9286. + */
  9287. +static ANTLR3_INLINE
  9288. +void mDIGIT19(pRSPLexer ctx)
  9289. +{
  9290. + ANTLR3_UINT32 _type;
  9291. +
  9292. +
  9293. + // RSP.g:148:9: ( '1' .. '9' )
  9294. + // RSP.g:148:11: '1' .. '9'
  9295. + {
  9296. + MATCHRANGE('1', '9');
  9297. + if (HASEXCEPTION())
  9298. + {
  9299. + goto ruleDIGIT19Ex;
  9300. + }
  9301. +
  9302. +
  9303. + }
  9304. +
  9305. +
  9306. +
  9307. + // This is where rules clean up and exit
  9308. + //
  9309. + goto ruleDIGIT19Ex; /* Prevent compiler warnings */
  9310. + ruleDIGIT19Ex: ;
  9311. +
  9312. +}
  9313. +// $ANTLR end DIGIT19
  9314. +
  9315. +/** This is the entry point in to the lexer from an object that
  9316. + * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM
  9317. + */
  9318. +static void
  9319. +mTokens(pRSPLexer ctx)
  9320. +{
  9321. + {
  9322. + // RSP.g:1:8: ( QUOTE | LPAR | RPAR | AND | OR | NOT | EQUAL | INCLUDES | STARTSW | ENDSW | GREATER | LESS | GTE | LTE | BEFORE | AFTER | DAY | WEEK | MONTH | YEAR | TODAY | NEWLINE | WS | FIELD | INT | DATE | STR )
  9323. +
  9324. + ANTLR3_UINT32 alt12;
  9325. +
  9326. + alt12=27;
  9327. +
  9328. + switch ( LA(1) )
  9329. + {
  9330. + case '"':
  9331. + {
  9332. +
  9333. + {
  9334. + int LA12_1 = LA(2);
  9335. + if ( (((LA12_1 >= 0x0000) && (LA12_1 <= '!')) || ((LA12_1 >= '#') && (LA12_1 <= 0xFFFF))) )
  9336. + {
  9337. + alt12=27;
  9338. + }
  9339. + else
  9340. + {
  9341. + alt12=1; }
  9342. + }
  9343. + }
  9344. + break;
  9345. + case '(':
  9346. + {
  9347. + alt12=2;
  9348. + }
  9349. + break;
  9350. + case ')':
  9351. + {
  9352. + alt12=3;
  9353. + }
  9354. + break;
  9355. + case 'a':
  9356. + {
  9357. + switch ( LA(2) )
  9358. + {
  9359. + case 'n':
  9360. + {
  9361. + switch ( LA(3) )
  9362. + {
  9363. + case 'd':
  9364. + {
  9365. + switch ( LA(4) )
  9366. + {
  9367. + case '_':
  9368. + case 'a':
  9369. + case 'b':
  9370. + case 'c':
  9371. + case 'd':
  9372. + case 'e':
  9373. + case 'f':
  9374. + case 'g':
  9375. + case 'h':
  9376. + case 'i':
  9377. + case 'j':
  9378. + case 'k':
  9379. + case 'l':
  9380. + case 'm':
  9381. + case 'n':
  9382. + case 'o':
  9383. + case 'p':
  9384. + case 'q':
  9385. + case 'r':
  9386. + case 's':
  9387. + case 't':
  9388. + case 'u':
  9389. + case 'v':
  9390. + case 'w':
  9391. + case 'x':
  9392. + case 'y':
  9393. + case 'z':
  9394. + {
  9395. + alt12=24;
  9396. + }
  9397. + break;
  9398. +
  9399. + default:
  9400. + alt12=4;}
  9401. +
  9402. + }
  9403. + break;
  9404. +
  9405. + default:
  9406. + alt12=24;}
  9407. +
  9408. + }
  9409. + break;
  9410. + case 'f':
  9411. + {
  9412. + switch ( LA(3) )
  9413. + {
  9414. + case 't':
  9415. + {
  9416. + switch ( LA(4) )
  9417. + {
  9418. + case 'e':
  9419. + {
  9420. + switch ( LA(5) )
  9421. + {
  9422. + case 'r':
  9423. + {
  9424. + switch ( LA(6) )
  9425. + {
  9426. + case '_':
  9427. + case 'a':
  9428. + case 'b':
  9429. + case 'c':
  9430. + case 'd':
  9431. + case 'e':
  9432. + case 'f':
  9433. + case 'g':
  9434. + case 'h':
  9435. + case 'i':
  9436. + case 'j':
  9437. + case 'k':
  9438. + case 'l':
  9439. + case 'm':
  9440. + case 'n':
  9441. + case 'o':
  9442. + case 'p':
  9443. + case 'q':
  9444. + case 'r':
  9445. + case 's':
  9446. + case 't':
  9447. + case 'u':
  9448. + case 'v':
  9449. + case 'w':
  9450. + case 'x':
  9451. + case 'y':
  9452. + case 'z':
  9453. + {
  9454. + alt12=24;
  9455. + }
  9456. + break;
  9457. +
  9458. + default:
  9459. + alt12=16;}
  9460. +
  9461. + }
  9462. + break;
  9463. +
  9464. + default:
  9465. + alt12=24;}
  9466. +
  9467. + }
  9468. + break;
  9469. +
  9470. + default:
  9471. + alt12=24;}
  9472. +
  9473. + }
  9474. + break;
  9475. +
  9476. + default:
  9477. + alt12=24;}
  9478. +
  9479. + }
  9480. + break;
  9481. + case '_':
  9482. + case 'a':
  9483. + case 'b':
  9484. + case 'c':
  9485. + case 'd':
  9486. + case 'e':
  9487. + case 'g':
  9488. + case 'h':
  9489. + case 'i':
  9490. + case 'j':
  9491. + case 'k':
  9492. + case 'l':
  9493. + case 'm':
  9494. + case 'o':
  9495. + case 'p':
  9496. + case 'q':
  9497. + case 'r':
  9498. + case 's':
  9499. + case 't':
  9500. + case 'u':
  9501. + case 'v':
  9502. + case 'w':
  9503. + case 'x':
  9504. + case 'y':
  9505. + case 'z':
  9506. + {
  9507. + alt12=24;
  9508. + }
  9509. + break;
  9510. +
  9511. + default:
  9512. + CONSTRUCTEX();
  9513. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  9514. + EXCEPTION->message = (void *)"";
  9515. + EXCEPTION->decisionNum = 12;
  9516. + EXCEPTION->state = 4;
  9517. +
  9518. +
  9519. + goto ruleTokensEx;
  9520. + }
  9521. +
  9522. + }
  9523. + break;
  9524. + case 'o':
  9525. + {
  9526. + switch ( LA(2) )
  9527. + {
  9528. + case 'r':
  9529. + {
  9530. + switch ( LA(3) )
  9531. + {
  9532. + case '_':
  9533. + case 'a':
  9534. + case 'b':
  9535. + case 'c':
  9536. + case 'd':
  9537. + case 'e':
  9538. + case 'f':
  9539. + case 'g':
  9540. + case 'h':
  9541. + case 'i':
  9542. + case 'j':
  9543. + case 'k':
  9544. + case 'l':
  9545. + case 'm':
  9546. + case 'n':
  9547. + case 'o':
  9548. + case 'p':
  9549. + case 'q':
  9550. + case 'r':
  9551. + case 's':
  9552. + case 't':
  9553. + case 'u':
  9554. + case 'v':
  9555. + case 'w':
  9556. + case 'x':
  9557. + case 'y':
  9558. + case 'z':
  9559. + {
  9560. + alt12=24;
  9561. + }
  9562. + break;
  9563. +
  9564. + default:
  9565. + alt12=5;}
  9566. +
  9567. + }
  9568. + break;
  9569. + case '_':
  9570. + case 'a':
  9571. + case 'b':
  9572. + case 'c':
  9573. + case 'd':
  9574. + case 'e':
  9575. + case 'f':
  9576. + case 'g':
  9577. + case 'h':
  9578. + case 'i':
  9579. + case 'j':
  9580. + case 'k':
  9581. + case 'l':
  9582. + case 'm':
  9583. + case 'n':
  9584. + case 'o':
  9585. + case 'p':
  9586. + case 'q':
  9587. + case 's':
  9588. + case 't':
  9589. + case 'u':
  9590. + case 'v':
  9591. + case 'w':
  9592. + case 'x':
  9593. + case 'y':
  9594. + case 'z':
  9595. + {
  9596. + alt12=24;
  9597. + }
  9598. + break;
  9599. +
  9600. + default:
  9601. + CONSTRUCTEX();
  9602. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  9603. + EXCEPTION->message = (void *)"";
  9604. + EXCEPTION->decisionNum = 12;
  9605. + EXCEPTION->state = 5;
  9606. +
  9607. +
  9608. + goto ruleTokensEx;
  9609. + }
  9610. +
  9611. + }
  9612. + break;
  9613. + case '!':
  9614. + {
  9615. + alt12=6;
  9616. + }
  9617. + break;
  9618. + case '=':
  9619. + {
  9620. + alt12=7;
  9621. + }
  9622. + break;
  9623. + case 'i':
  9624. + {
  9625. + switch ( LA(2) )
  9626. + {
  9627. + case 'n':
  9628. + {
  9629. + switch ( LA(3) )
  9630. + {
  9631. + case 'c':
  9632. + {
  9633. + switch ( LA(4) )
  9634. + {
  9635. + case 'l':
  9636. + {
  9637. + switch ( LA(5) )
  9638. + {
  9639. + case 'u':
  9640. + {
  9641. + switch ( LA(6) )
  9642. + {
  9643. + case 'd':
  9644. + {
  9645. + switch ( LA(7) )
  9646. + {
  9647. + case 'e':
  9648. + {
  9649. + switch ( LA(8) )
  9650. + {
  9651. + case 's':
  9652. + {
  9653. + switch ( LA(9) )
  9654. + {
  9655. + case '_':
  9656. + case 'a':
  9657. + case 'b':
  9658. + case 'c':
  9659. + case 'd':
  9660. + case 'e':
  9661. + case 'f':
  9662. + case 'g':
  9663. + case 'h':
  9664. + case 'i':
  9665. + case 'j':
  9666. + case 'k':
  9667. + case 'l':
  9668. + case 'm':
  9669. + case 'n':
  9670. + case 'o':
  9671. + case 'p':
  9672. + case 'q':
  9673. + case 'r':
  9674. + case 's':
  9675. + case 't':
  9676. + case 'u':
  9677. + case 'v':
  9678. + case 'w':
  9679. + case 'x':
  9680. + case 'y':
  9681. + case 'z':
  9682. + {
  9683. + alt12=24;
  9684. + }
  9685. + break;
  9686. +
  9687. + default:
  9688. + alt12=8;}
  9689. +
  9690. + }
  9691. + break;
  9692. +
  9693. + default:
  9694. + alt12=24;}
  9695. +
  9696. + }
  9697. + break;
  9698. +
  9699. + default:
  9700. + alt12=24;}
  9701. +
  9702. + }
  9703. + break;
  9704. +
  9705. + default:
  9706. + alt12=24;}
  9707. +
  9708. + }
  9709. + break;
  9710. +
  9711. + default:
  9712. + alt12=24;}
  9713. +
  9714. + }
  9715. + break;
  9716. +
  9717. + default:
  9718. + alt12=24;}
  9719. +
  9720. + }
  9721. + break;
  9722. +
  9723. + default:
  9724. + alt12=24;}
  9725. +
  9726. + }
  9727. + break;
  9728. + case '_':
  9729. + case 'a':
  9730. + case 'b':
  9731. + case 'c':
  9732. + case 'd':
  9733. + case 'e':
  9734. + case 'f':
  9735. + case 'g':
  9736. + case 'h':
  9737. + case 'i':
  9738. + case 'j':
  9739. + case 'k':
  9740. + case 'l':
  9741. + case 'm':
  9742. + case 'o':
  9743. + case 'p':
  9744. + case 'q':
  9745. + case 'r':
  9746. + case 's':
  9747. + case 't':
  9748. + case 'u':
  9749. + case 'v':
  9750. + case 'w':
  9751. + case 'x':
  9752. + case 'y':
  9753. + case 'z':
  9754. + {
  9755. + alt12=24;
  9756. + }
  9757. + break;
  9758. +
  9759. + default:
  9760. + CONSTRUCTEX();
  9761. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  9762. + EXCEPTION->message = (void *)"";
  9763. + EXCEPTION->decisionNum = 12;
  9764. + EXCEPTION->state = 8;
  9765. +
  9766. +
  9767. + goto ruleTokensEx;
  9768. + }
  9769. +
  9770. + }
  9771. + break;
  9772. + case 's':
  9773. + {
  9774. + switch ( LA(2) )
  9775. + {
  9776. + case 't':
  9777. + {
  9778. + switch ( LA(3) )
  9779. + {
  9780. + case 'a':
  9781. + {
  9782. + switch ( LA(4) )
  9783. + {
  9784. + case 'r':
  9785. + {
  9786. + switch ( LA(5) )
  9787. + {
  9788. + case 't':
  9789. + {
  9790. + switch ( LA(6) )
  9791. + {
  9792. + case 's':
  9793. + {
  9794. + switch ( LA(7) )
  9795. + {
  9796. + case 'w':
  9797. + {
  9798. + switch ( LA(8) )
  9799. + {
  9800. + case 'i':
  9801. + {
  9802. + switch ( LA(9) )
  9803. + {
  9804. + case 't':
  9805. + {
  9806. + switch ( LA(10) )
  9807. + {
  9808. + case 'h':
  9809. + {
  9810. + switch ( LA(11) )
  9811. + {
  9812. + case '_':
  9813. + case 'a':
  9814. + case 'b':
  9815. + case 'c':
  9816. + case 'd':
  9817. + case 'e':
  9818. + case 'f':
  9819. + case 'g':
  9820. + case 'h':
  9821. + case 'i':
  9822. + case 'j':
  9823. + case 'k':
  9824. + case 'l':
  9825. + case 'm':
  9826. + case 'n':
  9827. + case 'o':
  9828. + case 'p':
  9829. + case 'q':
  9830. + case 'r':
  9831. + case 's':
  9832. + case 't':
  9833. + case 'u':
  9834. + case 'v':
  9835. + case 'w':
  9836. + case 'x':
  9837. + case 'y':
  9838. + case 'z':
  9839. + {
  9840. + alt12=24;
  9841. + }
  9842. + break;
  9843. +
  9844. + default:
  9845. + alt12=9;}
  9846. +
  9847. + }
  9848. + break;
  9849. +
  9850. + default:
  9851. + alt12=24;}
  9852. +
  9853. + }
  9854. + break;
  9855. +
  9856. + default:
  9857. + alt12=24;}
  9858. +
  9859. + }
  9860. + break;
  9861. +
  9862. + default:
  9863. + alt12=24;}
  9864. +
  9865. + }
  9866. + break;
  9867. +
  9868. + default:
  9869. + alt12=24;}
  9870. +
  9871. + }
  9872. + break;
  9873. +
  9874. + default:
  9875. + alt12=24;}
  9876. +
  9877. + }
  9878. + break;
  9879. +
  9880. + default:
  9881. + alt12=24;}
  9882. +
  9883. + }
  9884. + break;
  9885. +
  9886. + default:
  9887. + alt12=24;}
  9888. +
  9889. + }
  9890. + break;
  9891. +
  9892. + default:
  9893. + alt12=24;}
  9894. +
  9895. + }
  9896. + break;
  9897. + case '_':
  9898. + case 'a':
  9899. + case 'b':
  9900. + case 'c':
  9901. + case 'd':
  9902. + case 'e':
  9903. + case 'f':
  9904. + case 'g':
  9905. + case 'h':
  9906. + case 'i':
  9907. + case 'j':
  9908. + case 'k':
  9909. + case 'l':
  9910. + case 'm':
  9911. + case 'n':
  9912. + case 'o':
  9913. + case 'p':
  9914. + case 'q':
  9915. + case 'r':
  9916. + case 's':
  9917. + case 'u':
  9918. + case 'v':
  9919. + case 'w':
  9920. + case 'x':
  9921. + case 'y':
  9922. + case 'z':
  9923. + {
  9924. + alt12=24;
  9925. + }
  9926. + break;
  9927. +
  9928. + default:
  9929. + CONSTRUCTEX();
  9930. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  9931. + EXCEPTION->message = (void *)"";
  9932. + EXCEPTION->decisionNum = 12;
  9933. + EXCEPTION->state = 9;
  9934. +
  9935. +
  9936. + goto ruleTokensEx;
  9937. + }
  9938. +
  9939. + }
  9940. + break;
  9941. + case 'e':
  9942. + {
  9943. + switch ( LA(2) )
  9944. + {
  9945. + case 'n':
  9946. + {
  9947. + switch ( LA(3) )
  9948. + {
  9949. + case 'd':
  9950. + {
  9951. + switch ( LA(4) )
  9952. + {
  9953. + case 's':
  9954. + {
  9955. + switch ( LA(5) )
  9956. + {
  9957. + case 'w':
  9958. + {
  9959. + switch ( LA(6) )
  9960. + {
  9961. + case 'i':
  9962. + {
  9963. + switch ( LA(7) )
  9964. + {
  9965. + case 't':
  9966. + {
  9967. + switch ( LA(8) )
  9968. + {
  9969. + case 'h':
  9970. + {
  9971. + switch ( LA(9) )
  9972. + {
  9973. + case '_':
  9974. + case 'a':
  9975. + case 'b':
  9976. + case 'c':
  9977. + case 'd':
  9978. + case 'e':
  9979. + case 'f':
  9980. + case 'g':
  9981. + case 'h':
  9982. + case 'i':
  9983. + case 'j':
  9984. + case 'k':
  9985. + case 'l':
  9986. + case 'm':
  9987. + case 'n':
  9988. + case 'o':
  9989. + case 'p':
  9990. + case 'q':
  9991. + case 'r':
  9992. + case 's':
  9993. + case 't':
  9994. + case 'u':
  9995. + case 'v':
  9996. + case 'w':
  9997. + case 'x':
  9998. + case 'y':
  9999. + case 'z':
  10000. + {
  10001. + alt12=24;
  10002. + }
  10003. + break;
  10004. +
  10005. + default:
  10006. + alt12=10;}
  10007. +
  10008. + }
  10009. + break;
  10010. +
  10011. + default:
  10012. + alt12=24;}
  10013. +
  10014. + }
  10015. + break;
  10016. +
  10017. + default:
  10018. + alt12=24;}
  10019. +
  10020. + }
  10021. + break;
  10022. +
  10023. + default:
  10024. + alt12=24;}
  10025. +
  10026. + }
  10027. + break;
  10028. +
  10029. + default:
  10030. + alt12=24;}
  10031. +
  10032. + }
  10033. + break;
  10034. +
  10035. + default:
  10036. + alt12=24;}
  10037. +
  10038. + }
  10039. + break;
  10040. +
  10041. + default:
  10042. + alt12=24;}
  10043. +
  10044. + }
  10045. + break;
  10046. + case '_':
  10047. + case 'a':
  10048. + case 'b':
  10049. + case 'c':
  10050. + case 'd':
  10051. + case 'e':
  10052. + case 'f':
  10053. + case 'g':
  10054. + case 'h':
  10055. + case 'i':
  10056. + case 'j':
  10057. + case 'k':
  10058. + case 'l':
  10059. + case 'm':
  10060. + case 'o':
  10061. + case 'p':
  10062. + case 'q':
  10063. + case 'r':
  10064. + case 's':
  10065. + case 't':
  10066. + case 'u':
  10067. + case 'v':
  10068. + case 'w':
  10069. + case 'x':
  10070. + case 'y':
  10071. + case 'z':
  10072. + {
  10073. + alt12=24;
  10074. + }
  10075. + break;
  10076. +
  10077. + default:
  10078. + CONSTRUCTEX();
  10079. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  10080. + EXCEPTION->message = (void *)"";
  10081. + EXCEPTION->decisionNum = 12;
  10082. + EXCEPTION->state = 10;
  10083. +
  10084. +
  10085. + goto ruleTokensEx;
  10086. + }
  10087. +
  10088. + }
  10089. + break;
  10090. + case '>':
  10091. + {
  10092. + switch ( LA(2) )
  10093. + {
  10094. + case '=':
  10095. + {
  10096. + alt12=13;
  10097. + }
  10098. + break;
  10099. +
  10100. + default:
  10101. + alt12=11;}
  10102. +
  10103. + }
  10104. + break;
  10105. + case '<':
  10106. + {
  10107. + switch ( LA(2) )
  10108. + {
  10109. + case '=':
  10110. + {
  10111. + alt12=14;
  10112. + }
  10113. + break;
  10114. +
  10115. + default:
  10116. + alt12=12;}
  10117. +
  10118. + }
  10119. + break;
  10120. + case 'b':
  10121. + {
  10122. + switch ( LA(2) )
  10123. + {
  10124. + case 'e':
  10125. + {
  10126. + switch ( LA(3) )
  10127. + {
  10128. + case 'f':
  10129. + {
  10130. + switch ( LA(4) )
  10131. + {
  10132. + case 'o':
  10133. + {
  10134. + switch ( LA(5) )
  10135. + {
  10136. + case 'r':
  10137. + {
  10138. + switch ( LA(6) )
  10139. + {
  10140. + case 'e':
  10141. + {
  10142. + switch ( LA(7) )
  10143. + {
  10144. + case '_':
  10145. + case 'a':
  10146. + case 'b':
  10147. + case 'c':
  10148. + case 'd':
  10149. + case 'e':
  10150. + case 'f':
  10151. + case 'g':
  10152. + case 'h':
  10153. + case 'i':
  10154. + case 'j':
  10155. + case 'k':
  10156. + case 'l':
  10157. + case 'm':
  10158. + case 'n':
  10159. + case 'o':
  10160. + case 'p':
  10161. + case 'q':
  10162. + case 'r':
  10163. + case 's':
  10164. + case 't':
  10165. + case 'u':
  10166. + case 'v':
  10167. + case 'w':
  10168. + case 'x':
  10169. + case 'y':
  10170. + case 'z':
  10171. + {
  10172. + alt12=24;
  10173. + }
  10174. + break;
  10175. +
  10176. + default:
  10177. + alt12=15;}
  10178. +
  10179. + }
  10180. + break;
  10181. +
  10182. + default:
  10183. + alt12=24;}
  10184. +
  10185. + }
  10186. + break;
  10187. +
  10188. + default:
  10189. + alt12=24;}
  10190. +
  10191. + }
  10192. + break;
  10193. +
  10194. + default:
  10195. + alt12=24;}
  10196. +
  10197. + }
  10198. + break;
  10199. +
  10200. + default:
  10201. + alt12=24;}
  10202. +
  10203. + }
  10204. + break;
  10205. + case '_':
  10206. + case 'a':
  10207. + case 'b':
  10208. + case 'c':
  10209. + case 'd':
  10210. + case 'f':
  10211. + case 'g':
  10212. + case 'h':
  10213. + case 'i':
  10214. + case 'j':
  10215. + case 'k':
  10216. + case 'l':
  10217. + case 'm':
  10218. + case 'n':
  10219. + case 'o':
  10220. + case 'p':
  10221. + case 'q':
  10222. + case 'r':
  10223. + case 's':
  10224. + case 't':
  10225. + case 'u':
  10226. + case 'v':
  10227. + case 'w':
  10228. + case 'x':
  10229. + case 'y':
  10230. + case 'z':
  10231. + {
  10232. + alt12=24;
  10233. + }
  10234. + break;
  10235. +
  10236. + default:
  10237. + CONSTRUCTEX();
  10238. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  10239. + EXCEPTION->message = (void *)"";
  10240. + EXCEPTION->decisionNum = 12;
  10241. + EXCEPTION->state = 13;
  10242. +
  10243. +
  10244. + goto ruleTokensEx;
  10245. + }
  10246. +
  10247. + }
  10248. + break;
  10249. + case 'd':
  10250. + {
  10251. + switch ( LA(2) )
  10252. + {
  10253. + case 'a':
  10254. + {
  10255. + switch ( LA(3) )
  10256. + {
  10257. + case 'y':
  10258. + {
  10259. + switch ( LA(4) )
  10260. + {
  10261. + case 's':
  10262. + {
  10263. + switch ( LA(5) )
  10264. + {
  10265. + case '_':
  10266. + case 'a':
  10267. + case 'b':
  10268. + case 'c':
  10269. + case 'd':
  10270. + case 'e':
  10271. + case 'f':
  10272. + case 'g':
  10273. + case 'h':
  10274. + case 'i':
  10275. + case 'j':
  10276. + case 'k':
  10277. + case 'l':
  10278. + case 'm':
  10279. + case 'n':
  10280. + case 'o':
  10281. + case 'p':
  10282. + case 'q':
  10283. + case 'r':
  10284. + case 's':
  10285. + case 't':
  10286. + case 'u':
  10287. + case 'v':
  10288. + case 'w':
  10289. + case 'x':
  10290. + case 'y':
  10291. + case 'z':
  10292. + {
  10293. + alt12=24;
  10294. + }
  10295. + break;
  10296. +
  10297. + default:
  10298. + alt12=17;}
  10299. +
  10300. + }
  10301. + break;
  10302. + case '_':
  10303. + case 'a':
  10304. + case 'b':
  10305. + case 'c':
  10306. + case 'd':
  10307. + case 'e':
  10308. + case 'f':
  10309. + case 'g':
  10310. + case 'h':
  10311. + case 'i':
  10312. + case 'j':
  10313. + case 'k':
  10314. + case 'l':
  10315. + case 'm':
  10316. + case 'n':
  10317. + case 'o':
  10318. + case 'p':
  10319. + case 'q':
  10320. + case 'r':
  10321. + case 't':
  10322. + case 'u':
  10323. + case 'v':
  10324. + case 'w':
  10325. + case 'x':
  10326. + case 'y':
  10327. + case 'z':
  10328. + {
  10329. + alt12=24;
  10330. + }
  10331. + break;
  10332. +
  10333. + default:
  10334. + alt12=17;}
  10335. +
  10336. + }
  10337. + break;
  10338. +
  10339. + default:
  10340. + alt12=24;}
  10341. +
  10342. + }
  10343. + break;
  10344. + case '_':
  10345. + case 'b':
  10346. + case 'c':
  10347. + case 'd':
  10348. + case 'e':
  10349. + case 'f':
  10350. + case 'g':
  10351. + case 'h':
  10352. + case 'i':
  10353. + case 'j':
  10354. + case 'k':
  10355. + case 'l':
  10356. + case 'm':
  10357. + case 'n':
  10358. + case 'o':
  10359. + case 'p':
  10360. + case 'q':
  10361. + case 'r':
  10362. + case 's':
  10363. + case 't':
  10364. + case 'u':
  10365. + case 'v':
  10366. + case 'w':
  10367. + case 'x':
  10368. + case 'y':
  10369. + case 'z':
  10370. + {
  10371. + alt12=24;
  10372. + }
  10373. + break;
  10374. +
  10375. + default:
  10376. + CONSTRUCTEX();
  10377. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  10378. + EXCEPTION->message = (void *)"";
  10379. + EXCEPTION->decisionNum = 12;
  10380. + EXCEPTION->state = 14;
  10381. +
  10382. +
  10383. + goto ruleTokensEx;
  10384. + }
  10385. +
  10386. + }
  10387. + break;
  10388. + case 'w':
  10389. + {
  10390. + switch ( LA(2) )
  10391. + {
  10392. + case 'e':
  10393. + {
  10394. + switch ( LA(3) )
  10395. + {
  10396. + case 'e':
  10397. + {
  10398. + switch ( LA(4) )
  10399. + {
  10400. + case 'k':
  10401. + {
  10402. + switch ( LA(5) )
  10403. + {
  10404. + case 's':
  10405. + {
  10406. + switch ( LA(6) )
  10407. + {
  10408. + case '_':
  10409. + case 'a':
  10410. + case 'b':
  10411. + case 'c':
  10412. + case 'd':
  10413. + case 'e':
  10414. + case 'f':
  10415. + case 'g':
  10416. + case 'h':
  10417. + case 'i':
  10418. + case 'j':
  10419. + case 'k':
  10420. + case 'l':
  10421. + case 'm':
  10422. + case 'n':
  10423. + case 'o':
  10424. + case 'p':
  10425. + case 'q':
  10426. + case 'r':
  10427. + case 's':
  10428. + case 't':
  10429. + case 'u':
  10430. + case 'v':
  10431. + case 'w':
  10432. + case 'x':
  10433. + case 'y':
  10434. + case 'z':
  10435. + {
  10436. + alt12=24;
  10437. + }
  10438. + break;
  10439. +
  10440. + default:
  10441. + alt12=18;}
  10442. +
  10443. + }
  10444. + break;
  10445. + case '_':
  10446. + case 'a':
  10447. + case 'b':
  10448. + case 'c':
  10449. + case 'd':
  10450. + case 'e':
  10451. + case 'f':
  10452. + case 'g':
  10453. + case 'h':
  10454. + case 'i':
  10455. + case 'j':
  10456. + case 'k':
  10457. + case 'l':
  10458. + case 'm':
  10459. + case 'n':
  10460. + case 'o':
  10461. + case 'p':
  10462. + case 'q':
  10463. + case 'r':
  10464. + case 't':
  10465. + case 'u':
  10466. + case 'v':
  10467. + case 'w':
  10468. + case 'x':
  10469. + case 'y':
  10470. + case 'z':
  10471. + {
  10472. + alt12=24;
  10473. + }
  10474. + break;
  10475. +
  10476. + default:
  10477. + alt12=18;}
  10478. +
  10479. + }
  10480. + break;
  10481. +
  10482. + default:
  10483. + alt12=24;}
  10484. +
  10485. + }
  10486. + break;
  10487. +
  10488. + default:
  10489. + alt12=24;}
  10490. +
  10491. + }
  10492. + break;
  10493. + case '_':
  10494. + case 'a':
  10495. + case 'b':
  10496. + case 'c':
  10497. + case 'd':
  10498. + case 'f':
  10499. + case 'g':
  10500. + case 'h':
  10501. + case 'i':
  10502. + case 'j':
  10503. + case 'k':
  10504. + case 'l':
  10505. + case 'm':
  10506. + case 'n':
  10507. + case 'o':
  10508. + case 'p':
  10509. + case 'q':
  10510. + case 'r':
  10511. + case 's':
  10512. + case 't':
  10513. + case 'u':
  10514. + case 'v':
  10515. + case 'w':
  10516. + case 'x':
  10517. + case 'y':
  10518. + case 'z':
  10519. + {
  10520. + alt12=24;
  10521. + }
  10522. + break;
  10523. +
  10524. + default:
  10525. + CONSTRUCTEX();
  10526. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  10527. + EXCEPTION->message = (void *)"";
  10528. + EXCEPTION->decisionNum = 12;
  10529. + EXCEPTION->state = 15;
  10530. +
  10531. +
  10532. + goto ruleTokensEx;
  10533. + }
  10534. +
  10535. + }
  10536. + break;
  10537. + case 'm':
  10538. + {
  10539. + switch ( LA(2) )
  10540. + {
  10541. + case 'o':
  10542. + {
  10543. + switch ( LA(3) )
  10544. + {
  10545. + case 'n':
  10546. + {
  10547. + switch ( LA(4) )
  10548. + {
  10549. + case 't':
  10550. + {
  10551. + switch ( LA(5) )
  10552. + {
  10553. + case 'h':
  10554. + {
  10555. + switch ( LA(6) )
  10556. + {
  10557. + case 's':
  10558. + {
  10559. + switch ( LA(7) )
  10560. + {
  10561. + case '_':
  10562. + case 'a':
  10563. + case 'b':
  10564. + case 'c':
  10565. + case 'd':
  10566. + case 'e':
  10567. + case 'f':
  10568. + case 'g':
  10569. + case 'h':
  10570. + case 'i':
  10571. + case 'j':
  10572. + case 'k':
  10573. + case 'l':
  10574. + case 'm':
  10575. + case 'n':
  10576. + case 'o':
  10577. + case 'p':
  10578. + case 'q':
  10579. + case 'r':
  10580. + case 's':
  10581. + case 't':
  10582. + case 'u':
  10583. + case 'v':
  10584. + case 'w':
  10585. + case 'x':
  10586. + case 'y':
  10587. + case 'z':
  10588. + {
  10589. + alt12=24;
  10590. + }
  10591. + break;
  10592. +
  10593. + default:
  10594. + alt12=19;}
  10595. +
  10596. + }
  10597. + break;
  10598. + case '_':
  10599. + case 'a':
  10600. + case 'b':
  10601. + case 'c':
  10602. + case 'd':
  10603. + case 'e':
  10604. + case 'f':
  10605. + case 'g':
  10606. + case 'h':
  10607. + case 'i':
  10608. + case 'j':
  10609. + case 'k':
  10610. + case 'l':
  10611. + case 'm':
  10612. + case 'n':
  10613. + case 'o':
  10614. + case 'p':
  10615. + case 'q':
  10616. + case 'r':
  10617. + case 't':
  10618. + case 'u':
  10619. + case 'v':
  10620. + case 'w':
  10621. + case 'x':
  10622. + case 'y':
  10623. + case 'z':
  10624. + {
  10625. + alt12=24;
  10626. + }
  10627. + break;
  10628. +
  10629. + default:
  10630. + alt12=19;}
  10631. +
  10632. + }
  10633. + break;
  10634. +
  10635. + default:
  10636. + alt12=24;}
  10637. +
  10638. + }
  10639. + break;
  10640. +
  10641. + default:
  10642. + alt12=24;}
  10643. +
  10644. + }
  10645. + break;
  10646. +
  10647. + default:
  10648. + alt12=24;}
  10649. +
  10650. + }
  10651. + break;
  10652. + case '_':
  10653. + case 'a':
  10654. + case 'b':
  10655. + case 'c':
  10656. + case 'd':
  10657. + case 'e':
  10658. + case 'f':
  10659. + case 'g':
  10660. + case 'h':
  10661. + case 'i':
  10662. + case 'j':
  10663. + case 'k':
  10664. + case 'l':
  10665. + case 'm':
  10666. + case 'n':
  10667. + case 'p':
  10668. + case 'q':
  10669. + case 'r':
  10670. + case 's':
  10671. + case 't':
  10672. + case 'u':
  10673. + case 'v':
  10674. + case 'w':
  10675. + case 'x':
  10676. + case 'y':
  10677. + case 'z':
  10678. + {
  10679. + alt12=24;
  10680. + }
  10681. + break;
  10682. +
  10683. + default:
  10684. + CONSTRUCTEX();
  10685. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  10686. + EXCEPTION->message = (void *)"";
  10687. + EXCEPTION->decisionNum = 12;
  10688. + EXCEPTION->state = 16;
  10689. +
  10690. +
  10691. + goto ruleTokensEx;
  10692. + }
  10693. +
  10694. + }
  10695. + break;
  10696. + case 'y':
  10697. + {
  10698. + switch ( LA(2) )
  10699. + {
  10700. + case 'e':
  10701. + {
  10702. + switch ( LA(3) )
  10703. + {
  10704. + case 'a':
  10705. + {
  10706. + switch ( LA(4) )
  10707. + {
  10708. + case 'r':
  10709. + {
  10710. + switch ( LA(5) )
  10711. + {
  10712. + case 's':
  10713. + {
  10714. + switch ( LA(6) )
  10715. + {
  10716. + case '_':
  10717. + case 'a':
  10718. + case 'b':
  10719. + case 'c':
  10720. + case 'd':
  10721. + case 'e':
  10722. + case 'f':
  10723. + case 'g':
  10724. + case 'h':
  10725. + case 'i':
  10726. + case 'j':
  10727. + case 'k':
  10728. + case 'l':
  10729. + case 'm':
  10730. + case 'n':
  10731. + case 'o':
  10732. + case 'p':
  10733. + case 'q':
  10734. + case 'r':
  10735. + case 's':
  10736. + case 't':
  10737. + case 'u':
  10738. + case 'v':
  10739. + case 'w':
  10740. + case 'x':
  10741. + case 'y':
  10742. + case 'z':
  10743. + {
  10744. + alt12=24;
  10745. + }
  10746. + break;
  10747. +
  10748. + default:
  10749. + alt12=20;}
  10750. +
  10751. + }
  10752. + break;
  10753. + case '_':
  10754. + case 'a':
  10755. + case 'b':
  10756. + case 'c':
  10757. + case 'd':
  10758. + case 'e':
  10759. + case 'f':
  10760. + case 'g':
  10761. + case 'h':
  10762. + case 'i':
  10763. + case 'j':
  10764. + case 'k':
  10765. + case 'l':
  10766. + case 'm':
  10767. + case 'n':
  10768. + case 'o':
  10769. + case 'p':
  10770. + case 'q':
  10771. + case 'r':
  10772. + case 't':
  10773. + case 'u':
  10774. + case 'v':
  10775. + case 'w':
  10776. + case 'x':
  10777. + case 'y':
  10778. + case 'z':
  10779. + {
  10780. + alt12=24;
  10781. + }
  10782. + break;
  10783. +
  10784. + default:
  10785. + alt12=20;}
  10786. +
  10787. + }
  10788. + break;
  10789. +
  10790. + default:
  10791. + alt12=24;}
  10792. +
  10793. + }
  10794. + break;
  10795. +
  10796. + default:
  10797. + alt12=24;}
  10798. +
  10799. + }
  10800. + break;
  10801. + case '_':
  10802. + case 'a':
  10803. + case 'b':
  10804. + case 'c':
  10805. + case 'd':
  10806. + case 'f':
  10807. + case 'g':
  10808. + case 'h':
  10809. + case 'i':
  10810. + case 'j':
  10811. + case 'k':
  10812. + case 'l':
  10813. + case 'm':
  10814. + case 'n':
  10815. + case 'o':
  10816. + case 'p':
  10817. + case 'q':
  10818. + case 'r':
  10819. + case 's':
  10820. + case 't':
  10821. + case 'u':
  10822. + case 'v':
  10823. + case 'w':
  10824. + case 'x':
  10825. + case 'y':
  10826. + case 'z':
  10827. + {
  10828. + alt12=24;
  10829. + }
  10830. + break;
  10831. +
  10832. + default:
  10833. + CONSTRUCTEX();
  10834. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  10835. + EXCEPTION->message = (void *)"";
  10836. + EXCEPTION->decisionNum = 12;
  10837. + EXCEPTION->state = 17;
  10838. +
  10839. +
  10840. + goto ruleTokensEx;
  10841. + }
  10842. +
  10843. + }
  10844. + break;
  10845. + case 't':
  10846. + {
  10847. + switch ( LA(2) )
  10848. + {
  10849. + case 'o':
  10850. + {
  10851. + switch ( LA(3) )
  10852. + {
  10853. + case 'd':
  10854. + {
  10855. + switch ( LA(4) )
  10856. + {
  10857. + case 'a':
  10858. + {
  10859. + switch ( LA(5) )
  10860. + {
  10861. + case 'y':
  10862. + {
  10863. + switch ( LA(6) )
  10864. + {
  10865. + case '_':
  10866. + case 'a':
  10867. + case 'b':
  10868. + case 'c':
  10869. + case 'd':
  10870. + case 'e':
  10871. + case 'f':
  10872. + case 'g':
  10873. + case 'h':
  10874. + case 'i':
  10875. + case 'j':
  10876. + case 'k':
  10877. + case 'l':
  10878. + case 'm':
  10879. + case 'n':
  10880. + case 'o':
  10881. + case 'p':
  10882. + case 'q':
  10883. + case 'r':
  10884. + case 's':
  10885. + case 't':
  10886. + case 'u':
  10887. + case 'v':
  10888. + case 'w':
  10889. + case 'x':
  10890. + case 'y':
  10891. + case 'z':
  10892. + {
  10893. + alt12=24;
  10894. + }
  10895. + break;
  10896. +
  10897. + default:
  10898. + alt12=21;}
  10899. +
  10900. + }
  10901. + break;
  10902. +
  10903. + default:
  10904. + alt12=24;}
  10905. +
  10906. + }
  10907. + break;
  10908. +
  10909. + default:
  10910. + alt12=24;}
  10911. +
  10912. + }
  10913. + break;
  10914. +
  10915. + default:
  10916. + alt12=24;}
  10917. +
  10918. + }
  10919. + break;
  10920. + case '_':
  10921. + case 'a':
  10922. + case 'b':
  10923. + case 'c':
  10924. + case 'd':
  10925. + case 'e':
  10926. + case 'f':
  10927. + case 'g':
  10928. + case 'h':
  10929. + case 'i':
  10930. + case 'j':
  10931. + case 'k':
  10932. + case 'l':
  10933. + case 'm':
  10934. + case 'n':
  10935. + case 'p':
  10936. + case 'q':
  10937. + case 'r':
  10938. + case 's':
  10939. + case 't':
  10940. + case 'u':
  10941. + case 'v':
  10942. + case 'w':
  10943. + case 'x':
  10944. + case 'y':
  10945. + case 'z':
  10946. + {
  10947. + alt12=24;
  10948. + }
  10949. + break;
  10950. +
  10951. + default:
  10952. + CONSTRUCTEX();
  10953. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  10954. + EXCEPTION->message = (void *)"";
  10955. + EXCEPTION->decisionNum = 12;
  10956. + EXCEPTION->state = 18;
  10957. +
  10958. +
  10959. + goto ruleTokensEx;
  10960. + }
  10961. +
  10962. + }
  10963. + break;
  10964. + case '\n':
  10965. + case '\r':
  10966. + {
  10967. + alt12=22;
  10968. + }
  10969. + break;
  10970. + case '\t':
  10971. + case ' ':
  10972. + {
  10973. + alt12=23;
  10974. + }
  10975. + break;
  10976. + case 'c':
  10977. + case 'f':
  10978. + case 'g':
  10979. + case 'h':
  10980. + case 'j':
  10981. + case 'k':
  10982. + case 'l':
  10983. + case 'n':
  10984. + case 'p':
  10985. + case 'q':
  10986. + case 'r':
  10987. + case 'u':
  10988. + case 'v':
  10989. + case 'x':
  10990. + case 'z':
  10991. + {
  10992. + alt12=24;
  10993. + }
  10994. + break;
  10995. + case '1':
  10996. + case '2':
  10997. + case '3':
  10998. + case '4':
  10999. + case '5':
  11000. + case '6':
  11001. + case '7':
  11002. + case '8':
  11003. + case '9':
  11004. + {
  11005. + switch ( LA(2) )
  11006. + {
  11007. + case '0':
  11008. + case '1':
  11009. + case '2':
  11010. + case '3':
  11011. + case '4':
  11012. + case '5':
  11013. + case '6':
  11014. + case '7':
  11015. + case '8':
  11016. + case '9':
  11017. + {
  11018. + switch ( LA(3) )
  11019. + {
  11020. + case '0':
  11021. + case '1':
  11022. + case '2':
  11023. + case '3':
  11024. + case '4':
  11025. + case '5':
  11026. + case '6':
  11027. + case '7':
  11028. + case '8':
  11029. + case '9':
  11030. + {
  11031. + switch ( LA(4) )
  11032. + {
  11033. + case '0':
  11034. + case '1':
  11035. + case '2':
  11036. + case '3':
  11037. + case '4':
  11038. + case '5':
  11039. + case '6':
  11040. + case '7':
  11041. + case '8':
  11042. + case '9':
  11043. + {
  11044. + switch ( LA(5) )
  11045. + {
  11046. + case '-':
  11047. + {
  11048. + alt12=26;
  11049. + }
  11050. + break;
  11051. +
  11052. + default:
  11053. + alt12=25;}
  11054. +
  11055. + }
  11056. + break;
  11057. +
  11058. + default:
  11059. + alt12=25;}
  11060. +
  11061. + }
  11062. + break;
  11063. +
  11064. + default:
  11065. + alt12=25;}
  11066. +
  11067. + }
  11068. + break;
  11069. +
  11070. + default:
  11071. + alt12=25;}
  11072. +
  11073. + }
  11074. + break;
  11075. +
  11076. + default:
  11077. + CONSTRUCTEX();
  11078. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  11079. + EXCEPTION->message = (void *)"";
  11080. + EXCEPTION->decisionNum = 12;
  11081. + EXCEPTION->state = 0;
  11082. +
  11083. +
  11084. + goto ruleTokensEx;
  11085. + }
  11086. +
  11087. + switch (alt12)
  11088. + {
  11089. + case 1:
  11090. + // RSP.g:1:10: QUOTE
  11091. + {
  11092. + /* 1:10: QUOTE */
  11093. + mQUOTE(ctx );
  11094. + if (HASEXCEPTION())
  11095. + {
  11096. + goto ruleTokensEx;
  11097. + }
  11098. +
  11099. +
  11100. + }
  11101. + break;
  11102. + case 2:
  11103. + // RSP.g:1:16: LPAR
  11104. + {
  11105. + /* 1:16: LPAR */
  11106. + mLPAR(ctx );
  11107. + if (HASEXCEPTION())
  11108. + {
  11109. + goto ruleTokensEx;
  11110. + }
  11111. +
  11112. +
  11113. + }
  11114. + break;
  11115. + case 3:
  11116. + // RSP.g:1:21: RPAR
  11117. + {
  11118. + /* 1:21: RPAR */
  11119. + mRPAR(ctx );
  11120. + if (HASEXCEPTION())
  11121. + {
  11122. + goto ruleTokensEx;
  11123. + }
  11124. +
  11125. +
  11126. + }
  11127. + break;
  11128. + case 4:
  11129. + // RSP.g:1:26: AND
  11130. + {
  11131. + /* 1:26: AND */
  11132. + mAND(ctx );
  11133. + if (HASEXCEPTION())
  11134. + {
  11135. + goto ruleTokensEx;
  11136. + }
  11137. +
  11138. +
  11139. + }
  11140. + break;
  11141. + case 5:
  11142. + // RSP.g:1:30: OR
  11143. + {
  11144. + /* 1:30: OR */
  11145. + mOR(ctx );
  11146. + if (HASEXCEPTION())
  11147. + {
  11148. + goto ruleTokensEx;
  11149. + }
  11150. +
  11151. +
  11152. + }
  11153. + break;
  11154. + case 6:
  11155. + // RSP.g:1:33: NOT
  11156. + {
  11157. + /* 1:33: NOT */
  11158. + mNOT(ctx );
  11159. + if (HASEXCEPTION())
  11160. + {
  11161. + goto ruleTokensEx;
  11162. + }
  11163. +
  11164. +
  11165. + }
  11166. + break;
  11167. + case 7:
  11168. + // RSP.g:1:37: EQUAL
  11169. + {
  11170. + /* 1:37: EQUAL */
  11171. + mEQUAL(ctx );
  11172. + if (HASEXCEPTION())
  11173. + {
  11174. + goto ruleTokensEx;
  11175. + }
  11176. +
  11177. +
  11178. + }
  11179. + break;
  11180. + case 8:
  11181. + // RSP.g:1:43: INCLUDES
  11182. + {
  11183. + /* 1:43: INCLUDES */
  11184. + mINCLUDES(ctx );
  11185. + if (HASEXCEPTION())
  11186. + {
  11187. + goto ruleTokensEx;
  11188. + }
  11189. +
  11190. +
  11191. + }
  11192. + break;
  11193. + case 9:
  11194. + // RSP.g:1:52: STARTSW
  11195. + {
  11196. + /* 1:52: STARTSW */
  11197. + mSTARTSW(ctx );
  11198. + if (HASEXCEPTION())
  11199. + {
  11200. + goto ruleTokensEx;
  11201. + }
  11202. +
  11203. +
  11204. + }
  11205. + break;
  11206. + case 10:
  11207. + // RSP.g:1:60: ENDSW
  11208. + {
  11209. + /* 1:60: ENDSW */
  11210. + mENDSW(ctx );
  11211. + if (HASEXCEPTION())
  11212. + {
  11213. + goto ruleTokensEx;
  11214. + }
  11215. +
  11216. +
  11217. + }
  11218. + break;
  11219. + case 11:
  11220. + // RSP.g:1:66: GREATER
  11221. + {
  11222. + /* 1:66: GREATER */
  11223. + mGREATER(ctx );
  11224. + if (HASEXCEPTION())
  11225. + {
  11226. + goto ruleTokensEx;
  11227. + }
  11228. +
  11229. +
  11230. + }
  11231. + break;
  11232. + case 12:
  11233. + // RSP.g:1:74: LESS
  11234. + {
  11235. + /* 1:74: LESS */
  11236. + mLESS(ctx );
  11237. + if (HASEXCEPTION())
  11238. + {
  11239. + goto ruleTokensEx;
  11240. + }
  11241. +
  11242. +
  11243. + }
  11244. + break;
  11245. + case 13:
  11246. + // RSP.g:1:79: GTE
  11247. + {
  11248. + /* 1:79: GTE */
  11249. + mGTE(ctx );
  11250. + if (HASEXCEPTION())
  11251. + {
  11252. + goto ruleTokensEx;
  11253. + }
  11254. +
  11255. +
  11256. + }
  11257. + break;
  11258. + case 14:
  11259. + // RSP.g:1:83: LTE
  11260. + {
  11261. + /* 1:83: LTE */
  11262. + mLTE(ctx );
  11263. + if (HASEXCEPTION())
  11264. + {
  11265. + goto ruleTokensEx;
  11266. + }
  11267. +
  11268. +
  11269. + }
  11270. + break;
  11271. + case 15:
  11272. + // RSP.g:1:87: BEFORE
  11273. + {
  11274. + /* 1:87: BEFORE */
  11275. + mBEFORE(ctx );
  11276. + if (HASEXCEPTION())
  11277. + {
  11278. + goto ruleTokensEx;
  11279. + }
  11280. +
  11281. +
  11282. + }
  11283. + break;
  11284. + case 16:
  11285. + // RSP.g:1:94: AFTER
  11286. + {
  11287. + /* 1:94: AFTER */
  11288. + mAFTER(ctx );
  11289. + if (HASEXCEPTION())
  11290. + {
  11291. + goto ruleTokensEx;
  11292. + }
  11293. +
  11294. +
  11295. + }
  11296. + break;
  11297. + case 17:
  11298. + // RSP.g:1:100: DAY
  11299. + {
  11300. + /* 1:100: DAY */
  11301. + mDAY(ctx );
  11302. + if (HASEXCEPTION())
  11303. + {
  11304. + goto ruleTokensEx;
  11305. + }
  11306. +
  11307. +
  11308. + }
  11309. + break;
  11310. + case 18:
  11311. + // RSP.g:1:104: WEEK
  11312. + {
  11313. + /* 1:104: WEEK */
  11314. + mWEEK(ctx );
  11315. + if (HASEXCEPTION())
  11316. + {
  11317. + goto ruleTokensEx;
  11318. + }
  11319. +
  11320. +
  11321. + }
  11322. + break;
  11323. + case 19:
  11324. + // RSP.g:1:109: MONTH
  11325. + {
  11326. + /* 1:109: MONTH */
  11327. + mMONTH(ctx );
  11328. + if (HASEXCEPTION())
  11329. + {
  11330. + goto ruleTokensEx;
  11331. + }
  11332. +
  11333. +
  11334. + }
  11335. + break;
  11336. + case 20:
  11337. + // RSP.g:1:115: YEAR
  11338. + {
  11339. + /* 1:115: YEAR */
  11340. + mYEAR(ctx );
  11341. + if (HASEXCEPTION())
  11342. + {
  11343. + goto ruleTokensEx;
  11344. + }
  11345. +
  11346. +
  11347. + }
  11348. + break;
  11349. + case 21:
  11350. + // RSP.g:1:120: TODAY
  11351. + {
  11352. + /* 1:120: TODAY */
  11353. + mTODAY(ctx );
  11354. + if (HASEXCEPTION())
  11355. + {
  11356. + goto ruleTokensEx;
  11357. + }
  11358. +
  11359. +
  11360. + }
  11361. + break;
  11362. + case 22:
  11363. + // RSP.g:1:126: NEWLINE
  11364. + {
  11365. + /* 1:126: NEWLINE */
  11366. + mNEWLINE(ctx );
  11367. + if (HASEXCEPTION())
  11368. + {
  11369. + goto ruleTokensEx;
  11370. + }
  11371. +
  11372. +
  11373. + }
  11374. + break;
  11375. + case 23:
  11376. + // RSP.g:1:134: WS
  11377. + {
  11378. + /* 1:134: WS */
  11379. + mWS(ctx );
  11380. + if (HASEXCEPTION())
  11381. + {
  11382. + goto ruleTokensEx;
  11383. + }
  11384. +
  11385. +
  11386. + }
  11387. + break;
  11388. + case 24:
  11389. + // RSP.g:1:137: FIELD
  11390. + {
  11391. + /* 1:137: FIELD */
  11392. + mFIELD(ctx );
  11393. + if (HASEXCEPTION())
  11394. + {
  11395. + goto ruleTokensEx;
  11396. + }
  11397. +
  11398. +
  11399. + }
  11400. + break;
  11401. + case 25:
  11402. + // RSP.g:1:143: INT
  11403. + {
  11404. + /* 1:143: INT */
  11405. + mINT(ctx );
  11406. + if (HASEXCEPTION())
  11407. + {
  11408. + goto ruleTokensEx;
  11409. + }
  11410. +
  11411. +
  11412. + }
  11413. + break;
  11414. + case 26:
  11415. + // RSP.g:1:147: DATE
  11416. + {
  11417. + /* 1:147: DATE */
  11418. + mDATE(ctx );
  11419. + if (HASEXCEPTION())
  11420. + {
  11421. + goto ruleTokensEx;
  11422. + }
  11423. +
  11424. +
  11425. + }
  11426. + break;
  11427. + case 27:
  11428. + // RSP.g:1:152: STR
  11429. + {
  11430. + /* 1:152: STR */
  11431. + mSTR(ctx );
  11432. + if (HASEXCEPTION())
  11433. + {
  11434. + goto ruleTokensEx;
  11435. + }
  11436. +
  11437. +
  11438. + }
  11439. + break;
  11440. +
  11441. + }
  11442. + }
  11443. +
  11444. +
  11445. + goto ruleTokensEx; /* Prevent compiler warnings */
  11446. +ruleTokensEx: ;
  11447. +}
  11448. +
  11449. +/* =========================================================================
  11450. + * Lexer matching rules end.
  11451. + * =========================================================================
  11452. + */
  11453. +/* End of Lexer code
  11454. + * ================================================
  11455. + * ================================================
  11456. + */
  11457. +
  11458. +
  11459. +/* End of code
  11460. + * =============================================================================
  11461. + */
  11462. diff --git a/src/pregen/RSPLexer.h b/src/pregen/RSPLexer.h
  11463. new file mode 100644
  11464. index 0000000..4f4d06b
  11465. --- /dev/null
  11466. +++ b/src/pregen/RSPLexer.h
  11467. @@ -0,0 +1,254 @@
  11468. +/** \file
  11469. + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
  11470. + *
  11471. + * - From the grammar source file : RSP.g
  11472. + * - On : 2014-09-30 21:42:41
  11473. + * - for the lexer : RSPLexerLexer *
  11474. + * Editing it, at least manually, is not wise.
  11475. + *
  11476. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  11477. + *
  11478. + *
  11479. + * The lexer RSPLexer has the callable functions (rules) shown below,
  11480. + * which will invoke the code for the associated rule in the source grammar
  11481. + * assuming that the input stream is pointing to a token/text stream that could begin
  11482. + * this rule.
  11483. + *
  11484. + * For instance if you call the first (topmost) rule in a parser grammar, you will
  11485. + * get the results of a full parse, but calling a rule half way through the grammar will
  11486. + * allow you to pass part of a full token stream to the parser, such as for syntax checking
  11487. + * in editors and so on.
  11488. + *
  11489. + * The parser entry points are called indirectly (by function pointer to function) via
  11490. + * a parser context typedef pRSPLexer, which is returned from a call to RSPLexerNew().
  11491. + *
  11492. + * As this is a generated lexer, it is unlikely you will call it 'manually'. However
  11493. + * the methods are provided anyway.
  11494. + * * The methods in pRSPLexer are as follows:
  11495. + *
  11496. + * - void pRSPLexer->QUOTE(pRSPLexer)
  11497. + * - void pRSPLexer->LPAR(pRSPLexer)
  11498. + * - void pRSPLexer->RPAR(pRSPLexer)
  11499. + * - void pRSPLexer->AND(pRSPLexer)
  11500. + * - void pRSPLexer->OR(pRSPLexer)
  11501. + * - void pRSPLexer->NOT(pRSPLexer)
  11502. + * - void pRSPLexer->EQUAL(pRSPLexer)
  11503. + * - void pRSPLexer->INCLUDES(pRSPLexer)
  11504. + * - void pRSPLexer->STARTSW(pRSPLexer)
  11505. + * - void pRSPLexer->ENDSW(pRSPLexer)
  11506. + * - void pRSPLexer->GREATER(pRSPLexer)
  11507. + * - void pRSPLexer->LESS(pRSPLexer)
  11508. + * - void pRSPLexer->GTE(pRSPLexer)
  11509. + * - void pRSPLexer->LTE(pRSPLexer)
  11510. + * - void pRSPLexer->BEFORE(pRSPLexer)
  11511. + * - void pRSPLexer->AFTER(pRSPLexer)
  11512. + * - void pRSPLexer->DAY(pRSPLexer)
  11513. + * - void pRSPLexer->WEEK(pRSPLexer)
  11514. + * - void pRSPLexer->MONTH(pRSPLexer)
  11515. + * - void pRSPLexer->YEAR(pRSPLexer)
  11516. + * - void pRSPLexer->TODAY(pRSPLexer)
  11517. + * - void pRSPLexer->NEWLINE(pRSPLexer)
  11518. + * - void pRSPLexer->WS(pRSPLexer)
  11519. + * - void pRSPLexer->FIELD(pRSPLexer)
  11520. + * - void pRSPLexer->INT(pRSPLexer)
  11521. + * - void pRSPLexer->DATE(pRSPLexer)
  11522. + * - void pRSPLexer->STR(pRSPLexer)
  11523. + * - void pRSPLexer->ESCAPED(pRSPLexer)
  11524. + * - void pRSPLexer->DIGIT09(pRSPLexer)
  11525. + * - void pRSPLexer->DIGIT19(pRSPLexer)
  11526. + * - void pRSPLexer->Tokens(pRSPLexer)
  11527. + *
  11528. + * The return type for any particular rule is of course determined by the source
  11529. + * grammar file.
  11530. + */
  11531. +// [The "BSD licence"]
  11532. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  11533. +// http://www.temporal-wave.com
  11534. +// http://www.linkedin.com/in/jimidle
  11535. +//
  11536. +// All rights reserved.
  11537. +//
  11538. +// Redistribution and use in source and binary forms, with or without
  11539. +// modification, are permitted provided that the following conditions
  11540. +// are met:
  11541. +// 1. Redistributions of source code must retain the above copyright
  11542. +// notice, this list of conditions and the following disclaimer.
  11543. +// 2. Redistributions in binary form must reproduce the above copyright
  11544. +// notice, this list of conditions and the following disclaimer in the
  11545. +// documentation and/or other materials provided with the distribution.
  11546. +// 3. The name of the author may not be used to endorse or promote products
  11547. +// derived from this software without specific prior written permission.
  11548. +//
  11549. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  11550. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11551. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11552. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  11553. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  11554. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  11555. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11556. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11557. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  11558. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11559. +
  11560. +#ifndef _RSPLexer_H
  11561. +#define _RSPLexer_H
  11562. +/* =============================================================================
  11563. + * Standard antlr3 C runtime definitions
  11564. + */
  11565. +#include <antlr3.h>
  11566. +
  11567. +/* End of standard antlr 3 runtime definitions
  11568. + * =============================================================================
  11569. + */
  11570. +
  11571. +#ifdef __cplusplus
  11572. +extern "C" {
  11573. +#endif
  11574. +
  11575. +// Forward declare the context typedef so that we can use it before it is
  11576. +// properly defined. Delegators and delegates (from import statements) are
  11577. +// interdependent and their context structures contain pointers to each other
  11578. +// C only allows such things to be declared if you pre-declare the typedef.
  11579. +//
  11580. +typedef struct RSPLexer_Ctx_struct RSPLexer, * pRSPLexer;
  11581. +
  11582. +
  11583. +
  11584. +#ifdef ANTLR3_WINDOWS
  11585. +// Disable: Unreferenced parameter, - Rules with parameters that are not used
  11586. +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
  11587. +// initialized but unused variable - tree rewrite variables declared but not needed
  11588. +// Unreferenced local variable - lexer rule declares but does not always use _type
  11589. +// potentially unitialized variable used - retval always returned from a rule
  11590. +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
  11591. +//
  11592. +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
  11593. +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
  11594. +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
  11595. +// this is a matter of orthogonality hence I disable that one.
  11596. +//
  11597. +#pragma warning( disable : 4100 )
  11598. +#pragma warning( disable : 4101 )
  11599. +#pragma warning( disable : 4127 )
  11600. +#pragma warning( disable : 4189 )
  11601. +#pragma warning( disable : 4505 )
  11602. +#pragma warning( disable : 4701 )
  11603. +#endif
  11604. +
  11605. +/** Context tracking structure for RSPLexer
  11606. + */
  11607. +struct RSPLexer_Ctx_struct
  11608. +{
  11609. + /** Built in ANTLR3 context tracker contains all the generic elements
  11610. + * required for context tracking.
  11611. + */
  11612. + pANTLR3_LEXER pLexer;
  11613. +
  11614. +
  11615. + void (*mQUOTE) (struct RSPLexer_Ctx_struct * ctx);
  11616. + void (*mLPAR) (struct RSPLexer_Ctx_struct * ctx);
  11617. + void (*mRPAR) (struct RSPLexer_Ctx_struct * ctx);
  11618. + void (*mAND) (struct RSPLexer_Ctx_struct * ctx);
  11619. + void (*mOR) (struct RSPLexer_Ctx_struct * ctx);
  11620. + void (*mNOT) (struct RSPLexer_Ctx_struct * ctx);
  11621. + void (*mEQUAL) (struct RSPLexer_Ctx_struct * ctx);
  11622. + void (*mINCLUDES) (struct RSPLexer_Ctx_struct * ctx);
  11623. + void (*mSTARTSW) (struct RSPLexer_Ctx_struct * ctx);
  11624. + void (*mENDSW) (struct RSPLexer_Ctx_struct * ctx);
  11625. + void (*mGREATER) (struct RSPLexer_Ctx_struct * ctx);
  11626. + void (*mLESS) (struct RSPLexer_Ctx_struct * ctx);
  11627. + void (*mGTE) (struct RSPLexer_Ctx_struct * ctx);
  11628. + void (*mLTE) (struct RSPLexer_Ctx_struct * ctx);
  11629. + void (*mBEFORE) (struct RSPLexer_Ctx_struct * ctx);
  11630. + void (*mAFTER) (struct RSPLexer_Ctx_struct * ctx);
  11631. + void (*mDAY) (struct RSPLexer_Ctx_struct * ctx);
  11632. + void (*mWEEK) (struct RSPLexer_Ctx_struct * ctx);
  11633. + void (*mMONTH) (struct RSPLexer_Ctx_struct * ctx);
  11634. + void (*mYEAR) (struct RSPLexer_Ctx_struct * ctx);
  11635. + void (*mTODAY) (struct RSPLexer_Ctx_struct * ctx);
  11636. + void (*mNEWLINE) (struct RSPLexer_Ctx_struct * ctx);
  11637. + void (*mWS) (struct RSPLexer_Ctx_struct * ctx);
  11638. + void (*mFIELD) (struct RSPLexer_Ctx_struct * ctx);
  11639. + void (*mINT) (struct RSPLexer_Ctx_struct * ctx);
  11640. + void (*mDATE) (struct RSPLexer_Ctx_struct * ctx);
  11641. + void (*mSTR) (struct RSPLexer_Ctx_struct * ctx);
  11642. + void (*mESCAPED) (struct RSPLexer_Ctx_struct * ctx);
  11643. + void (*mDIGIT09) (struct RSPLexer_Ctx_struct * ctx);
  11644. + void (*mDIGIT19) (struct RSPLexer_Ctx_struct * ctx);
  11645. + void (*mTokens) (struct RSPLexer_Ctx_struct * ctx); const char * (*getGrammarFileName)();
  11646. + void (*free) (struct RSPLexer_Ctx_struct * ctx);
  11647. +
  11648. +};
  11649. +
  11650. +// Function protoypes for the constructor functions that external translation units
  11651. +// such as delegators and delegates may wish to call.
  11652. +//
  11653. +ANTLR3_API pRSPLexer RSPLexerNew (pANTLR3_INPUT_STREAM instream);
  11654. +ANTLR3_API pRSPLexer RSPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
  11655. +
  11656. +/** Symbolic definitions of all the tokens that the lexer will work with.
  11657. + * \{
  11658. + *
  11659. + * Antlr will define EOF, but we can't use that as it it is too common in
  11660. + * in C header files and that would be confusing. There is no way to filter this out at the moment
  11661. + * so we just undef it here for now. That isn't the value we get back from C recognizers
  11662. + * anyway. We are looking for ANTLR3_TOKEN_EOF.
  11663. + */
  11664. +#ifdef EOF
  11665. +#undef EOF
  11666. +#endif
  11667. +#ifdef Tokens
  11668. +#undef Tokens
  11669. +#endif
  11670. +#define STARTSW 14
  11671. +#define WEEK 26
  11672. +#define TODAY 24
  11673. +#define YEAR 28
  11674. +#define ENDSW 15
  11675. +#define GTE 20
  11676. +#define BEFORE 21
  11677. +#define DAY 25
  11678. +#define INT 16
  11679. +#define NOT 11
  11680. +#define AFTER 22
  11681. +#define AND 6
  11682. +#define EOF -1
  11683. +#define LTE 19
  11684. +#define MONTH 27
  11685. +#define DIGIT19 31
  11686. +#define INCLUDES 13
  11687. +#define STR 10
  11688. +#define QUOTE 29
  11689. +#define GREATER 18
  11690. +#define WS 30
  11691. +#define LPAR 7
  11692. +#define NEWLINE 4
  11693. +#define EQUAL 12
  11694. +#define OR 5
  11695. +#define LESS 17
  11696. +#define FIELD 9
  11697. +#define RPAR 8
  11698. +#define ESCAPED 33
  11699. +#define DATE 23
  11700. +#define DIGIT09 32
  11701. +#ifdef EOF
  11702. +#undef EOF
  11703. +#define EOF ANTLR3_TOKEN_EOF
  11704. +#endif
  11705. +
  11706. +#ifndef TOKENSOURCE
  11707. +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
  11708. +#endif
  11709. +
  11710. +/* End of token definitions for RSPLexer
  11711. + * =============================================================================
  11712. + */
  11713. +/** \} */
  11714. +
  11715. +#ifdef __cplusplus
  11716. +}
  11717. +#endif
  11718. +
  11719. +#endif
  11720. +
  11721. +/* END - Note:Keep extra line feed to satisfy UNIX systems */
  11722. diff --git a/src/pregen/RSPParser.c b/src/pregen/RSPParser.c
  11723. new file mode 100644
  11724. index 0000000..c538e49
  11725. --- /dev/null
  11726. +++ b/src/pregen/RSPParser.c
  11727. @@ -0,0 +1,2684 @@
  11728. +/** \file
  11729. + * This C source file was generated by $ANTLR version 3.2 debian-7ubuntu3
  11730. + *
  11731. + * - From the grammar source file : RSP.g
  11732. + * - On : 2014-09-30 21:42:40
  11733. + * - for the parser : RSPParserParser *
  11734. + * Editing it, at least manually, is not wise.
  11735. + *
  11736. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  11737. + *
  11738. + *
  11739. +*/
  11740. +// [The "BSD licence"]
  11741. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  11742. +// http://www.temporal-wave.com
  11743. +// http://www.linkedin.com/in/jimidle
  11744. +//
  11745. +// All rights reserved.
  11746. +//
  11747. +// Redistribution and use in source and binary forms, with or without
  11748. +// modification, are permitted provided that the following conditions
  11749. +// are met:
  11750. +// 1. Redistributions of source code must retain the above copyright
  11751. +// notice, this list of conditions and the following disclaimer.
  11752. +// 2. Redistributions in binary form must reproduce the above copyright
  11753. +// notice, this list of conditions and the following disclaimer in the
  11754. +// documentation and/or other materials provided with the distribution.
  11755. +// 3. The name of the author may not be used to endorse or promote products
  11756. +// derived from this software without specific prior written permission.
  11757. +//
  11758. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  11759. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11760. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11761. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  11762. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  11763. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  11764. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11765. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11766. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  11767. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11768. +
  11769. +/* -----------------------------------------
  11770. + * Include the ANTLR3 generated header file.
  11771. + */
  11772. +#include "RSPParser.h"
  11773. +/* ----------------------------------------- */
  11774. +
  11775. +
  11776. +
  11777. +
  11778. +
  11779. +/* MACROS that hide the C interface implementations from the
  11780. + * generated code, which makes it a little more understandable to the human eye.
  11781. + * I am very much against using C pre-processor macros for function calls and bits
  11782. + * of code as you cannot see what is happening when single stepping in debuggers
  11783. + * and so on. The exception (in my book at least) is for generated code, where you are
  11784. + * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
  11785. + * hides some indirect calls, but is always referring to the input stream. This is
  11786. + * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
  11787. + * the runtime interfaces without changing the generated code too often, without
  11788. + * confusing the reader of the generated output, who may not wish to know the gory
  11789. + * details of the interface inheritance.
  11790. + */
  11791. +
  11792. +#define CTX ctx
  11793. +
  11794. +/* Aids in accessing scopes for grammar programmers
  11795. + */
  11796. +#undef SCOPE_TYPE
  11797. +#undef SCOPE_STACK
  11798. +#undef SCOPE_TOP
  11799. +#define SCOPE_TYPE(scope) pRSPParser_##scope##_SCOPE
  11800. +#define SCOPE_STACK(scope) pRSPParser_##scope##Stack
  11801. +#define SCOPE_TOP(scope) ctx->pRSPParser_##scope##Top
  11802. +#define SCOPE_SIZE(scope) ctx->pRSPParser_##scope##Stack_limit
  11803. +#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
  11804. +
  11805. +/* Macros for accessing things in the parser
  11806. + */
  11807. +
  11808. +#undef PARSER
  11809. +#undef RECOGNIZER
  11810. +#undef HAVEPARSEDRULE
  11811. +#undef MEMOIZE
  11812. +#undef INPUT
  11813. +#undef STRSTREAM
  11814. +#undef HASEXCEPTION
  11815. +#undef EXCEPTION
  11816. +#undef MATCHT
  11817. +#undef MATCHANYT
  11818. +#undef FOLLOWSTACK
  11819. +#undef FOLLOWPUSH
  11820. +#undef FOLLOWPOP
  11821. +#undef PRECOVER
  11822. +#undef PREPORTERROR
  11823. +#undef LA
  11824. +#undef LT
  11825. +#undef CONSTRUCTEX
  11826. +#undef CONSUME
  11827. +#undef MARK
  11828. +#undef REWIND
  11829. +#undef REWINDLAST
  11830. +#undef PERRORRECOVERY
  11831. +#undef HASFAILED
  11832. +#undef FAILEDFLAG
  11833. +#undef RECOVERFROMMISMATCHEDSET
  11834. +#undef RECOVERFROMMISMATCHEDELEMENT
  11835. +#undef INDEX
  11836. +#undef ADAPTOR
  11837. +#undef SEEK
  11838. +#undef RULEMEMO
  11839. +#undef DBG
  11840. +
  11841. +#define PARSER ctx->pParser
  11842. +#define RECOGNIZER PARSER->rec
  11843. +#define PSRSTATE RECOGNIZER->state
  11844. +#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
  11845. +#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)
  11846. +#define INPUT PARSER->tstream
  11847. +#define STRSTREAM INPUT
  11848. +#define ISTREAM INPUT->istream
  11849. +#define INDEX() ISTREAM->index(INPUT->istream)
  11850. +#define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE)
  11851. +#define EXCEPTION PSRSTATE->exception
  11852. +#define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs)
  11853. +#define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER)
  11854. +#define FOLLOWSTACK PSRSTATE->following
  11855. +#define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
  11856. +#define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK)
  11857. +#define PRECOVER() RECOGNIZER->recover(RECOGNIZER)
  11858. +#define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER)
  11859. +#define LA(n) INPUT->istream->_LA(ISTREAM, n)
  11860. +#define LT(n) INPUT->_LT(INPUT, n)
  11861. +#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)
  11862. +#define CONSUME() ISTREAM->consume(ISTREAM)
  11863. +#define MARK() ISTREAM->mark(ISTREAM)
  11864. +#define REWIND(m) ISTREAM->rewind(ISTREAM, m)
  11865. +#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)
  11866. +#define SEEK(n) ISTREAM->seek(ISTREAM, n)
  11867. +#define PERRORRECOVERY PSRSTATE->errorRecovery
  11868. +#define FAILEDFLAG PSRSTATE->failed
  11869. +#define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE)
  11870. +#define BACKTRACKING PSRSTATE->backtracking
  11871. +#define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
  11872. +#define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
  11873. +#define ADAPTOR ctx->adaptor
  11874. +#define RULEMEMO PSRSTATE->ruleMemo
  11875. +#define DBG RECOGNIZER->debugger
  11876. +
  11877. +#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt
  11878. +
  11879. +/* The 4 tokens defined below may well clash with your own #defines or token types. If so
  11880. + * then for the present you must use different names for your defines as these are hard coded
  11881. + * in the code generator. It would be better not to use such names internally, and maybe
  11882. + * we can change this in a forthcoming release. I deliberately do not #undef these
  11883. + * here as this will at least give you a redefined error somewhere if they clash.
  11884. + */
  11885. +#define UP ANTLR3_TOKEN_UP
  11886. +#define DOWN ANTLR3_TOKEN_DOWN
  11887. +#define EOR ANTLR3_TOKEN_EOR
  11888. +#define INVALID ANTLR3_TOKEN_INVALID
  11889. +
  11890. +
  11891. +/* =============================================================================
  11892. + * Functions to create and destroy scopes. First come the rule scopes, followed
  11893. + * by the global declared scopes.
  11894. + */
  11895. +
  11896. +
  11897. +
  11898. +/* ============================================================================= */
  11899. +
  11900. +/* =============================================================================
  11901. + * Start of recognizer
  11902. + */
  11903. +
  11904. +
  11905. +
  11906. +/** \brief Table of all token names in symbolic order, mainly used for
  11907. + * error reporting.
  11908. + */
  11909. +pANTLR3_UINT8 RSPParserTokenNames[30+4]
  11910. + = {
  11911. + (pANTLR3_UINT8) "<invalid>", /* String to print to indicate an invalid token */
  11912. + (pANTLR3_UINT8) "<EOR>",
  11913. + (pANTLR3_UINT8) "<DOWN>",
  11914. + (pANTLR3_UINT8) "<UP>",
  11915. + (pANTLR3_UINT8) "NEWLINE",
  11916. + (pANTLR3_UINT8) "OR",
  11917. + (pANTLR3_UINT8) "AND",
  11918. + (pANTLR3_UINT8) "LPAR",
  11919. + (pANTLR3_UINT8) "RPAR",
  11920. + (pANTLR3_UINT8) "FIELD",
  11921. + (pANTLR3_UINT8) "STR",
  11922. + (pANTLR3_UINT8) "NOT",
  11923. + (pANTLR3_UINT8) "EQUAL",
  11924. + (pANTLR3_UINT8) "INCLUDES",
  11925. + (pANTLR3_UINT8) "STARTSW",
  11926. + (pANTLR3_UINT8) "ENDSW",
  11927. + (pANTLR3_UINT8) "INT",
  11928. + (pANTLR3_UINT8) "LESS",
  11929. + (pANTLR3_UINT8) "GREATER",
  11930. + (pANTLR3_UINT8) "LTE",
  11931. + (pANTLR3_UINT8) "GTE",
  11932. + (pANTLR3_UINT8) "BEFORE",
  11933. + (pANTLR3_UINT8) "AFTER",
  11934. + (pANTLR3_UINT8) "DATE",
  11935. + (pANTLR3_UINT8) "TODAY",
  11936. + (pANTLR3_UINT8) "DAY",
  11937. + (pANTLR3_UINT8) "WEEK",
  11938. + (pANTLR3_UINT8) "MONTH",
  11939. + (pANTLR3_UINT8) "YEAR",
  11940. + (pANTLR3_UINT8) "QUOTE",
  11941. + (pANTLR3_UINT8) "WS",
  11942. + (pANTLR3_UINT8) "DIGIT19",
  11943. + (pANTLR3_UINT8) "DIGIT09",
  11944. + (pANTLR3_UINT8) "ESCAPED"
  11945. + };
  11946. +
  11947. +
  11948. +
  11949. +// Forward declare the locally static matching functions we have generated.
  11950. +//
  11951. +static RSPParser_query_return query (pRSPParser ctx);
  11952. +static RSPParser_expr_return expr (pRSPParser ctx);
  11953. +static RSPParser_aexpr_return aexpr (pRSPParser ctx);
  11954. +static RSPParser_crit_return crit (pRSPParser ctx);
  11955. +static RSPParser_strcrit_return strcrit (pRSPParser ctx);
  11956. +static RSPParser_strop_return strop (pRSPParser ctx);
  11957. +static RSPParser_intcrit_return intcrit (pRSPParser ctx);
  11958. +static RSPParser_intop_return intop (pRSPParser ctx);
  11959. +static RSPParser_datecrit_return datecrit (pRSPParser ctx);
  11960. +static RSPParser_dateop_return dateop (pRSPParser ctx);
  11961. +static RSPParser_datespec_return datespec (pRSPParser ctx);
  11962. +static RSPParser_dateref_return dateref (pRSPParser ctx);
  11963. +static RSPParser_dateintval_return dateintval (pRSPParser ctx);
  11964. +static void RSPParserFree(pRSPParser ctx);
  11965. +/* For use in tree output where we are accumulating rule labels via label += ruleRef
  11966. + * we need a function that knows how to free a return scope when the list is destroyed.
  11967. + * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
  11968. + */
  11969. +static void ANTLR3_CDECL freeScope(void * scope)
  11970. +{
  11971. + ANTLR3_FREE(scope);
  11972. +}
  11973. +
  11974. +/** \brief Name of the grammar file that generated this code
  11975. + */
  11976. +static const char fileName[] = "RSP.g";
  11977. +
  11978. +/** \brief Return the name of the grammar file that generated this code.
  11979. + */
  11980. +static const char * getGrammarFileName()
  11981. +{
  11982. + return fileName;
  11983. +}
  11984. +/** \brief Create a new RSPParser parser and return a context for it.
  11985. + *
  11986. + * \param[in] instream Pointer to an input stream interface.
  11987. + *
  11988. + * \return Pointer to new parser context upon success.
  11989. + */
  11990. +ANTLR3_API pRSPParser
  11991. +RSPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream)
  11992. +{
  11993. + // See if we can create a new parser with the standard constructor
  11994. + //
  11995. + return RSPParserNewSSD(instream, NULL);
  11996. +}
  11997. +
  11998. +/** \brief Create a new RSPParser parser and return a context for it.
  11999. + *
  12000. + * \param[in] instream Pointer to an input stream interface.
  12001. + *
  12002. + * \return Pointer to new parser context upon success.
  12003. + */
  12004. +ANTLR3_API pRSPParser
  12005. +RSPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
  12006. +{
  12007. + pRSPParser ctx; /* Context structure we will build and return */
  12008. +
  12009. + ctx = (pRSPParser) ANTLR3_CALLOC(1, sizeof(RSPParser));
  12010. +
  12011. + if (ctx == NULL)
  12012. + {
  12013. + // Failed to allocate memory for parser context
  12014. + //
  12015. + return NULL;
  12016. + }
  12017. +
  12018. + /* -------------------------------------------------------------------
  12019. + * Memory for basic structure is allocated, now to fill in
  12020. + * the base ANTLR3 structures. We initialize the function pointers
  12021. + * for the standard ANTLR3 parser function set, but upon return
  12022. + * from here, the programmer may set the pointers to provide custom
  12023. + * implementations of each function.
  12024. + *
  12025. + * We don't use the macros defined in RSPParser.h here, in order that you can get a sense
  12026. + * of what goes where.
  12027. + */
  12028. +
  12029. + /* Create a base parser/recognizer, using the supplied token stream
  12030. + */
  12031. + ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state);
  12032. + /* Install the implementation of our RSPParser interface
  12033. + */
  12034. + ctx->query = query;
  12035. + ctx->expr = expr;
  12036. + ctx->aexpr = aexpr;
  12037. + ctx->crit = crit;
  12038. + ctx->strcrit = strcrit;
  12039. + ctx->strop = strop;
  12040. + ctx->intcrit = intcrit;
  12041. + ctx->intop = intop;
  12042. + ctx->datecrit = datecrit;
  12043. + ctx->dateop = dateop;
  12044. + ctx->datespec = datespec;
  12045. + ctx->dateref = dateref;
  12046. + ctx->dateintval = dateintval;
  12047. + ctx->free = RSPParserFree;
  12048. + ctx->getGrammarFileName = getGrammarFileName;
  12049. +
  12050. + /* Install the scope pushing methods.
  12051. + */
  12052. + ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory);
  12053. + ctx->vectors = antlr3VectorFactoryNew(0);
  12054. +
  12055. +
  12056. +
  12057. + /* Install the token table
  12058. + */
  12059. + PSRSTATE->tokenNames = RSPParserTokenNames;
  12060. +
  12061. +
  12062. + /* Return the newly built parser to the caller
  12063. + */
  12064. + return ctx;
  12065. +}
  12066. +
  12067. +/** Free the parser resources
  12068. + */
  12069. + static void
  12070. + RSPParserFree(pRSPParser ctx)
  12071. + {
  12072. + /* Free any scope memory
  12073. + */
  12074. +
  12075. + ctx->vectors->close(ctx->vectors);
  12076. + /* We created the adaptor so we must free it
  12077. + */
  12078. + ADAPTOR->free(ADAPTOR);
  12079. + // Free this parser
  12080. + //
  12081. + ctx->pParser->free(ctx->pParser);
  12082. + ANTLR3_FREE(ctx);
  12083. +
  12084. + /* Everything is released, so we can return
  12085. + */
  12086. + return;
  12087. + }
  12088. +
  12089. +/** Return token names used by this parser
  12090. + *
  12091. + * The returned pointer is used as an index into the token names table (using the token
  12092. + * number as the index).
  12093. + *
  12094. + * \return Pointer to first char * in the table.
  12095. + */
  12096. +static pANTLR3_UINT8 *getTokenNames()
  12097. +{
  12098. + return RSPParserTokenNames;
  12099. +}
  12100. +
  12101. +
  12102. +/* Declare the bitsets
  12103. + */
  12104. +
  12105. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42 */
  12106. +static ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) };
  12107. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_query42 = { FOLLOW_expr_in_query42_bits, 1 };
  12108. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44 */
  12109. +static ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000) };
  12110. +static ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44 = { FOLLOW_NEWLINE_in_query44_bits, 1 };
  12111. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47 */
  12112. +static ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12113. +static ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47 = { FOLLOW_EOF_in_query47_bits, 1 };
  12114. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr63 */
  12115. +static ANTLR3_BITWORD FOLLOW_aexpr_in_expr63_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
  12116. +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr63 = { FOLLOW_aexpr_in_expr63_bits, 1 };
  12117. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expr66 */
  12118. +static ANTLR3_BITWORD FOLLOW_OR_in_expr66_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
  12119. +static ANTLR3_BITSET_LIST FOLLOW_OR_in_expr66 = { FOLLOW_OR_in_expr66_bits, 1 };
  12120. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr69 */
  12121. +static ANTLR3_BITWORD FOLLOW_aexpr_in_expr69_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) };
  12122. +static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr69 = { FOLLOW_aexpr_in_expr69_bits, 1 };
  12123. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr81 */
  12124. +static ANTLR3_BITWORD FOLLOW_crit_in_aexpr81_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
  12125. +static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr81 = { FOLLOW_crit_in_aexpr81_bits, 1 };
  12126. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_aexpr84 */
  12127. +static ANTLR3_BITWORD FOLLOW_AND_in_aexpr84_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
  12128. +static ANTLR3_BITSET_LIST FOLLOW_AND_in_aexpr84 = { FOLLOW_AND_in_aexpr84_bits, 1 };
  12129. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr87 */
  12130. +static ANTLR3_BITWORD FOLLOW_crit_in_aexpr87_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) };
  12131. +static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr87 = { FOLLOW_crit_in_aexpr87_bits, 1 };
  12132. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit99 */
  12133. +static ANTLR3_BITWORD FOLLOW_LPAR_in_crit99_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) };
  12134. +static ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit99 = { FOLLOW_LPAR_in_crit99_bits, 1 };
  12135. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit101 */
  12136. +static ANTLR3_BITWORD FOLLOW_expr_in_crit101_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000100) };
  12137. +static ANTLR3_BITSET_LIST FOLLOW_expr_in_crit101 = { FOLLOW_expr_in_crit101_bits, 1 };
  12138. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit103 */
  12139. +static ANTLR3_BITWORD FOLLOW_RPAR_in_crit103_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12140. +static ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit103 = { FOLLOW_RPAR_in_crit103_bits, 1 };
  12141. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_crit114 */
  12142. +static ANTLR3_BITWORD FOLLOW_strcrit_in_crit114_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12143. +static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_crit114 = { FOLLOW_strcrit_in_crit114_bits, 1 };
  12144. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_crit119 */
  12145. +static ANTLR3_BITWORD FOLLOW_intcrit_in_crit119_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12146. +static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_crit119 = { FOLLOW_intcrit_in_crit119_bits, 1 };
  12147. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_datecrit_in_crit124 */
  12148. +static ANTLR3_BITWORD FOLLOW_datecrit_in_crit124_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12149. +static ANTLR3_BITSET_LIST FOLLOW_datecrit_in_crit124 = { FOLLOW_datecrit_in_crit124_bits, 1 };
  12150. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit134 */
  12151. +static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit134_bits[] = { ANTLR3_UINT64_LIT(0x000000000000F000) };
  12152. +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit134 = { FOLLOW_FIELD_in_strcrit134_bits, 1 };
  12153. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit136 */
  12154. +static ANTLR3_BITWORD FOLLOW_strop_in_strcrit136_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) };
  12155. +static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit136 = { FOLLOW_strop_in_strcrit136_bits, 1 };
  12156. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit138 */
  12157. +static ANTLR3_BITWORD FOLLOW_STR_in_strcrit138_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12158. +static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit138 = { FOLLOW_STR_in_strcrit138_bits, 1 };
  12159. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit155 */
  12160. +static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit155_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000800) };
  12161. +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit155 = { FOLLOW_FIELD_in_strcrit155_bits, 1 };
  12162. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_strcrit157 */
  12163. +static ANTLR3_BITWORD FOLLOW_NOT_in_strcrit157_bits[] = { ANTLR3_UINT64_LIT(0x000000000000F000) };
  12164. +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_strcrit157 = { FOLLOW_NOT_in_strcrit157_bits, 1 };
  12165. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit159 */
  12166. +static ANTLR3_BITWORD FOLLOW_strop_in_strcrit159_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) };
  12167. +static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit159 = { FOLLOW_strop_in_strcrit159_bits, 1 };
  12168. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit161 */
  12169. +static ANTLR3_BITWORD FOLLOW_STR_in_strcrit161_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12170. +static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit161 = { FOLLOW_STR_in_strcrit161_bits, 1 };
  12171. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_strop0 */
  12172. +static ANTLR3_BITWORD FOLLOW_set_in_strop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12173. +static ANTLR3_BITSET_LIST FOLLOW_set_in_strop0 = { FOLLOW_set_in_strop0_bits, 1 };
  12174. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit211 */
  12175. +static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit211_bits[] = { ANTLR3_UINT64_LIT(0x00000000001E1000) };
  12176. +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit211 = { FOLLOW_FIELD_in_intcrit211_bits, 1 };
  12177. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit213 */
  12178. +static ANTLR3_BITWORD FOLLOW_intop_in_intcrit213_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) };
  12179. +static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit213 = { FOLLOW_intop_in_intcrit213_bits, 1 };
  12180. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit215 */
  12181. +static ANTLR3_BITWORD FOLLOW_INT_in_intcrit215_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12182. +static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit215 = { FOLLOW_INT_in_intcrit215_bits, 1 };
  12183. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit232 */
  12184. +static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit232_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000800) };
  12185. +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit232 = { FOLLOW_FIELD_in_intcrit232_bits, 1 };
  12186. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_intcrit234 */
  12187. +static ANTLR3_BITWORD FOLLOW_NOT_in_intcrit234_bits[] = { ANTLR3_UINT64_LIT(0x00000000001E1000) };
  12188. +static ANTLR3_BITSET_LIST FOLLOW_NOT_in_intcrit234 = { FOLLOW_NOT_in_intcrit234_bits, 1 };
  12189. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit236 */
  12190. +static ANTLR3_BITWORD FOLLOW_intop_in_intcrit236_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) };
  12191. +static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit236 = { FOLLOW_intop_in_intcrit236_bits, 1 };
  12192. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit238 */
  12193. +static ANTLR3_BITWORD FOLLOW_INT_in_intcrit238_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12194. +static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit238 = { FOLLOW_INT_in_intcrit238_bits, 1 };
  12195. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_intop0 */
  12196. +static ANTLR3_BITWORD FOLLOW_set_in_intop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12197. +static ANTLR3_BITSET_LIST FOLLOW_set_in_intop0 = { FOLLOW_set_in_intop0_bits, 1 };
  12198. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_datecrit292 */
  12199. +static ANTLR3_BITWORD FOLLOW_FIELD_in_datecrit292_bits[] = { ANTLR3_UINT64_LIT(0x0000000000600000) };
  12200. +static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_datecrit292 = { FOLLOW_FIELD_in_datecrit292_bits, 1 };
  12201. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datecrit294 */
  12202. +static ANTLR3_BITWORD FOLLOW_dateop_in_datecrit294_bits[] = { ANTLR3_UINT64_LIT(0x0000000001810000) };
  12203. +static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datecrit294 = { FOLLOW_dateop_in_datecrit294_bits, 1 };
  12204. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_datespec_in_datecrit296 */
  12205. +static ANTLR3_BITWORD FOLLOW_datespec_in_datecrit296_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12206. +static ANTLR3_BITSET_LIST FOLLOW_datespec_in_datecrit296 = { FOLLOW_datespec_in_datecrit296_bits, 1 };
  12207. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateop0 */
  12208. +static ANTLR3_BITWORD FOLLOW_set_in_dateop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12209. +static ANTLR3_BITSET_LIST FOLLOW_set_in_dateop0 = { FOLLOW_set_in_dateop0_bits, 1 };
  12210. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec331 */
  12211. +static ANTLR3_BITWORD FOLLOW_dateref_in_datespec331_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12212. +static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec331 = { FOLLOW_dateref_in_datespec331_bits, 1 };
  12213. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_datespec336 */
  12214. +static ANTLR3_BITWORD FOLLOW_INT_in_datespec336_bits[] = { ANTLR3_UINT64_LIT(0x000000001E000000) };
  12215. +static ANTLR3_BITSET_LIST FOLLOW_INT_in_datespec336 = { FOLLOW_INT_in_datespec336_bits, 1 };
  12216. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateintval_in_datespec338 */
  12217. +static ANTLR3_BITWORD FOLLOW_dateintval_in_datespec338_bits[] = { ANTLR3_UINT64_LIT(0x0000000000600000) };
  12218. +static ANTLR3_BITSET_LIST FOLLOW_dateintval_in_datespec338 = { FOLLOW_dateintval_in_datespec338_bits, 1 };
  12219. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datespec340 */
  12220. +static ANTLR3_BITWORD FOLLOW_dateop_in_datespec340_bits[] = { ANTLR3_UINT64_LIT(0x0000000001800000) };
  12221. +static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datespec340 = { FOLLOW_dateop_in_datespec340_bits, 1 };
  12222. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec342 */
  12223. +static ANTLR3_BITWORD FOLLOW_dateref_in_datespec342_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12224. +static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec342 = { FOLLOW_dateref_in_datespec342_bits, 1 };
  12225. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateref0 */
  12226. +static ANTLR3_BITWORD FOLLOW_set_in_dateref0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12227. +static ANTLR3_BITSET_LIST FOLLOW_set_in_dateref0 = { FOLLOW_set_in_dateref0_bits, 1 };
  12228. +/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateintval0 */
  12229. +static ANTLR3_BITWORD FOLLOW_set_in_dateintval0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) };
  12230. +static ANTLR3_BITSET_LIST FOLLOW_set_in_dateintval0 = { FOLLOW_set_in_dateintval0_bits, 1 };
  12231. +
  12232. +
  12233. +
  12234. +
  12235. +/* ==============================================
  12236. + * Parsing rules
  12237. + */
  12238. +/**
  12239. + * $ANTLR start query
  12240. + * RSP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ;
  12241. + */
  12242. +static RSPParser_query_return
  12243. +query(pRSPParser ctx)
  12244. +{
  12245. + RSPParser_query_return retval;
  12246. +
  12247. + pANTLR3_BASE_TREE root_0;
  12248. +
  12249. + pANTLR3_COMMON_TOKEN NEWLINE2;
  12250. + pANTLR3_COMMON_TOKEN EOF3;
  12251. + RSPParser_expr_return expr1;
  12252. + #undef RETURN_TYPE_expr1
  12253. + #define RETURN_TYPE_expr1 RSPParser_expr_return
  12254. +
  12255. + pANTLR3_BASE_TREE NEWLINE2_tree;
  12256. + pANTLR3_BASE_TREE EOF3_tree;
  12257. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE;
  12258. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF;
  12259. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
  12260. + /* Initialize rule variables
  12261. + */
  12262. +
  12263. +
  12264. + root_0 = NULL;
  12265. +
  12266. + NEWLINE2 = NULL;
  12267. + EOF3 = NULL;
  12268. + expr1.tree = NULL;
  12269. +
  12270. + retval.start = LT(1); retval.stop = retval.start;
  12271. +
  12272. + NEWLINE2_tree = NULL;
  12273. + EOF3_tree = NULL;
  12274. +
  12275. + stream_NEWLINE = NULL;
  12276. + #define CREATE_stream_NEWLINE if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); }
  12277. + stream_EOF = NULL;
  12278. + #define CREATE_stream_EOF if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); }
  12279. + stream_expr = NULL;
  12280. + #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
  12281. +
  12282. + retval.tree = NULL;
  12283. + {
  12284. + // RSP.g:27:7: ( expr ( NEWLINE )? EOF -> expr )
  12285. + // RSP.g:27:9: expr ( NEWLINE )? EOF
  12286. + {
  12287. + FOLLOWPUSH(FOLLOW_expr_in_query42);
  12288. + expr1=expr(ctx);
  12289. +
  12290. + FOLLOWPOP();
  12291. + if (HASEXCEPTION())
  12292. + {
  12293. + goto rulequeryEx;
  12294. + }
  12295. +
  12296. + CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL);
  12297. +
  12298. + // RSP.g:27:14: ( NEWLINE )?
  12299. + {
  12300. + int alt1=2;
  12301. + switch ( LA(1) )
  12302. + {
  12303. + case NEWLINE:
  12304. + {
  12305. + alt1=1;
  12306. + }
  12307. + break;
  12308. + }
  12309. +
  12310. + switch (alt1)
  12311. + {
  12312. + case 1:
  12313. + // RSP.g:27:14: NEWLINE
  12314. + {
  12315. + NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44);
  12316. + if (HASEXCEPTION())
  12317. + {
  12318. + goto rulequeryEx;
  12319. + }
  12320. +
  12321. + CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL);
  12322. +
  12323. +
  12324. + }
  12325. + break;
  12326. +
  12327. + }
  12328. + }
  12329. + EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47);
  12330. + if (HASEXCEPTION())
  12331. + {
  12332. + goto rulequeryEx;
  12333. + }
  12334. +
  12335. + CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL);
  12336. +
  12337. +
  12338. +
  12339. + /* AST REWRITE
  12340. + * elements : expr
  12341. + * token labels :
  12342. + * rule labels : retval
  12343. + * token list labels :
  12344. + * rule list labels :
  12345. + */
  12346. + {
  12347. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  12348. +
  12349. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  12350. +
  12351. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  12352. + retval.tree = root_0;
  12353. + // 27:28: -> expr
  12354. + {
  12355. + ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
  12356. +
  12357. + }
  12358. +
  12359. + retval.tree = root_0; // set result root
  12360. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  12361. +
  12362. +
  12363. + }
  12364. + }
  12365. +
  12366. + }
  12367. +
  12368. +
  12369. + // This is where rules clean up and exit
  12370. + //
  12371. + goto rulequeryEx; /* Prevent compiler warnings */
  12372. + rulequeryEx: ;
  12373. + retval.stop = LT(-1);
  12374. +
  12375. + retval.stop = LT(-1);
  12376. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  12377. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  12378. + if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE);
  12379. + if (stream_EOF != NULL) stream_EOF->free(stream_EOF);
  12380. + if (stream_expr != NULL) stream_expr->free(stream_expr);
  12381. +
  12382. + if (HASEXCEPTION())
  12383. + {
  12384. + PREPORTERROR();
  12385. + PRECOVER();
  12386. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  12387. + }
  12388. +
  12389. +
  12390. + return retval;
  12391. +}
  12392. +/* $ANTLR end query */
  12393. +
  12394. +/**
  12395. + * $ANTLR start expr
  12396. + * RSP.g:30:1: expr : aexpr ( OR aexpr )* ;
  12397. + */
  12398. +static RSPParser_expr_return
  12399. +expr(pRSPParser ctx)
  12400. +{
  12401. + RSPParser_expr_return retval;
  12402. +
  12403. + pANTLR3_BASE_TREE root_0;
  12404. +
  12405. + pANTLR3_COMMON_TOKEN OR5;
  12406. + RSPParser_aexpr_return aexpr4;
  12407. + #undef RETURN_TYPE_aexpr4
  12408. + #define RETURN_TYPE_aexpr4 RSPParser_aexpr_return
  12409. +
  12410. + RSPParser_aexpr_return aexpr6;
  12411. + #undef RETURN_TYPE_aexpr6
  12412. + #define RETURN_TYPE_aexpr6 RSPParser_aexpr_return
  12413. +
  12414. + pANTLR3_BASE_TREE OR5_tree;
  12415. +
  12416. + /* Initialize rule variables
  12417. + */
  12418. +
  12419. +
  12420. + root_0 = NULL;
  12421. +
  12422. + OR5 = NULL;
  12423. + aexpr4.tree = NULL;
  12424. +
  12425. + aexpr6.tree = NULL;
  12426. +
  12427. + retval.start = LT(1); retval.stop = retval.start;
  12428. +
  12429. + OR5_tree = NULL;
  12430. +
  12431. +
  12432. + retval.tree = NULL;
  12433. + {
  12434. + // RSP.g:30:6: ( aexpr ( OR aexpr )* )
  12435. + // RSP.g:30:8: aexpr ( OR aexpr )*
  12436. + {
  12437. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  12438. +
  12439. + FOLLOWPUSH(FOLLOW_aexpr_in_expr63);
  12440. + aexpr4=aexpr(ctx);
  12441. +
  12442. + FOLLOWPOP();
  12443. + if (HASEXCEPTION())
  12444. + {
  12445. + goto ruleexprEx;
  12446. + }
  12447. +
  12448. + ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree);
  12449. +
  12450. + // RSP.g:30:14: ( OR aexpr )*
  12451. +
  12452. + for (;;)
  12453. + {
  12454. + int alt2=2;
  12455. + switch ( LA(1) )
  12456. + {
  12457. + case OR:
  12458. + {
  12459. + alt2=1;
  12460. + }
  12461. + break;
  12462. +
  12463. + }
  12464. +
  12465. + switch (alt2)
  12466. + {
  12467. + case 1:
  12468. + // RSP.g:30:15: OR aexpr
  12469. + {
  12470. + OR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OR, &FOLLOW_OR_in_expr66);
  12471. + if (HASEXCEPTION())
  12472. + {
  12473. + goto ruleexprEx;
  12474. + }
  12475. +
  12476. + OR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OR5));
  12477. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OR5_tree, root_0));
  12478. +
  12479. + FOLLOWPUSH(FOLLOW_aexpr_in_expr69);
  12480. + aexpr6=aexpr(ctx);
  12481. +
  12482. + FOLLOWPOP();
  12483. + if (HASEXCEPTION())
  12484. + {
  12485. + goto ruleexprEx;
  12486. + }
  12487. +
  12488. + ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree);
  12489. +
  12490. + }
  12491. + break;
  12492. +
  12493. + default:
  12494. + goto loop2; /* break out of the loop */
  12495. + break;
  12496. + }
  12497. + }
  12498. + loop2: ; /* Jump out to here if this rule does not match */
  12499. +
  12500. +
  12501. + }
  12502. +
  12503. + }
  12504. +
  12505. +
  12506. + // This is where rules clean up and exit
  12507. + //
  12508. + goto ruleexprEx; /* Prevent compiler warnings */
  12509. + ruleexprEx: ;
  12510. + retval.stop = LT(-1);
  12511. +
  12512. + retval.stop = LT(-1);
  12513. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  12514. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  12515. +
  12516. + if (HASEXCEPTION())
  12517. + {
  12518. + PREPORTERROR();
  12519. + PRECOVER();
  12520. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  12521. + }
  12522. +
  12523. +
  12524. + return retval;
  12525. +}
  12526. +/* $ANTLR end expr */
  12527. +
  12528. +/**
  12529. + * $ANTLR start aexpr
  12530. + * RSP.g:33:1: aexpr : crit ( AND crit )* ;
  12531. + */
  12532. +static RSPParser_aexpr_return
  12533. +aexpr(pRSPParser ctx)
  12534. +{
  12535. + RSPParser_aexpr_return retval;
  12536. +
  12537. + pANTLR3_BASE_TREE root_0;
  12538. +
  12539. + pANTLR3_COMMON_TOKEN AND8;
  12540. + RSPParser_crit_return crit7;
  12541. + #undef RETURN_TYPE_crit7
  12542. + #define RETURN_TYPE_crit7 RSPParser_crit_return
  12543. +
  12544. + RSPParser_crit_return crit9;
  12545. + #undef RETURN_TYPE_crit9
  12546. + #define RETURN_TYPE_crit9 RSPParser_crit_return
  12547. +
  12548. + pANTLR3_BASE_TREE AND8_tree;
  12549. +
  12550. + /* Initialize rule variables
  12551. + */
  12552. +
  12553. +
  12554. + root_0 = NULL;
  12555. +
  12556. + AND8 = NULL;
  12557. + crit7.tree = NULL;
  12558. +
  12559. + crit9.tree = NULL;
  12560. +
  12561. + retval.start = LT(1); retval.stop = retval.start;
  12562. +
  12563. + AND8_tree = NULL;
  12564. +
  12565. +
  12566. + retval.tree = NULL;
  12567. + {
  12568. + // RSP.g:33:7: ( crit ( AND crit )* )
  12569. + // RSP.g:33:9: crit ( AND crit )*
  12570. + {
  12571. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  12572. +
  12573. + FOLLOWPUSH(FOLLOW_crit_in_aexpr81);
  12574. + crit7=crit(ctx);
  12575. +
  12576. + FOLLOWPOP();
  12577. + if (HASEXCEPTION())
  12578. + {
  12579. + goto ruleaexprEx;
  12580. + }
  12581. +
  12582. + ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree);
  12583. +
  12584. + // RSP.g:33:14: ( AND crit )*
  12585. +
  12586. + for (;;)
  12587. + {
  12588. + int alt3=2;
  12589. + switch ( LA(1) )
  12590. + {
  12591. + case AND:
  12592. + {
  12593. + alt3=1;
  12594. + }
  12595. + break;
  12596. +
  12597. + }
  12598. +
  12599. + switch (alt3)
  12600. + {
  12601. + case 1:
  12602. + // RSP.g:33:15: AND crit
  12603. + {
  12604. + AND8 = (pANTLR3_COMMON_TOKEN) MATCHT(AND, &FOLLOW_AND_in_aexpr84);
  12605. + if (HASEXCEPTION())
  12606. + {
  12607. + goto ruleaexprEx;
  12608. + }
  12609. +
  12610. + AND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, AND8));
  12611. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, AND8_tree, root_0));
  12612. +
  12613. + FOLLOWPUSH(FOLLOW_crit_in_aexpr87);
  12614. + crit9=crit(ctx);
  12615. +
  12616. + FOLLOWPOP();
  12617. + if (HASEXCEPTION())
  12618. + {
  12619. + goto ruleaexprEx;
  12620. + }
  12621. +
  12622. + ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree);
  12623. +
  12624. + }
  12625. + break;
  12626. +
  12627. + default:
  12628. + goto loop3; /* break out of the loop */
  12629. + break;
  12630. + }
  12631. + }
  12632. + loop3: ; /* Jump out to here if this rule does not match */
  12633. +
  12634. +
  12635. + }
  12636. +
  12637. + }
  12638. +
  12639. +
  12640. + // This is where rules clean up and exit
  12641. + //
  12642. + goto ruleaexprEx; /* Prevent compiler warnings */
  12643. + ruleaexprEx: ;
  12644. + retval.stop = LT(-1);
  12645. +
  12646. + retval.stop = LT(-1);
  12647. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  12648. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  12649. +
  12650. + if (HASEXCEPTION())
  12651. + {
  12652. + PREPORTERROR();
  12653. + PRECOVER();
  12654. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  12655. + }
  12656. +
  12657. +
  12658. + return retval;
  12659. +}
  12660. +/* $ANTLR end aexpr */
  12661. +
  12662. +/**
  12663. + * $ANTLR start crit
  12664. + * RSP.g:36:1: crit : ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit );
  12665. + */
  12666. +static RSPParser_crit_return
  12667. +crit(pRSPParser ctx)
  12668. +{
  12669. + RSPParser_crit_return retval;
  12670. +
  12671. + pANTLR3_BASE_TREE root_0;
  12672. +
  12673. + pANTLR3_COMMON_TOKEN LPAR10;
  12674. + pANTLR3_COMMON_TOKEN RPAR12;
  12675. + RSPParser_expr_return expr11;
  12676. + #undef RETURN_TYPE_expr11
  12677. + #define RETURN_TYPE_expr11 RSPParser_expr_return
  12678. +
  12679. + RSPParser_strcrit_return strcrit13;
  12680. + #undef RETURN_TYPE_strcrit13
  12681. + #define RETURN_TYPE_strcrit13 RSPParser_strcrit_return
  12682. +
  12683. + RSPParser_intcrit_return intcrit14;
  12684. + #undef RETURN_TYPE_intcrit14
  12685. + #define RETURN_TYPE_intcrit14 RSPParser_intcrit_return
  12686. +
  12687. + RSPParser_datecrit_return datecrit15;
  12688. + #undef RETURN_TYPE_datecrit15
  12689. + #define RETURN_TYPE_datecrit15 RSPParser_datecrit_return
  12690. +
  12691. + pANTLR3_BASE_TREE LPAR10_tree;
  12692. + pANTLR3_BASE_TREE RPAR12_tree;
  12693. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR;
  12694. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR;
  12695. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
  12696. + /* Initialize rule variables
  12697. + */
  12698. +
  12699. +
  12700. + root_0 = NULL;
  12701. +
  12702. + LPAR10 = NULL;
  12703. + RPAR12 = NULL;
  12704. + expr11.tree = NULL;
  12705. +
  12706. + strcrit13.tree = NULL;
  12707. +
  12708. + intcrit14.tree = NULL;
  12709. +
  12710. + datecrit15.tree = NULL;
  12711. +
  12712. + retval.start = LT(1); retval.stop = retval.start;
  12713. +
  12714. + LPAR10_tree = NULL;
  12715. + RPAR12_tree = NULL;
  12716. +
  12717. + stream_RPAR = NULL;
  12718. + #define CREATE_stream_RPAR if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); }
  12719. + stream_LPAR = NULL;
  12720. + #define CREATE_stream_LPAR if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); }
  12721. + stream_expr = NULL;
  12722. + #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
  12723. +
  12724. + retval.tree = NULL;
  12725. + {
  12726. + {
  12727. + // RSP.g:36:6: ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit )
  12728. +
  12729. + ANTLR3_UINT32 alt4;
  12730. +
  12731. + alt4=4;
  12732. +
  12733. + switch ( LA(1) )
  12734. + {
  12735. + case LPAR:
  12736. + {
  12737. + alt4=1;
  12738. + }
  12739. + break;
  12740. + case FIELD:
  12741. + {
  12742. + switch ( LA(2) )
  12743. + {
  12744. + case NOT:
  12745. + {
  12746. + switch ( LA(3) )
  12747. + {
  12748. + case EQUAL:
  12749. + {
  12750. + switch ( LA(4) )
  12751. + {
  12752. + case STR:
  12753. + {
  12754. + alt4=2;
  12755. + }
  12756. + break;
  12757. + case INT:
  12758. + {
  12759. + alt4=3;
  12760. + }
  12761. + break;
  12762. +
  12763. + default:
  12764. + CONSTRUCTEX();
  12765. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  12766. + EXCEPTION->message = (void *)"";
  12767. + EXCEPTION->decisionNum = 4;
  12768. + EXCEPTION->state = 8;
  12769. +
  12770. +
  12771. + goto rulecritEx;
  12772. + }
  12773. +
  12774. + }
  12775. + break;
  12776. + case INCLUDES:
  12777. + case STARTSW:
  12778. + case ENDSW:
  12779. + {
  12780. + alt4=2;
  12781. + }
  12782. + break;
  12783. + case LESS:
  12784. + case GREATER:
  12785. + case LTE:
  12786. + case GTE:
  12787. + {
  12788. + alt4=3;
  12789. + }
  12790. + break;
  12791. +
  12792. + default:
  12793. + CONSTRUCTEX();
  12794. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  12795. + EXCEPTION->message = (void *)"";
  12796. + EXCEPTION->decisionNum = 4;
  12797. + EXCEPTION->state = 3;
  12798. +
  12799. +
  12800. + goto rulecritEx;
  12801. + }
  12802. +
  12803. + }
  12804. + break;
  12805. + case EQUAL:
  12806. + {
  12807. + switch ( LA(3) )
  12808. + {
  12809. + case INT:
  12810. + {
  12811. + alt4=3;
  12812. + }
  12813. + break;
  12814. + case STR:
  12815. + {
  12816. + alt4=2;
  12817. + }
  12818. + break;
  12819. +
  12820. + default:
  12821. + CONSTRUCTEX();
  12822. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  12823. + EXCEPTION->message = (void *)"";
  12824. + EXCEPTION->decisionNum = 4;
  12825. + EXCEPTION->state = 4;
  12826. +
  12827. +
  12828. + goto rulecritEx;
  12829. + }
  12830. +
  12831. + }
  12832. + break;
  12833. + case BEFORE:
  12834. + case AFTER:
  12835. + {
  12836. + alt4=4;
  12837. + }
  12838. + break;
  12839. + case LESS:
  12840. + case GREATER:
  12841. + case LTE:
  12842. + case GTE:
  12843. + {
  12844. + alt4=3;
  12845. + }
  12846. + break;
  12847. + case INCLUDES:
  12848. + case STARTSW:
  12849. + case ENDSW:
  12850. + {
  12851. + alt4=2;
  12852. + }
  12853. + break;
  12854. +
  12855. + default:
  12856. + CONSTRUCTEX();
  12857. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  12858. + EXCEPTION->message = (void *)"";
  12859. + EXCEPTION->decisionNum = 4;
  12860. + EXCEPTION->state = 2;
  12861. +
  12862. +
  12863. + goto rulecritEx;
  12864. + }
  12865. +
  12866. + }
  12867. + break;
  12868. +
  12869. + default:
  12870. + CONSTRUCTEX();
  12871. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  12872. + EXCEPTION->message = (void *)"";
  12873. + EXCEPTION->decisionNum = 4;
  12874. + EXCEPTION->state = 0;
  12875. +
  12876. +
  12877. + goto rulecritEx;
  12878. + }
  12879. +
  12880. + switch (alt4)
  12881. + {
  12882. + case 1:
  12883. + // RSP.g:36:8: LPAR expr RPAR
  12884. + {
  12885. + LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit99);
  12886. + if (HASEXCEPTION())
  12887. + {
  12888. + goto rulecritEx;
  12889. + }
  12890. +
  12891. + CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL);
  12892. +
  12893. + FOLLOWPUSH(FOLLOW_expr_in_crit101);
  12894. + expr11=expr(ctx);
  12895. +
  12896. + FOLLOWPOP();
  12897. + if (HASEXCEPTION())
  12898. + {
  12899. + goto rulecritEx;
  12900. + }
  12901. +
  12902. + CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL);
  12903. + RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit103);
  12904. + if (HASEXCEPTION())
  12905. + {
  12906. + goto rulecritEx;
  12907. + }
  12908. +
  12909. + CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL);
  12910. +
  12911. +
  12912. +
  12913. + /* AST REWRITE
  12914. + * elements : expr
  12915. + * token labels :
  12916. + * rule labels : retval
  12917. + * token list labels :
  12918. + * rule list labels :
  12919. + */
  12920. + {
  12921. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  12922. +
  12923. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  12924. +
  12925. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  12926. + retval.tree = root_0;
  12927. + // 36:25: -> expr
  12928. + {
  12929. + ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
  12930. +
  12931. + }
  12932. +
  12933. + retval.tree = root_0; // set result root
  12934. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  12935. +
  12936. +
  12937. + }
  12938. + }
  12939. + break;
  12940. + case 2:
  12941. + // RSP.g:37:4: strcrit
  12942. + {
  12943. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  12944. +
  12945. + FOLLOWPUSH(FOLLOW_strcrit_in_crit114);
  12946. + strcrit13=strcrit(ctx);
  12947. +
  12948. + FOLLOWPOP();
  12949. + if (HASEXCEPTION())
  12950. + {
  12951. + goto rulecritEx;
  12952. + }
  12953. +
  12954. + ADAPTOR->addChild(ADAPTOR, root_0, strcrit13.tree);
  12955. +
  12956. + }
  12957. + break;
  12958. + case 3:
  12959. + // RSP.g:38:4: intcrit
  12960. + {
  12961. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  12962. +
  12963. + FOLLOWPUSH(FOLLOW_intcrit_in_crit119);
  12964. + intcrit14=intcrit(ctx);
  12965. +
  12966. + FOLLOWPOP();
  12967. + if (HASEXCEPTION())
  12968. + {
  12969. + goto rulecritEx;
  12970. + }
  12971. +
  12972. + ADAPTOR->addChild(ADAPTOR, root_0, intcrit14.tree);
  12973. +
  12974. + }
  12975. + break;
  12976. + case 4:
  12977. + // RSP.g:39:4: datecrit
  12978. + {
  12979. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  12980. +
  12981. + FOLLOWPUSH(FOLLOW_datecrit_in_crit124);
  12982. + datecrit15=datecrit(ctx);
  12983. +
  12984. + FOLLOWPOP();
  12985. + if (HASEXCEPTION())
  12986. + {
  12987. + goto rulecritEx;
  12988. + }
  12989. +
  12990. + ADAPTOR->addChild(ADAPTOR, root_0, datecrit15.tree);
  12991. +
  12992. + }
  12993. + break;
  12994. +
  12995. + }
  12996. + }
  12997. + }
  12998. +
  12999. +
  13000. + // This is where rules clean up and exit
  13001. + //
  13002. + goto rulecritEx; /* Prevent compiler warnings */
  13003. + rulecritEx: ;
  13004. + retval.stop = LT(-1);
  13005. +
  13006. + retval.stop = LT(-1);
  13007. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  13008. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  13009. + if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR);
  13010. + if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR);
  13011. + if (stream_expr != NULL) stream_expr->free(stream_expr);
  13012. +
  13013. + if (HASEXCEPTION())
  13014. + {
  13015. + PREPORTERROR();
  13016. + PRECOVER();
  13017. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  13018. + }
  13019. +
  13020. +
  13021. + return retval;
  13022. +}
  13023. +/* $ANTLR end crit */
  13024. +
  13025. +/**
  13026. + * $ANTLR start strcrit
  13027. + * RSP.g:42:1: strcrit : ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) );
  13028. + */
  13029. +static RSPParser_strcrit_return
  13030. +strcrit(pRSPParser ctx)
  13031. +{
  13032. + RSPParser_strcrit_return retval;
  13033. +
  13034. + pANTLR3_BASE_TREE root_0;
  13035. +
  13036. + pANTLR3_COMMON_TOKEN FIELD16;
  13037. + pANTLR3_COMMON_TOKEN STR18;
  13038. + pANTLR3_COMMON_TOKEN FIELD19;
  13039. + pANTLR3_COMMON_TOKEN NOT20;
  13040. + pANTLR3_COMMON_TOKEN STR22;
  13041. + RSPParser_strop_return strop17;
  13042. + #undef RETURN_TYPE_strop17
  13043. + #define RETURN_TYPE_strop17 RSPParser_strop_return
  13044. +
  13045. + RSPParser_strop_return strop21;
  13046. + #undef RETURN_TYPE_strop21
  13047. + #define RETURN_TYPE_strop21 RSPParser_strop_return
  13048. +
  13049. + pANTLR3_BASE_TREE FIELD16_tree;
  13050. + pANTLR3_BASE_TREE STR18_tree;
  13051. + pANTLR3_BASE_TREE FIELD19_tree;
  13052. + pANTLR3_BASE_TREE NOT20_tree;
  13053. + pANTLR3_BASE_TREE STR22_tree;
  13054. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_STR;
  13055. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD;
  13056. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT;
  13057. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_strop;
  13058. + /* Initialize rule variables
  13059. + */
  13060. +
  13061. +
  13062. + root_0 = NULL;
  13063. +
  13064. + FIELD16 = NULL;
  13065. + STR18 = NULL;
  13066. + FIELD19 = NULL;
  13067. + NOT20 = NULL;
  13068. + STR22 = NULL;
  13069. + strop17.tree = NULL;
  13070. +
  13071. + strop21.tree = NULL;
  13072. +
  13073. + retval.start = LT(1); retval.stop = retval.start;
  13074. +
  13075. + FIELD16_tree = NULL;
  13076. + STR18_tree = NULL;
  13077. + FIELD19_tree = NULL;
  13078. + NOT20_tree = NULL;
  13079. + STR22_tree = NULL;
  13080. +
  13081. + stream_STR = NULL;
  13082. + #define CREATE_stream_STR if (stream_STR == NULL) {stream_STR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token STR"); }
  13083. + stream_FIELD = NULL;
  13084. + #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); }
  13085. + stream_NOT = NULL;
  13086. + #define CREATE_stream_NOT if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); }
  13087. + stream_strop = NULL;
  13088. + #define CREATE_stream_strop if (stream_strop == NULL) {stream_strop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule strop"); }
  13089. +
  13090. + retval.tree = NULL;
  13091. + {
  13092. + {
  13093. + // RSP.g:42:9: ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) )
  13094. +
  13095. + ANTLR3_UINT32 alt5;
  13096. +
  13097. + alt5=2;
  13098. +
  13099. + switch ( LA(1) )
  13100. + {
  13101. + case FIELD:
  13102. + {
  13103. + switch ( LA(2) )
  13104. + {
  13105. + case NOT:
  13106. + {
  13107. + alt5=2;
  13108. + }
  13109. + break;
  13110. + case EQUAL:
  13111. + case INCLUDES:
  13112. + case STARTSW:
  13113. + case ENDSW:
  13114. + {
  13115. + alt5=1;
  13116. + }
  13117. + break;
  13118. +
  13119. + default:
  13120. + CONSTRUCTEX();
  13121. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  13122. + EXCEPTION->message = (void *)"";
  13123. + EXCEPTION->decisionNum = 5;
  13124. + EXCEPTION->state = 1;
  13125. +
  13126. +
  13127. + goto rulestrcritEx;
  13128. + }
  13129. +
  13130. + }
  13131. + break;
  13132. +
  13133. + default:
  13134. + CONSTRUCTEX();
  13135. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  13136. + EXCEPTION->message = (void *)"";
  13137. + EXCEPTION->decisionNum = 5;
  13138. + EXCEPTION->state = 0;
  13139. +
  13140. +
  13141. + goto rulestrcritEx;
  13142. + }
  13143. +
  13144. + switch (alt5)
  13145. + {
  13146. + case 1:
  13147. + // RSP.g:42:11: FIELD strop STR
  13148. + {
  13149. + FIELD16 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit134);
  13150. + if (HASEXCEPTION())
  13151. + {
  13152. + goto rulestrcritEx;
  13153. + }
  13154. +
  13155. + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD16, NULL);
  13156. +
  13157. + FOLLOWPUSH(FOLLOW_strop_in_strcrit136);
  13158. + strop17=strop(ctx);
  13159. +
  13160. + FOLLOWPOP();
  13161. + if (HASEXCEPTION())
  13162. + {
  13163. + goto rulestrcritEx;
  13164. + }
  13165. +
  13166. + CREATE_stream_strop; stream_strop->add(stream_strop, strop17.tree, NULL);
  13167. + STR18 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit138);
  13168. + if (HASEXCEPTION())
  13169. + {
  13170. + goto rulestrcritEx;
  13171. + }
  13172. +
  13173. + CREATE_stream_STR; stream_STR->add(stream_STR, STR18, NULL);
  13174. +
  13175. +
  13176. +
  13177. + /* AST REWRITE
  13178. + * elements : strop, STR, FIELD
  13179. + * token labels :
  13180. + * rule labels : retval
  13181. + * token list labels :
  13182. + * rule list labels :
  13183. + */
  13184. + {
  13185. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  13186. +
  13187. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  13188. +
  13189. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13190. + retval.tree = root_0;
  13191. + // 42:29: -> ^( strop FIELD STR )
  13192. + {
  13193. + // RSP.g:42:32: ^( strop FIELD STR )
  13194. + {
  13195. + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13196. + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_1));
  13197. +
  13198. + ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
  13199. + ADAPTOR->addChild(ADAPTOR, root_1, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR));
  13200. +
  13201. + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
  13202. + }
  13203. +
  13204. + }
  13205. +
  13206. + retval.tree = root_0; // set result root
  13207. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  13208. +
  13209. +
  13210. + }
  13211. + }
  13212. + break;
  13213. + case 2:
  13214. + // RSP.g:43:4: FIELD NOT strop STR
  13215. + {
  13216. + FIELD19 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit155);
  13217. + if (HASEXCEPTION())
  13218. + {
  13219. + goto rulestrcritEx;
  13220. + }
  13221. +
  13222. + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD19, NULL);
  13223. +
  13224. + NOT20 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_strcrit157);
  13225. + if (HASEXCEPTION())
  13226. + {
  13227. + goto rulestrcritEx;
  13228. + }
  13229. +
  13230. + CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT20, NULL);
  13231. +
  13232. + FOLLOWPUSH(FOLLOW_strop_in_strcrit159);
  13233. + strop21=strop(ctx);
  13234. +
  13235. + FOLLOWPOP();
  13236. + if (HASEXCEPTION())
  13237. + {
  13238. + goto rulestrcritEx;
  13239. + }
  13240. +
  13241. + CREATE_stream_strop; stream_strop->add(stream_strop, strop21.tree, NULL);
  13242. + STR22 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit161);
  13243. + if (HASEXCEPTION())
  13244. + {
  13245. + goto rulestrcritEx;
  13246. + }
  13247. +
  13248. + CREATE_stream_STR; stream_STR->add(stream_STR, STR22, NULL);
  13249. +
  13250. +
  13251. +
  13252. + /* AST REWRITE
  13253. + * elements : NOT, FIELD, strop, STR
  13254. + * token labels :
  13255. + * rule labels : retval
  13256. + * token list labels :
  13257. + * rule list labels :
  13258. + */
  13259. + {
  13260. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  13261. +
  13262. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  13263. +
  13264. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13265. + retval.tree = root_0;
  13266. + // 43:25: -> ^( NOT ^( strop FIELD STR ) )
  13267. + {
  13268. + // RSP.g:43:28: ^( NOT ^( strop FIELD STR ) )
  13269. + {
  13270. + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13271. + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1));
  13272. +
  13273. + // RSP.g:43:34: ^( strop FIELD STR )
  13274. + {
  13275. + pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13276. + root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_2));
  13277. +
  13278. + ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
  13279. + ADAPTOR->addChild(ADAPTOR, root_2, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR));
  13280. +
  13281. + ADAPTOR->addChild(ADAPTOR, root_1, root_2);
  13282. + }
  13283. +
  13284. + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
  13285. + }
  13286. +
  13287. + }
  13288. +
  13289. + retval.tree = root_0; // set result root
  13290. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  13291. +
  13292. +
  13293. + }
  13294. + }
  13295. + break;
  13296. +
  13297. + }
  13298. + }
  13299. + }
  13300. +
  13301. +
  13302. + // This is where rules clean up and exit
  13303. + //
  13304. + goto rulestrcritEx; /* Prevent compiler warnings */
  13305. + rulestrcritEx: ;
  13306. + retval.stop = LT(-1);
  13307. +
  13308. + retval.stop = LT(-1);
  13309. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  13310. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  13311. + if (stream_STR != NULL) stream_STR->free(stream_STR);
  13312. + if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD);
  13313. + if (stream_NOT != NULL) stream_NOT->free(stream_NOT);
  13314. + if (stream_strop != NULL) stream_strop->free(stream_strop);
  13315. +
  13316. + if (HASEXCEPTION())
  13317. + {
  13318. + PREPORTERROR();
  13319. + PRECOVER();
  13320. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  13321. + }
  13322. +
  13323. +
  13324. + return retval;
  13325. +}
  13326. +/* $ANTLR end strcrit */
  13327. +
  13328. +/**
  13329. + * $ANTLR start strop
  13330. + * RSP.g:46:1: strop : ( EQUAL | INCLUDES | STARTSW | ENDSW );
  13331. + */
  13332. +static RSPParser_strop_return
  13333. +strop(pRSPParser ctx)
  13334. +{
  13335. + RSPParser_strop_return retval;
  13336. +
  13337. + pANTLR3_BASE_TREE root_0;
  13338. +
  13339. + pANTLR3_COMMON_TOKEN set23;
  13340. +
  13341. + pANTLR3_BASE_TREE set23_tree;
  13342. +
  13343. + /* Initialize rule variables
  13344. + */
  13345. +
  13346. +
  13347. + root_0 = NULL;
  13348. +
  13349. + set23 = NULL;
  13350. + retval.start = LT(1); retval.stop = retval.start;
  13351. +
  13352. + set23_tree = NULL;
  13353. +
  13354. +
  13355. + retval.tree = NULL;
  13356. + {
  13357. + // RSP.g:46:7: ( EQUAL | INCLUDES | STARTSW | ENDSW )
  13358. + // RSP.g:
  13359. + {
  13360. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13361. +
  13362. + set23=(pANTLR3_COMMON_TOKEN)LT(1);
  13363. + if ( ((LA(1) >= EQUAL) && (LA(1) <= ENDSW)) )
  13364. + {
  13365. + CONSUME();
  13366. + ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set23)));
  13367. + PERRORRECOVERY=ANTLR3_FALSE;
  13368. + }
  13369. + else
  13370. + {
  13371. + CONSTRUCTEX();
  13372. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  13373. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  13374. + EXCEPTION->expectingSet = &FOLLOW_set_in_strop0;
  13375. + RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_strop0); goto rulestropEx;
  13376. + }
  13377. +
  13378. +
  13379. + }
  13380. +
  13381. + }
  13382. +
  13383. +
  13384. + // This is where rules clean up and exit
  13385. + //
  13386. + goto rulestropEx; /* Prevent compiler warnings */
  13387. + rulestropEx: ;
  13388. + retval.stop = LT(-1);
  13389. +
  13390. + retval.stop = LT(-1);
  13391. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  13392. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  13393. +
  13394. + if (HASEXCEPTION())
  13395. + {
  13396. + PREPORTERROR();
  13397. + PRECOVER();
  13398. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  13399. + }
  13400. +
  13401. +
  13402. + return retval;
  13403. +}
  13404. +/* $ANTLR end strop */
  13405. +
  13406. +/**
  13407. + * $ANTLR start intcrit
  13408. + * RSP.g:52:1: intcrit : ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) );
  13409. + */
  13410. +static RSPParser_intcrit_return
  13411. +intcrit(pRSPParser ctx)
  13412. +{
  13413. + RSPParser_intcrit_return retval;
  13414. +
  13415. + pANTLR3_BASE_TREE root_0;
  13416. +
  13417. + pANTLR3_COMMON_TOKEN FIELD24;
  13418. + pANTLR3_COMMON_TOKEN INT26;
  13419. + pANTLR3_COMMON_TOKEN FIELD27;
  13420. + pANTLR3_COMMON_TOKEN NOT28;
  13421. + pANTLR3_COMMON_TOKEN INT30;
  13422. + RSPParser_intop_return intop25;
  13423. + #undef RETURN_TYPE_intop25
  13424. + #define RETURN_TYPE_intop25 RSPParser_intop_return
  13425. +
  13426. + RSPParser_intop_return intop29;
  13427. + #undef RETURN_TYPE_intop29
  13428. + #define RETURN_TYPE_intop29 RSPParser_intop_return
  13429. +
  13430. + pANTLR3_BASE_TREE FIELD24_tree;
  13431. + pANTLR3_BASE_TREE INT26_tree;
  13432. + pANTLR3_BASE_TREE FIELD27_tree;
  13433. + pANTLR3_BASE_TREE NOT28_tree;
  13434. + pANTLR3_BASE_TREE INT30_tree;
  13435. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD;
  13436. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT;
  13437. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT;
  13438. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_intop;
  13439. + /* Initialize rule variables
  13440. + */
  13441. +
  13442. +
  13443. + root_0 = NULL;
  13444. +
  13445. + FIELD24 = NULL;
  13446. + INT26 = NULL;
  13447. + FIELD27 = NULL;
  13448. + NOT28 = NULL;
  13449. + INT30 = NULL;
  13450. + intop25.tree = NULL;
  13451. +
  13452. + intop29.tree = NULL;
  13453. +
  13454. + retval.start = LT(1); retval.stop = retval.start;
  13455. +
  13456. + FIELD24_tree = NULL;
  13457. + INT26_tree = NULL;
  13458. + FIELD27_tree = NULL;
  13459. + NOT28_tree = NULL;
  13460. + INT30_tree = NULL;
  13461. +
  13462. + stream_FIELD = NULL;
  13463. + #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); }
  13464. + stream_INT = NULL;
  13465. + #define CREATE_stream_INT if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); }
  13466. + stream_NOT = NULL;
  13467. + #define CREATE_stream_NOT if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); }
  13468. + stream_intop = NULL;
  13469. + #define CREATE_stream_intop if (stream_intop == NULL) {stream_intop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule intop"); }
  13470. +
  13471. + retval.tree = NULL;
  13472. + {
  13473. + {
  13474. + // RSP.g:52:9: ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) )
  13475. +
  13476. + ANTLR3_UINT32 alt6;
  13477. +
  13478. + alt6=2;
  13479. +
  13480. + switch ( LA(1) )
  13481. + {
  13482. + case FIELD:
  13483. + {
  13484. + switch ( LA(2) )
  13485. + {
  13486. + case NOT:
  13487. + {
  13488. + alt6=2;
  13489. + }
  13490. + break;
  13491. + case EQUAL:
  13492. + case LESS:
  13493. + case GREATER:
  13494. + case LTE:
  13495. + case GTE:
  13496. + {
  13497. + alt6=1;
  13498. + }
  13499. + break;
  13500. +
  13501. + default:
  13502. + CONSTRUCTEX();
  13503. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  13504. + EXCEPTION->message = (void *)"";
  13505. + EXCEPTION->decisionNum = 6;
  13506. + EXCEPTION->state = 1;
  13507. +
  13508. +
  13509. + goto ruleintcritEx;
  13510. + }
  13511. +
  13512. + }
  13513. + break;
  13514. +
  13515. + default:
  13516. + CONSTRUCTEX();
  13517. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  13518. + EXCEPTION->message = (void *)"";
  13519. + EXCEPTION->decisionNum = 6;
  13520. + EXCEPTION->state = 0;
  13521. +
  13522. +
  13523. + goto ruleintcritEx;
  13524. + }
  13525. +
  13526. + switch (alt6)
  13527. + {
  13528. + case 1:
  13529. + // RSP.g:52:11: FIELD intop INT
  13530. + {
  13531. + FIELD24 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit211);
  13532. + if (HASEXCEPTION())
  13533. + {
  13534. + goto ruleintcritEx;
  13535. + }
  13536. +
  13537. + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD24, NULL);
  13538. +
  13539. + FOLLOWPUSH(FOLLOW_intop_in_intcrit213);
  13540. + intop25=intop(ctx);
  13541. +
  13542. + FOLLOWPOP();
  13543. + if (HASEXCEPTION())
  13544. + {
  13545. + goto ruleintcritEx;
  13546. + }
  13547. +
  13548. + CREATE_stream_intop; stream_intop->add(stream_intop, intop25.tree, NULL);
  13549. + INT26 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit215);
  13550. + if (HASEXCEPTION())
  13551. + {
  13552. + goto ruleintcritEx;
  13553. + }
  13554. +
  13555. + CREATE_stream_INT; stream_INT->add(stream_INT, INT26, NULL);
  13556. +
  13557. +
  13558. +
  13559. + /* AST REWRITE
  13560. + * elements : FIELD, intop, INT
  13561. + * token labels :
  13562. + * rule labels : retval
  13563. + * token list labels :
  13564. + * rule list labels :
  13565. + */
  13566. + {
  13567. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  13568. +
  13569. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  13570. +
  13571. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13572. + retval.tree = root_0;
  13573. + // 52:29: -> ^( intop FIELD INT )
  13574. + {
  13575. + // RSP.g:52:32: ^( intop FIELD INT )
  13576. + {
  13577. + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13578. + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_1));
  13579. +
  13580. + ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
  13581. + ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT));
  13582. +
  13583. + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
  13584. + }
  13585. +
  13586. + }
  13587. +
  13588. + retval.tree = root_0; // set result root
  13589. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  13590. +
  13591. +
  13592. + }
  13593. + }
  13594. + break;
  13595. + case 2:
  13596. + // RSP.g:53:4: FIELD NOT intop INT
  13597. + {
  13598. + FIELD27 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit232);
  13599. + if (HASEXCEPTION())
  13600. + {
  13601. + goto ruleintcritEx;
  13602. + }
  13603. +
  13604. + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD27, NULL);
  13605. +
  13606. + NOT28 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_intcrit234);
  13607. + if (HASEXCEPTION())
  13608. + {
  13609. + goto ruleintcritEx;
  13610. + }
  13611. +
  13612. + CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT28, NULL);
  13613. +
  13614. + FOLLOWPUSH(FOLLOW_intop_in_intcrit236);
  13615. + intop29=intop(ctx);
  13616. +
  13617. + FOLLOWPOP();
  13618. + if (HASEXCEPTION())
  13619. + {
  13620. + goto ruleintcritEx;
  13621. + }
  13622. +
  13623. + CREATE_stream_intop; stream_intop->add(stream_intop, intop29.tree, NULL);
  13624. + INT30 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit238);
  13625. + if (HASEXCEPTION())
  13626. + {
  13627. + goto ruleintcritEx;
  13628. + }
  13629. +
  13630. + CREATE_stream_INT; stream_INT->add(stream_INT, INT30, NULL);
  13631. +
  13632. +
  13633. +
  13634. + /* AST REWRITE
  13635. + * elements : NOT, INT, FIELD, intop
  13636. + * token labels :
  13637. + * rule labels : retval
  13638. + * token list labels :
  13639. + * rule list labels :
  13640. + */
  13641. + {
  13642. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  13643. +
  13644. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  13645. +
  13646. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13647. + retval.tree = root_0;
  13648. + // 53:25: -> ^( NOT ^( intop FIELD INT ) )
  13649. + {
  13650. + // RSP.g:53:28: ^( NOT ^( intop FIELD INT ) )
  13651. + {
  13652. + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13653. + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1));
  13654. +
  13655. + // RSP.g:53:34: ^( intop FIELD INT )
  13656. + {
  13657. + pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13658. + root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_2));
  13659. +
  13660. + ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
  13661. + ADAPTOR->addChild(ADAPTOR, root_2, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT));
  13662. +
  13663. + ADAPTOR->addChild(ADAPTOR, root_1, root_2);
  13664. + }
  13665. +
  13666. + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
  13667. + }
  13668. +
  13669. + }
  13670. +
  13671. + retval.tree = root_0; // set result root
  13672. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  13673. +
  13674. +
  13675. + }
  13676. + }
  13677. + break;
  13678. +
  13679. + }
  13680. + }
  13681. + }
  13682. +
  13683. +
  13684. + // This is where rules clean up and exit
  13685. + //
  13686. + goto ruleintcritEx; /* Prevent compiler warnings */
  13687. + ruleintcritEx: ;
  13688. + retval.stop = LT(-1);
  13689. +
  13690. + retval.stop = LT(-1);
  13691. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  13692. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  13693. + if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD);
  13694. + if (stream_INT != NULL) stream_INT->free(stream_INT);
  13695. + if (stream_NOT != NULL) stream_NOT->free(stream_NOT);
  13696. + if (stream_intop != NULL) stream_intop->free(stream_intop);
  13697. +
  13698. + if (HASEXCEPTION())
  13699. + {
  13700. + PREPORTERROR();
  13701. + PRECOVER();
  13702. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  13703. + }
  13704. +
  13705. +
  13706. + return retval;
  13707. +}
  13708. +/* $ANTLR end intcrit */
  13709. +
  13710. +/**
  13711. + * $ANTLR start intop
  13712. + * RSP.g:56:1: intop : ( EQUAL | LESS | GREATER | LTE | GTE );
  13713. + */
  13714. +static RSPParser_intop_return
  13715. +intop(pRSPParser ctx)
  13716. +{
  13717. + RSPParser_intop_return retval;
  13718. +
  13719. + pANTLR3_BASE_TREE root_0;
  13720. +
  13721. + pANTLR3_COMMON_TOKEN set31;
  13722. +
  13723. + pANTLR3_BASE_TREE set31_tree;
  13724. +
  13725. + /* Initialize rule variables
  13726. + */
  13727. +
  13728. +
  13729. + root_0 = NULL;
  13730. +
  13731. + set31 = NULL;
  13732. + retval.start = LT(1); retval.stop = retval.start;
  13733. +
  13734. + set31_tree = NULL;
  13735. +
  13736. +
  13737. + retval.tree = NULL;
  13738. + {
  13739. + // RSP.g:56:7: ( EQUAL | LESS | GREATER | LTE | GTE )
  13740. + // RSP.g:
  13741. + {
  13742. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13743. +
  13744. + set31=(pANTLR3_COMMON_TOKEN)LT(1);
  13745. + if ( LA(1) == EQUAL || ((LA(1) >= LESS) && (LA(1) <= GTE)) )
  13746. + {
  13747. + CONSUME();
  13748. + ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set31)));
  13749. + PERRORRECOVERY=ANTLR3_FALSE;
  13750. + }
  13751. + else
  13752. + {
  13753. + CONSTRUCTEX();
  13754. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  13755. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  13756. + EXCEPTION->expectingSet = &FOLLOW_set_in_intop0;
  13757. + RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_intop0); goto ruleintopEx;
  13758. + }
  13759. +
  13760. +
  13761. + }
  13762. +
  13763. + }
  13764. +
  13765. +
  13766. + // This is where rules clean up and exit
  13767. + //
  13768. + goto ruleintopEx; /* Prevent compiler warnings */
  13769. + ruleintopEx: ;
  13770. + retval.stop = LT(-1);
  13771. +
  13772. + retval.stop = LT(-1);
  13773. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  13774. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  13775. +
  13776. + if (HASEXCEPTION())
  13777. + {
  13778. + PREPORTERROR();
  13779. + PRECOVER();
  13780. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  13781. + }
  13782. +
  13783. +
  13784. + return retval;
  13785. +}
  13786. +/* $ANTLR end intop */
  13787. +
  13788. +/**
  13789. + * $ANTLR start datecrit
  13790. + * RSP.g:63:1: datecrit : FIELD dateop datespec -> ^( dateop FIELD datespec ) ;
  13791. + */
  13792. +static RSPParser_datecrit_return
  13793. +datecrit(pRSPParser ctx)
  13794. +{
  13795. + RSPParser_datecrit_return retval;
  13796. +
  13797. + pANTLR3_BASE_TREE root_0;
  13798. +
  13799. + pANTLR3_COMMON_TOKEN FIELD32;
  13800. + RSPParser_dateop_return dateop33;
  13801. + #undef RETURN_TYPE_dateop33
  13802. + #define RETURN_TYPE_dateop33 RSPParser_dateop_return
  13803. +
  13804. + RSPParser_datespec_return datespec34;
  13805. + #undef RETURN_TYPE_datespec34
  13806. + #define RETURN_TYPE_datespec34 RSPParser_datespec_return
  13807. +
  13808. + pANTLR3_BASE_TREE FIELD32_tree;
  13809. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD;
  13810. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_datespec;
  13811. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop;
  13812. + /* Initialize rule variables
  13813. + */
  13814. +
  13815. +
  13816. + root_0 = NULL;
  13817. +
  13818. + FIELD32 = NULL;
  13819. + dateop33.tree = NULL;
  13820. +
  13821. + datespec34.tree = NULL;
  13822. +
  13823. + retval.start = LT(1); retval.stop = retval.start;
  13824. +
  13825. + FIELD32_tree = NULL;
  13826. +
  13827. + stream_FIELD = NULL;
  13828. + #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); }
  13829. + stream_datespec = NULL;
  13830. + #define CREATE_stream_datespec if (stream_datespec == NULL) {stream_datespec = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule datespec"); }
  13831. + stream_dateop = NULL;
  13832. + #define CREATE_stream_dateop if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); }
  13833. +
  13834. + retval.tree = NULL;
  13835. + {
  13836. + // RSP.g:63:9: ( FIELD dateop datespec -> ^( dateop FIELD datespec ) )
  13837. + // RSP.g:63:11: FIELD dateop datespec
  13838. + {
  13839. + FIELD32 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_datecrit292);
  13840. + if (HASEXCEPTION())
  13841. + {
  13842. + goto ruledatecritEx;
  13843. + }
  13844. +
  13845. + CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD32, NULL);
  13846. +
  13847. + FOLLOWPUSH(FOLLOW_dateop_in_datecrit294);
  13848. + dateop33=dateop(ctx);
  13849. +
  13850. + FOLLOWPOP();
  13851. + if (HASEXCEPTION())
  13852. + {
  13853. + goto ruledatecritEx;
  13854. + }
  13855. +
  13856. + CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop33.tree, NULL);
  13857. + FOLLOWPUSH(FOLLOW_datespec_in_datecrit296);
  13858. + datespec34=datespec(ctx);
  13859. +
  13860. + FOLLOWPOP();
  13861. + if (HASEXCEPTION())
  13862. + {
  13863. + goto ruledatecritEx;
  13864. + }
  13865. +
  13866. + CREATE_stream_datespec; stream_datespec->add(stream_datespec, datespec34.tree, NULL);
  13867. +
  13868. +
  13869. + /* AST REWRITE
  13870. + * elements : FIELD, datespec, dateop
  13871. + * token labels :
  13872. + * rule labels : retval
  13873. + * token list labels :
  13874. + * rule list labels :
  13875. + */
  13876. + {
  13877. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  13878. +
  13879. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  13880. +
  13881. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13882. + retval.tree = root_0;
  13883. + // 63:34: -> ^( dateop FIELD datespec )
  13884. + {
  13885. + // RSP.g:63:37: ^( dateop FIELD datespec )
  13886. + {
  13887. + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13888. + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1));
  13889. +
  13890. + ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
  13891. + ADAPTOR->addChild(ADAPTOR, root_1, stream_datespec == NULL ? NULL : stream_datespec->nextTree(stream_datespec));
  13892. +
  13893. + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
  13894. + }
  13895. +
  13896. + }
  13897. +
  13898. + retval.tree = root_0; // set result root
  13899. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  13900. +
  13901. +
  13902. + }
  13903. + }
  13904. +
  13905. + }
  13906. +
  13907. +
  13908. + // This is where rules clean up and exit
  13909. + //
  13910. + goto ruledatecritEx; /* Prevent compiler warnings */
  13911. + ruledatecritEx: ;
  13912. + retval.stop = LT(-1);
  13913. +
  13914. + retval.stop = LT(-1);
  13915. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  13916. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  13917. + if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD);
  13918. + if (stream_datespec != NULL) stream_datespec->free(stream_datespec);
  13919. + if (stream_dateop != NULL) stream_dateop->free(stream_dateop);
  13920. +
  13921. + if (HASEXCEPTION())
  13922. + {
  13923. + PREPORTERROR();
  13924. + PRECOVER();
  13925. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  13926. + }
  13927. +
  13928. +
  13929. + return retval;
  13930. +}
  13931. +/* $ANTLR end datecrit */
  13932. +
  13933. +/**
  13934. + * $ANTLR start dateop
  13935. + * RSP.g:66:1: dateop : ( BEFORE | AFTER );
  13936. + */
  13937. +static RSPParser_dateop_return
  13938. +dateop(pRSPParser ctx)
  13939. +{
  13940. + RSPParser_dateop_return retval;
  13941. +
  13942. + pANTLR3_BASE_TREE root_0;
  13943. +
  13944. + pANTLR3_COMMON_TOKEN set35;
  13945. +
  13946. + pANTLR3_BASE_TREE set35_tree;
  13947. +
  13948. + /* Initialize rule variables
  13949. + */
  13950. +
  13951. +
  13952. + root_0 = NULL;
  13953. +
  13954. + set35 = NULL;
  13955. + retval.start = LT(1); retval.stop = retval.start;
  13956. +
  13957. + set35_tree = NULL;
  13958. +
  13959. +
  13960. + retval.tree = NULL;
  13961. + {
  13962. + // RSP.g:66:8: ( BEFORE | AFTER )
  13963. + // RSP.g:
  13964. + {
  13965. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  13966. +
  13967. + set35=(pANTLR3_COMMON_TOKEN)LT(1);
  13968. + if ( ((LA(1) >= BEFORE) && (LA(1) <= AFTER)) )
  13969. + {
  13970. + CONSUME();
  13971. + ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set35)));
  13972. + PERRORRECOVERY=ANTLR3_FALSE;
  13973. + }
  13974. + else
  13975. + {
  13976. + CONSTRUCTEX();
  13977. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  13978. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  13979. + EXCEPTION->expectingSet = &FOLLOW_set_in_dateop0;
  13980. + RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateop0); goto ruledateopEx;
  13981. + }
  13982. +
  13983. +
  13984. + }
  13985. +
  13986. + }
  13987. +
  13988. +
  13989. + // This is where rules clean up and exit
  13990. + //
  13991. + goto ruledateopEx; /* Prevent compiler warnings */
  13992. + ruledateopEx: ;
  13993. + retval.stop = LT(-1);
  13994. +
  13995. + retval.stop = LT(-1);
  13996. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  13997. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  13998. +
  13999. + if (HASEXCEPTION())
  14000. + {
  14001. + PREPORTERROR();
  14002. + PRECOVER();
  14003. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  14004. + }
  14005. +
  14006. +
  14007. + return retval;
  14008. +}
  14009. +/* $ANTLR end dateop */
  14010. +
  14011. +/**
  14012. + * $ANTLR start datespec
  14013. + * RSP.g:70:1: datespec : ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) );
  14014. + */
  14015. +static RSPParser_datespec_return
  14016. +datespec(pRSPParser ctx)
  14017. +{
  14018. + RSPParser_datespec_return retval;
  14019. +
  14020. + pANTLR3_BASE_TREE root_0;
  14021. +
  14022. + pANTLR3_COMMON_TOKEN INT37;
  14023. + RSPParser_dateref_return dateref36;
  14024. + #undef RETURN_TYPE_dateref36
  14025. + #define RETURN_TYPE_dateref36 RSPParser_dateref_return
  14026. +
  14027. + RSPParser_dateintval_return dateintval38;
  14028. + #undef RETURN_TYPE_dateintval38
  14029. + #define RETURN_TYPE_dateintval38 RSPParser_dateintval_return
  14030. +
  14031. + RSPParser_dateop_return dateop39;
  14032. + #undef RETURN_TYPE_dateop39
  14033. + #define RETURN_TYPE_dateop39 RSPParser_dateop_return
  14034. +
  14035. + RSPParser_dateref_return dateref40;
  14036. + #undef RETURN_TYPE_dateref40
  14037. + #define RETURN_TYPE_dateref40 RSPParser_dateref_return
  14038. +
  14039. + pANTLR3_BASE_TREE INT37_tree;
  14040. + pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT;
  14041. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateintval;
  14042. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateref;
  14043. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop;
  14044. + /* Initialize rule variables
  14045. + */
  14046. +
  14047. +
  14048. + root_0 = NULL;
  14049. +
  14050. + INT37 = NULL;
  14051. + dateref36.tree = NULL;
  14052. +
  14053. + dateintval38.tree = NULL;
  14054. +
  14055. + dateop39.tree = NULL;
  14056. +
  14057. + dateref40.tree = NULL;
  14058. +
  14059. + retval.start = LT(1); retval.stop = retval.start;
  14060. +
  14061. + INT37_tree = NULL;
  14062. +
  14063. + stream_INT = NULL;
  14064. + #define CREATE_stream_INT if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); }
  14065. + stream_dateintval = NULL;
  14066. + #define CREATE_stream_dateintval if (stream_dateintval == NULL) {stream_dateintval = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateintval"); }
  14067. + stream_dateref = NULL;
  14068. + #define CREATE_stream_dateref if (stream_dateref == NULL) {stream_dateref = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateref"); }
  14069. + stream_dateop = NULL;
  14070. + #define CREATE_stream_dateop if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); }
  14071. +
  14072. + retval.tree = NULL;
  14073. + {
  14074. + {
  14075. + // RSP.g:70:9: ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) )
  14076. +
  14077. + ANTLR3_UINT32 alt7;
  14078. +
  14079. + alt7=2;
  14080. +
  14081. + switch ( LA(1) )
  14082. + {
  14083. + case DATE:
  14084. + case TODAY:
  14085. + {
  14086. + alt7=1;
  14087. + }
  14088. + break;
  14089. + case INT:
  14090. + {
  14091. + alt7=2;
  14092. + }
  14093. + break;
  14094. +
  14095. + default:
  14096. + CONSTRUCTEX();
  14097. + EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
  14098. + EXCEPTION->message = (void *)"";
  14099. + EXCEPTION->decisionNum = 7;
  14100. + EXCEPTION->state = 0;
  14101. +
  14102. +
  14103. + goto ruledatespecEx;
  14104. + }
  14105. +
  14106. + switch (alt7)
  14107. + {
  14108. + case 1:
  14109. + // RSP.g:70:11: dateref
  14110. + {
  14111. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  14112. +
  14113. + FOLLOWPUSH(FOLLOW_dateref_in_datespec331);
  14114. + dateref36=dateref(ctx);
  14115. +
  14116. + FOLLOWPOP();
  14117. + if (HASEXCEPTION())
  14118. + {
  14119. + goto ruledatespecEx;
  14120. + }
  14121. +
  14122. + ADAPTOR->addChild(ADAPTOR, root_0, dateref36.tree);
  14123. +
  14124. + }
  14125. + break;
  14126. + case 2:
  14127. + // RSP.g:71:4: INT dateintval dateop dateref
  14128. + {
  14129. + INT37 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_datespec336);
  14130. + if (HASEXCEPTION())
  14131. + {
  14132. + goto ruledatespecEx;
  14133. + }
  14134. +
  14135. + CREATE_stream_INT; stream_INT->add(stream_INT, INT37, NULL);
  14136. +
  14137. + FOLLOWPUSH(FOLLOW_dateintval_in_datespec338);
  14138. + dateintval38=dateintval(ctx);
  14139. +
  14140. + FOLLOWPOP();
  14141. + if (HASEXCEPTION())
  14142. + {
  14143. + goto ruledatespecEx;
  14144. + }
  14145. +
  14146. + CREATE_stream_dateintval; stream_dateintval->add(stream_dateintval, dateintval38.tree, NULL);
  14147. + FOLLOWPUSH(FOLLOW_dateop_in_datespec340);
  14148. + dateop39=dateop(ctx);
  14149. +
  14150. + FOLLOWPOP();
  14151. + if (HASEXCEPTION())
  14152. + {
  14153. + goto ruledatespecEx;
  14154. + }
  14155. +
  14156. + CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop39.tree, NULL);
  14157. + FOLLOWPUSH(FOLLOW_dateref_in_datespec342);
  14158. + dateref40=dateref(ctx);
  14159. +
  14160. + FOLLOWPOP();
  14161. + if (HASEXCEPTION())
  14162. + {
  14163. + goto ruledatespecEx;
  14164. + }
  14165. +
  14166. + CREATE_stream_dateref; stream_dateref->add(stream_dateref, dateref40.tree, NULL);
  14167. +
  14168. +
  14169. + /* AST REWRITE
  14170. + * elements : dateintval, INT, dateref, dateop
  14171. + * token labels :
  14172. + * rule labels : retval
  14173. + * token list labels :
  14174. + * rule list labels :
  14175. + */
  14176. + {
  14177. + pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
  14178. +
  14179. + stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
  14180. +
  14181. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  14182. + retval.tree = root_0;
  14183. + // 71:34: -> ^( dateop dateref INT dateintval )
  14184. + {
  14185. + // RSP.g:71:37: ^( dateop dateref INT dateintval )
  14186. + {
  14187. + pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  14188. + root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1));
  14189. +
  14190. + ADAPTOR->addChild(ADAPTOR, root_1, stream_dateref == NULL ? NULL : stream_dateref->nextTree(stream_dateref));
  14191. + ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT));
  14192. + ADAPTOR->addChild(ADAPTOR, root_1, stream_dateintval == NULL ? NULL : stream_dateintval->nextTree(stream_dateintval));
  14193. +
  14194. + ADAPTOR->addChild(ADAPTOR, root_0, root_1);
  14195. + }
  14196. +
  14197. + }
  14198. +
  14199. + retval.tree = root_0; // set result root
  14200. + if (stream_retval != NULL) stream_retval->free(stream_retval);
  14201. +
  14202. +
  14203. + }
  14204. + }
  14205. + break;
  14206. +
  14207. + }
  14208. + }
  14209. + }
  14210. +
  14211. +
  14212. + // This is where rules clean up and exit
  14213. + //
  14214. + goto ruledatespecEx; /* Prevent compiler warnings */
  14215. + ruledatespecEx: ;
  14216. + retval.stop = LT(-1);
  14217. +
  14218. + retval.stop = LT(-1);
  14219. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  14220. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  14221. + if (stream_INT != NULL) stream_INT->free(stream_INT);
  14222. + if (stream_dateintval != NULL) stream_dateintval->free(stream_dateintval);
  14223. + if (stream_dateref != NULL) stream_dateref->free(stream_dateref);
  14224. + if (stream_dateop != NULL) stream_dateop->free(stream_dateop);
  14225. +
  14226. + if (HASEXCEPTION())
  14227. + {
  14228. + PREPORTERROR();
  14229. + PRECOVER();
  14230. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  14231. + }
  14232. +
  14233. +
  14234. + return retval;
  14235. +}
  14236. +/* $ANTLR end datespec */
  14237. +
  14238. +/**
  14239. + * $ANTLR start dateref
  14240. + * RSP.g:74:1: dateref : ( DATE | TODAY );
  14241. + */
  14242. +static RSPParser_dateref_return
  14243. +dateref(pRSPParser ctx)
  14244. +{
  14245. + RSPParser_dateref_return retval;
  14246. +
  14247. + pANTLR3_BASE_TREE root_0;
  14248. +
  14249. + pANTLR3_COMMON_TOKEN set41;
  14250. +
  14251. + pANTLR3_BASE_TREE set41_tree;
  14252. +
  14253. + /* Initialize rule variables
  14254. + */
  14255. +
  14256. +
  14257. + root_0 = NULL;
  14258. +
  14259. + set41 = NULL;
  14260. + retval.start = LT(1); retval.stop = retval.start;
  14261. +
  14262. + set41_tree = NULL;
  14263. +
  14264. +
  14265. + retval.tree = NULL;
  14266. + {
  14267. + // RSP.g:74:9: ( DATE | TODAY )
  14268. + // RSP.g:
  14269. + {
  14270. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  14271. +
  14272. + set41=(pANTLR3_COMMON_TOKEN)LT(1);
  14273. + if ( ((LA(1) >= DATE) && (LA(1) <= TODAY)) )
  14274. + {
  14275. + CONSUME();
  14276. + ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set41)));
  14277. + PERRORRECOVERY=ANTLR3_FALSE;
  14278. + }
  14279. + else
  14280. + {
  14281. + CONSTRUCTEX();
  14282. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  14283. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  14284. + EXCEPTION->expectingSet = &FOLLOW_set_in_dateref0;
  14285. + RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateref0); goto ruledaterefEx;
  14286. + }
  14287. +
  14288. +
  14289. + }
  14290. +
  14291. + }
  14292. +
  14293. +
  14294. + // This is where rules clean up and exit
  14295. + //
  14296. + goto ruledaterefEx; /* Prevent compiler warnings */
  14297. + ruledaterefEx: ;
  14298. + retval.stop = LT(-1);
  14299. +
  14300. + retval.stop = LT(-1);
  14301. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  14302. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  14303. +
  14304. + if (HASEXCEPTION())
  14305. + {
  14306. + PREPORTERROR();
  14307. + PRECOVER();
  14308. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  14309. + }
  14310. +
  14311. +
  14312. + return retval;
  14313. +}
  14314. +/* $ANTLR end dateref */
  14315. +
  14316. +/**
  14317. + * $ANTLR start dateintval
  14318. + * RSP.g:78:1: dateintval : ( DAY | WEEK | MONTH | YEAR );
  14319. + */
  14320. +static RSPParser_dateintval_return
  14321. +dateintval(pRSPParser ctx)
  14322. +{
  14323. + RSPParser_dateintval_return retval;
  14324. +
  14325. + pANTLR3_BASE_TREE root_0;
  14326. +
  14327. + pANTLR3_COMMON_TOKEN set42;
  14328. +
  14329. + pANTLR3_BASE_TREE set42_tree;
  14330. +
  14331. + /* Initialize rule variables
  14332. + */
  14333. +
  14334. +
  14335. + root_0 = NULL;
  14336. +
  14337. + set42 = NULL;
  14338. + retval.start = LT(1); retval.stop = retval.start;
  14339. +
  14340. + set42_tree = NULL;
  14341. +
  14342. +
  14343. + retval.tree = NULL;
  14344. + {
  14345. + // RSP.g:79:2: ( DAY | WEEK | MONTH | YEAR )
  14346. + // RSP.g:
  14347. + {
  14348. + root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
  14349. +
  14350. + set42=(pANTLR3_COMMON_TOKEN)LT(1);
  14351. + if ( ((LA(1) >= DAY) && (LA(1) <= YEAR)) )
  14352. + {
  14353. + CONSUME();
  14354. + ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set42)));
  14355. + PERRORRECOVERY=ANTLR3_FALSE;
  14356. + }
  14357. + else
  14358. + {
  14359. + CONSTRUCTEX();
  14360. + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
  14361. + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
  14362. + EXCEPTION->expectingSet = &FOLLOW_set_in_dateintval0;
  14363. + RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateintval0); goto ruledateintvalEx;
  14364. + }
  14365. +
  14366. +
  14367. + }
  14368. +
  14369. + }
  14370. +
  14371. +
  14372. + // This is where rules clean up and exit
  14373. + //
  14374. + goto ruledateintvalEx; /* Prevent compiler warnings */
  14375. + ruledateintvalEx: ;
  14376. + retval.stop = LT(-1);
  14377. +
  14378. + retval.stop = LT(-1);
  14379. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
  14380. + ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
  14381. +
  14382. + if (HASEXCEPTION())
  14383. + {
  14384. + PREPORTERROR();
  14385. + PRECOVER();
  14386. + retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
  14387. + }
  14388. +
  14389. +
  14390. + return retval;
  14391. +}
  14392. +/* $ANTLR end dateintval */
  14393. +/* End of parsing rules
  14394. + * ==============================================
  14395. + */
  14396. +
  14397. +/* ==============================================
  14398. + * Syntactic predicates
  14399. + */
  14400. +/* End of syntactic predicates
  14401. + * ==============================================
  14402. + */
  14403. +
  14404. +
  14405. +
  14406. +
  14407. +
  14408. +
  14409. +/* End of code
  14410. + * =============================================================================
  14411. + */
  14412. diff --git a/src/pregen/RSPParser.h b/src/pregen/RSPParser.h
  14413. new file mode 100644
  14414. index 0000000..d0744a2
  14415. --- /dev/null
  14416. +++ b/src/pregen/RSPParser.h
  14417. @@ -0,0 +1,365 @@
  14418. +/** \file
  14419. + * This C header file was generated by $ANTLR version 3.2 debian-7ubuntu3
  14420. + *
  14421. + * - From the grammar source file : RSP.g
  14422. + * - On : 2014-09-30 21:42:40
  14423. + * - for the parser : RSPParserParser *
  14424. + * Editing it, at least manually, is not wise.
  14425. + *
  14426. + * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
  14427. + *
  14428. + *
  14429. + * The parser RSPParser has the callable functions (rules) shown below,
  14430. + * which will invoke the code for the associated rule in the source grammar
  14431. + * assuming that the input stream is pointing to a token/text stream that could begin
  14432. + * this rule.
  14433. + *
  14434. + * For instance if you call the first (topmost) rule in a parser grammar, you will
  14435. + * get the results of a full parse, but calling a rule half way through the grammar will
  14436. + * allow you to pass part of a full token stream to the parser, such as for syntax checking
  14437. + * in editors and so on.
  14438. + *
  14439. + * The parser entry points are called indirectly (by function pointer to function) via
  14440. + * a parser context typedef pRSPParser, which is returned from a call to RSPParserNew().
  14441. + *
  14442. + * The methods in pRSPParser are as follows:
  14443. + *
  14444. + * - RSPParser_query_return pRSPParser->query(pRSPParser)
  14445. + * - RSPParser_expr_return pRSPParser->expr(pRSPParser)
  14446. + * - RSPParser_aexpr_return pRSPParser->aexpr(pRSPParser)
  14447. + * - RSPParser_crit_return pRSPParser->crit(pRSPParser)
  14448. + * - RSPParser_strcrit_return pRSPParser->strcrit(pRSPParser)
  14449. + * - RSPParser_strop_return pRSPParser->strop(pRSPParser)
  14450. + * - RSPParser_intcrit_return pRSPParser->intcrit(pRSPParser)
  14451. + * - RSPParser_intop_return pRSPParser->intop(pRSPParser)
  14452. + * - RSPParser_datecrit_return pRSPParser->datecrit(pRSPParser)
  14453. + * - RSPParser_dateop_return pRSPParser->dateop(pRSPParser)
  14454. + * - RSPParser_datespec_return pRSPParser->datespec(pRSPParser)
  14455. + * - RSPParser_dateref_return pRSPParser->dateref(pRSPParser)
  14456. + * - RSPParser_dateintval_return pRSPParser->dateintval(pRSPParser)
  14457. + *
  14458. + * The return type for any particular rule is of course determined by the source
  14459. + * grammar file.
  14460. + */
  14461. +// [The "BSD licence"]
  14462. +// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
  14463. +// http://www.temporal-wave.com
  14464. +// http://www.linkedin.com/in/jimidle
  14465. +//
  14466. +// All rights reserved.
  14467. +//
  14468. +// Redistribution and use in source and binary forms, with or without
  14469. +// modification, are permitted provided that the following conditions
  14470. +// are met:
  14471. +// 1. Redistributions of source code must retain the above copyright
  14472. +// notice, this list of conditions and the following disclaimer.
  14473. +// 2. Redistributions in binary form must reproduce the above copyright
  14474. +// notice, this list of conditions and the following disclaimer in the
  14475. +// documentation and/or other materials provided with the distribution.
  14476. +// 3. The name of the author may not be used to endorse or promote products
  14477. +// derived from this software without specific prior written permission.
  14478. +//
  14479. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  14480. +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14481. +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14482. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  14483. +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  14484. +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  14485. +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14486. +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14487. +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  14488. +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14489. +
  14490. +#ifndef _RSPParser_H
  14491. +#define _RSPParser_H
  14492. +/* =============================================================================
  14493. + * Standard antlr3 C runtime definitions
  14494. + */
  14495. +#include <antlr3.h>
  14496. +
  14497. +/* End of standard antlr 3 runtime definitions
  14498. + * =============================================================================
  14499. + */
  14500. +
  14501. +#ifdef __cplusplus
  14502. +extern "C" {
  14503. +#endif
  14504. +
  14505. +// Forward declare the context typedef so that we can use it before it is
  14506. +// properly defined. Delegators and delegates (from import statements) are
  14507. +// interdependent and their context structures contain pointers to each other
  14508. +// C only allows such things to be declared if you pre-declare the typedef.
  14509. +//
  14510. +typedef struct RSPParser_Ctx_struct RSPParser, * pRSPParser;
  14511. +
  14512. +
  14513. +
  14514. +#ifdef ANTLR3_WINDOWS
  14515. +// Disable: Unreferenced parameter, - Rules with parameters that are not used
  14516. +// constant conditional, - ANTLR realizes that a prediction is always true (synpred usually)
  14517. +// initialized but unused variable - tree rewrite variables declared but not needed
  14518. +// Unreferenced local variable - lexer rule declares but does not always use _type
  14519. +// potentially unitialized variable used - retval always returned from a rule
  14520. +// unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns
  14521. +//
  14522. +// These are only really displayed at warning level /W4 but that is the code ideal I am aiming at
  14523. +// and the codegen must generate some of these warnings by necessity, apart from 4100, which is
  14524. +// usually generated when a parser rule is given a parameter that it does not use. Mostly though
  14525. +// this is a matter of orthogonality hence I disable that one.
  14526. +//
  14527. +#pragma warning( disable : 4100 )
  14528. +#pragma warning( disable : 4101 )
  14529. +#pragma warning( disable : 4127 )
  14530. +#pragma warning( disable : 4189 )
  14531. +#pragma warning( disable : 4505 )
  14532. +#pragma warning( disable : 4701 )
  14533. +#endif
  14534. +typedef struct RSPParser_query_return_struct
  14535. +{
  14536. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14537. + */
  14538. + pANTLR3_COMMON_TOKEN start;
  14539. + pANTLR3_COMMON_TOKEN stop;
  14540. + pANTLR3_BASE_TREE tree;
  14541. +
  14542. +}
  14543. + RSPParser_query_return;
  14544. +
  14545. +typedef struct RSPParser_expr_return_struct
  14546. +{
  14547. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14548. + */
  14549. + pANTLR3_COMMON_TOKEN start;
  14550. + pANTLR3_COMMON_TOKEN stop;
  14551. + pANTLR3_BASE_TREE tree;
  14552. +
  14553. +}
  14554. + RSPParser_expr_return;
  14555. +
  14556. +typedef struct RSPParser_aexpr_return_struct
  14557. +{
  14558. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14559. + */
  14560. + pANTLR3_COMMON_TOKEN start;
  14561. + pANTLR3_COMMON_TOKEN stop;
  14562. + pANTLR3_BASE_TREE tree;
  14563. +
  14564. +}
  14565. + RSPParser_aexpr_return;
  14566. +
  14567. +typedef struct RSPParser_crit_return_struct
  14568. +{
  14569. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14570. + */
  14571. + pANTLR3_COMMON_TOKEN start;
  14572. + pANTLR3_COMMON_TOKEN stop;
  14573. + pANTLR3_BASE_TREE tree;
  14574. +
  14575. +}
  14576. + RSPParser_crit_return;
  14577. +
  14578. +typedef struct RSPParser_strcrit_return_struct
  14579. +{
  14580. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14581. + */
  14582. + pANTLR3_COMMON_TOKEN start;
  14583. + pANTLR3_COMMON_TOKEN stop;
  14584. + pANTLR3_BASE_TREE tree;
  14585. +
  14586. +}
  14587. + RSPParser_strcrit_return;
  14588. +
  14589. +typedef struct RSPParser_strop_return_struct
  14590. +{
  14591. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14592. + */
  14593. + pANTLR3_COMMON_TOKEN start;
  14594. + pANTLR3_COMMON_TOKEN stop;
  14595. + pANTLR3_BASE_TREE tree;
  14596. +
  14597. +}
  14598. + RSPParser_strop_return;
  14599. +
  14600. +typedef struct RSPParser_intcrit_return_struct
  14601. +{
  14602. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14603. + */
  14604. + pANTLR3_COMMON_TOKEN start;
  14605. + pANTLR3_COMMON_TOKEN stop;
  14606. + pANTLR3_BASE_TREE tree;
  14607. +
  14608. +}
  14609. + RSPParser_intcrit_return;
  14610. +
  14611. +typedef struct RSPParser_intop_return_struct
  14612. +{
  14613. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14614. + */
  14615. + pANTLR3_COMMON_TOKEN start;
  14616. + pANTLR3_COMMON_TOKEN stop;
  14617. + pANTLR3_BASE_TREE tree;
  14618. +
  14619. +}
  14620. + RSPParser_intop_return;
  14621. +
  14622. +typedef struct RSPParser_datecrit_return_struct
  14623. +{
  14624. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14625. + */
  14626. + pANTLR3_COMMON_TOKEN start;
  14627. + pANTLR3_COMMON_TOKEN stop;
  14628. + pANTLR3_BASE_TREE tree;
  14629. +
  14630. +}
  14631. + RSPParser_datecrit_return;
  14632. +
  14633. +typedef struct RSPParser_dateop_return_struct
  14634. +{
  14635. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14636. + */
  14637. + pANTLR3_COMMON_TOKEN start;
  14638. + pANTLR3_COMMON_TOKEN stop;
  14639. + pANTLR3_BASE_TREE tree;
  14640. +
  14641. +}
  14642. + RSPParser_dateop_return;
  14643. +
  14644. +typedef struct RSPParser_datespec_return_struct
  14645. +{
  14646. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14647. + */
  14648. + pANTLR3_COMMON_TOKEN start;
  14649. + pANTLR3_COMMON_TOKEN stop;
  14650. + pANTLR3_BASE_TREE tree;
  14651. +
  14652. +}
  14653. + RSPParser_datespec_return;
  14654. +
  14655. +typedef struct RSPParser_dateref_return_struct
  14656. +{
  14657. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14658. + */
  14659. + pANTLR3_COMMON_TOKEN start;
  14660. + pANTLR3_COMMON_TOKEN stop;
  14661. + pANTLR3_BASE_TREE tree;
  14662. +
  14663. +}
  14664. + RSPParser_dateref_return;
  14665. +
  14666. +typedef struct RSPParser_dateintval_return_struct
  14667. +{
  14668. + /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
  14669. + */
  14670. + pANTLR3_COMMON_TOKEN start;
  14671. + pANTLR3_COMMON_TOKEN stop;
  14672. + pANTLR3_BASE_TREE tree;
  14673. +
  14674. +}
  14675. + RSPParser_dateintval_return;
  14676. +
  14677. +
  14678. +
  14679. +/** Context tracking structure for RSPParser
  14680. + */
  14681. +struct RSPParser_Ctx_struct
  14682. +{
  14683. + /** Built in ANTLR3 context tracker contains all the generic elements
  14684. + * required for context tracking.
  14685. + */
  14686. + pANTLR3_PARSER pParser;
  14687. +
  14688. +
  14689. + RSPParser_query_return (*query) (struct RSPParser_Ctx_struct * ctx);
  14690. + RSPParser_expr_return (*expr) (struct RSPParser_Ctx_struct * ctx);
  14691. + RSPParser_aexpr_return (*aexpr) (struct RSPParser_Ctx_struct * ctx);
  14692. + RSPParser_crit_return (*crit) (struct RSPParser_Ctx_struct * ctx);
  14693. + RSPParser_strcrit_return (*strcrit) (struct RSPParser_Ctx_struct * ctx);
  14694. + RSPParser_strop_return (*strop) (struct RSPParser_Ctx_struct * ctx);
  14695. + RSPParser_intcrit_return (*intcrit) (struct RSPParser_Ctx_struct * ctx);
  14696. + RSPParser_intop_return (*intop) (struct RSPParser_Ctx_struct * ctx);
  14697. + RSPParser_datecrit_return (*datecrit) (struct RSPParser_Ctx_struct * ctx);
  14698. + RSPParser_dateop_return (*dateop) (struct RSPParser_Ctx_struct * ctx);
  14699. + RSPParser_datespec_return (*datespec) (struct RSPParser_Ctx_struct * ctx);
  14700. + RSPParser_dateref_return (*dateref) (struct RSPParser_Ctx_struct * ctx);
  14701. + RSPParser_dateintval_return (*dateintval) (struct RSPParser_Ctx_struct * ctx);
  14702. + // Delegated rules
  14703. + const char * (*getGrammarFileName)();
  14704. + void (*free) (struct RSPParser_Ctx_struct * ctx);
  14705. + /* @headerFile.members() */
  14706. + pANTLR3_BASE_TREE_ADAPTOR adaptor;
  14707. + pANTLR3_VECTOR_FACTORY vectors;
  14708. + /* End @headerFile.members() */
  14709. +};
  14710. +
  14711. +// Function protoypes for the constructor functions that external translation units
  14712. +// such as delegators and delegates may wish to call.
  14713. +//
  14714. +ANTLR3_API pRSPParser RSPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream);
  14715. +ANTLR3_API pRSPParser RSPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state);
  14716. +
  14717. +/** Symbolic definitions of all the tokens that the parser will work with.
  14718. + * \{
  14719. + *
  14720. + * Antlr will define EOF, but we can't use that as it it is too common in
  14721. + * in C header files and that would be confusing. There is no way to filter this out at the moment
  14722. + * so we just undef it here for now. That isn't the value we get back from C recognizers
  14723. + * anyway. We are looking for ANTLR3_TOKEN_EOF.
  14724. + */
  14725. +#ifdef EOF
  14726. +#undef EOF
  14727. +#endif
  14728. +#ifdef Tokens
  14729. +#undef Tokens
  14730. +#endif
  14731. +#define STARTSW 14
  14732. +#define WEEK 26
  14733. +#define TODAY 24
  14734. +#define YEAR 28
  14735. +#define ENDSW 15
  14736. +#define GTE 20
  14737. +#define BEFORE 21
  14738. +#define DAY 25
  14739. +#define INT 16
  14740. +#define NOT 11
  14741. +#define AFTER 22
  14742. +#define AND 6
  14743. +#define EOF -1
  14744. +#define LTE 19
  14745. +#define MONTH 27
  14746. +#define DIGIT19 31
  14747. +#define INCLUDES 13
  14748. +#define STR 10
  14749. +#define QUOTE 29
  14750. +#define WS 30
  14751. +#define GREATER 18
  14752. +#define NEWLINE 4
  14753. +#define LPAR 7
  14754. +#define EQUAL 12
  14755. +#define OR 5
  14756. +#define LESS 17
  14757. +#define RPAR 8
  14758. +#define FIELD 9
  14759. +#define ESCAPED 33
  14760. +#define DATE 23
  14761. +#define DIGIT09 32
  14762. +#ifdef EOF
  14763. +#undef EOF
  14764. +#define EOF ANTLR3_TOKEN_EOF
  14765. +#endif
  14766. +
  14767. +#ifndef TOKENSOURCE
  14768. +#define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource
  14769. +#endif
  14770. +
  14771. +/* End of token definitions for RSPParser
  14772. + * =============================================================================
  14773. + */
  14774. +/** \} */
  14775. +
  14776. +#ifdef __cplusplus
  14777. +}
  14778. +#endif
  14779. +
  14780. +#endif
  14781. +
  14782. +/* END - Note:Keep extra line feed to satisfy UNIX systems */