oql-parser.php 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863
  1. <?php
  2. /* Driver template for the PHP_OQLParser_rGenerator parser generator. (PHP port of LEMON)
  3. */
  4. /**
  5. * This can be used to store both the string representation of
  6. * a token, and any useful meta-data associated with the token.
  7. *
  8. * meta-data should be stored as an array
  9. */
  10. class OQLParser_yyToken implements ArrayAccess
  11. {
  12. public $string = '';
  13. public $metadata = array();
  14. function __construct($s, $m = array())
  15. {
  16. if ($s instanceof OQLParser_yyToken) {
  17. $this->string = $s->string;
  18. $this->metadata = $s->metadata;
  19. } else {
  20. $this->string = (string) $s;
  21. if ($m instanceof OQLParser_yyToken) {
  22. $this->metadata = $m->metadata;
  23. } elseif (is_array($m)) {
  24. $this->metadata = $m;
  25. }
  26. }
  27. }
  28. function __toString()
  29. {
  30. return $this->string;
  31. }
  32. function offsetExists($offset)
  33. {
  34. return isset($this->metadata[$offset]);
  35. }
  36. function offsetGet($offset)
  37. {
  38. return $this->metadata[$offset];
  39. }
  40. function offsetSet($offset, $value)
  41. {
  42. if ($offset === null) {
  43. if (isset($value[0])) {
  44. $x = ($value instanceof OQLParser_yyToken) ?
  45. $value->metadata : $value;
  46. $this->metadata = array_merge($this->metadata, $x);
  47. return;
  48. }
  49. $offset = count($this->metadata);
  50. }
  51. if ($value === null) {
  52. return;
  53. }
  54. if ($value instanceof OQLParser_yyToken) {
  55. if ($value->metadata) {
  56. $this->metadata[$offset] = $value->metadata;
  57. }
  58. } elseif ($value) {
  59. $this->metadata[$offset] = $value;
  60. }
  61. }
  62. function offsetUnset($offset)
  63. {
  64. unset($this->metadata[$offset]);
  65. }
  66. }
  67. /** The following structure represents a single element of the
  68. * parser's stack. Information stored includes:
  69. *
  70. * + The state number for the parser at this level of the stack.
  71. *
  72. * + The value of the token stored at this level of the stack.
  73. * (In other words, the "major" token.)
  74. *
  75. * + The semantic value stored at this level of the stack. This is
  76. * the information used by the action routines in the grammar.
  77. * It is sometimes called the "minor" token.
  78. */
  79. class OQLParser_yyStackEntry
  80. {
  81. public $stateno; /* The state-number */
  82. public $major; /* The major token value. This is the code
  83. ** number for the token at this stack level */
  84. public $minor; /* The user-supplied minor token value. This
  85. ** is the value of the token */
  86. };
  87. // code external to the class is included here
  88. // declare_class is output here
  89. #line 24 "oql-parser.y"
  90. class OQLParserRaw#line 102 "oql-parser.php"
  91. {
  92. /* First off, code is included which follows the "include_class" declaration
  93. ** in the input file. */
  94. /* Next is all token values, as class constants
  95. */
  96. /*
  97. ** These constants (all generated automatically by the parser generator)
  98. ** specify the various kinds of tokens (terminals) that the parser
  99. ** understands.
  100. **
  101. ** Each symbol here is a terminal symbol in the grammar.
  102. */
  103. const SELECT = 1;
  104. const AS_ALIAS = 2;
  105. const FROM = 3;
  106. const COMA = 4;
  107. const WHERE = 5;
  108. const JOIN = 6;
  109. const ON = 7;
  110. const EQ = 8;
  111. const BELOW = 9;
  112. const BELOW_STRICT = 10;
  113. const NOT_BELOW = 11;
  114. const NOT_BELOW_STRICT = 12;
  115. const ABOVE = 13;
  116. const ABOVE_STRICT = 14;
  117. const NOT_ABOVE = 15;
  118. const NOT_ABOVE_STRICT = 16;
  119. const PAR_OPEN = 17;
  120. const PAR_CLOSE = 18;
  121. const INTERVAL = 19;
  122. const F_SECOND = 20;
  123. const F_MINUTE = 21;
  124. const F_HOUR = 22;
  125. const F_DAY = 23;
  126. const F_MONTH = 24;
  127. const F_YEAR = 25;
  128. const DOT = 26;
  129. const VARNAME = 27;
  130. const NAME = 28;
  131. const NUMVAL = 29;
  132. const STRVAL = 30;
  133. const REGEXP = 31;
  134. const NOT_EQ = 32;
  135. const LOG_AND = 33;
  136. const LOG_OR = 34;
  137. const MATH_DIV = 35;
  138. const MATH_MULT = 36;
  139. const MATH_PLUS = 37;
  140. const MATH_MINUS = 38;
  141. const GT = 39;
  142. const LT = 40;
  143. const GE = 41;
  144. const LE = 42;
  145. const LIKE = 43;
  146. const NOT_LIKE = 44;
  147. const IN = 45;
  148. const NOT_IN = 46;
  149. const F_IF = 47;
  150. const F_ELT = 48;
  151. const F_COALESCE = 49;
  152. const F_ISNULL = 50;
  153. const F_CONCAT = 51;
  154. const F_SUBSTR = 52;
  155. const F_TRIM = 53;
  156. const F_DATE = 54;
  157. const F_DATE_FORMAT = 55;
  158. const F_CURRENT_DATE = 56;
  159. const F_NOW = 57;
  160. const F_TIME = 58;
  161. const F_TO_DAYS = 59;
  162. const F_FROM_DAYS = 60;
  163. const F_DATE_ADD = 61;
  164. const F_DATE_SUB = 62;
  165. const F_ROUND = 63;
  166. const F_FLOOR = 64;
  167. const F_INET_ATON = 65;
  168. const F_INET_NTOA = 66;
  169. const YY_NO_ACTION = 262;
  170. const YY_ACCEPT_ACTION = 261;
  171. const YY_ERROR_ACTION = 260;
  172. /* Next are that tables used to determine what action to take based on the
  173. ** current state and lookahead token. These tables are used to implement
  174. ** functions that take a state number and lookahead value and return an
  175. ** action integer.
  176. **
  177. ** Suppose the action integer is N. Then the action is determined as
  178. ** follows
  179. **
  180. ** 0 <= N < self::YYNSTATE Shift N. That is,
  181. ** push the lookahead
  182. ** token onto the stack
  183. ** and goto state N.
  184. **
  185. ** self::YYNSTATE <= N < self::YYNSTATE+self::YYNRULE Reduce by rule N-YYNSTATE.
  186. **
  187. ** N == self::YYNSTATE+self::YYNRULE A syntax error has occurred.
  188. **
  189. ** N == self::YYNSTATE+self::YYNRULE+1 The parser accepts its
  190. ** input. (and concludes parsing)
  191. **
  192. ** N == self::YYNSTATE+self::YYNRULE+2 No such action. Denotes unused
  193. ** slots in the yy_action[] table.
  194. **
  195. ** The action table is constructed as a single large static array $yy_action.
  196. ** Given state S and lookahead X, the action is computed as
  197. **
  198. ** self::$yy_action[self::$yy_shift_ofst[S] + X ]
  199. **
  200. ** If the index value self::$yy_shift_ofst[S]+X is out of range or if the value
  201. ** self::$yy_lookahead[self::$yy_shift_ofst[S]+X] is not equal to X or if
  202. ** self::$yy_shift_ofst[S] is equal to self::YY_SHIFT_USE_DFLT, it means that
  203. ** the action is not in the table and that self::$yy_default[S] should be used instead.
  204. **
  205. ** The formula above is for computing the action when the lookahead is
  206. ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
  207. ** a reduce action) then the static $yy_reduce_ofst array is used in place of
  208. ** the static $yy_shift_ofst array and self::YY_REDUCE_USE_DFLT is used in place of
  209. ** self::YY_SHIFT_USE_DFLT.
  210. **
  211. ** The following are the tables generated in this section:
  212. **
  213. ** self::$yy_action A single table containing all actions.
  214. ** self::$yy_lookahead A table containing the lookahead for each entry in
  215. ** yy_action. Used to detect hash collisions.
  216. ** self::$yy_shift_ofst For each state, the offset into self::$yy_action for
  217. ** shifting terminals.
  218. ** self::$yy_reduce_ofst For each state, the offset into self::$yy_action for
  219. ** shifting non-terminals after a reduce.
  220. ** self::$yy_default Default action for each state.
  221. */
  222. const YY_SZ_ACTTAB = 486;
  223. static public $yy_action = array(
  224. /* 0 */ 16, 71, 69, 68, 70, 65, 66, 10, 91, 31,
  225. /* 10 */ 159, 159, 80, 35, 115, 120, 6, 137, 127, 11,
  226. /* 20 */ 128, 126, 145, 140, 139, 8, 94, 95, 92, 93,
  227. /* 30 */ 120, 125, 124, 138, 118, 116, 13, 129, 130, 135,
  228. /* 40 */ 136, 134, 133, 131, 132, 53, 98, 99, 104, 105,
  229. /* 50 */ 103, 102, 100, 101, 121, 122, 143, 144, 142, 141,
  230. /* 60 */ 146, 151, 150, 149, 147, 148, 6, 48, 7, 9,
  231. /* 70 */ 33, 34, 145, 140, 139, 35, 94, 95, 92, 93,
  232. /* 80 */ 5, 25, 20, 19, 18, 21, 24, 22, 23, 17,
  233. /* 90 */ 84, 36, 27, 33, 64, 56, 98, 99, 104, 105,
  234. /* 100 */ 103, 102, 100, 101, 121, 122, 143, 144, 142, 141,
  235. /* 110 */ 146, 151, 150, 149, 147, 148, 6, 37, 39, 78,
  236. /* 120 */ 74, 74, 145, 140, 139, 120, 94, 95, 92, 93,
  237. /* 130 */ 44, 8, 38, 33, 67, 50, 46, 12, 33, 33,
  238. /* 140 */ 3, 1, 79, 212, 152, 28, 98, 99, 104, 105,
  239. /* 150 */ 103, 102, 100, 101, 121, 122, 143, 144, 142, 141,
  240. /* 160 */ 146, 151, 150, 149, 147, 148, 261, 123, 112, 62,
  241. /* 170 */ 95, 74, 58, 61, 74, 108, 47, 40, 110, 109,
  242. /* 180 */ 63, 97, 119, 62, 30, 35, 15, 4, 45, 81,
  243. /* 190 */ 49, 113, 32, 85, 117, 107, 106, 96, 60, 62,
  244. /* 200 */ 213, 74, 74, 2, 213, 108, 52, 40, 110, 109,
  245. /* 210 */ 63, 57, 60, 213, 30, 213, 15, 114, 45, 213,
  246. /* 220 */ 213, 74, 90, 62, 117, 107, 106, 96, 60, 108,
  247. /* 230 */ 52, 40, 110, 109, 63, 213, 213, 213, 30, 62,
  248. /* 240 */ 15, 213, 45, 213, 77, 55, 72, 62, 117, 107,
  249. /* 250 */ 106, 96, 60, 108, 43, 40, 110, 109, 63, 213,
  250. /* 260 */ 213, 213, 30, 213, 15, 213, 45, 213, 60, 59,
  251. /* 270 */ 111, 62, 117, 107, 106, 96, 60, 108, 47, 40,
  252. /* 280 */ 110, 109, 63, 213, 213, 213, 30, 213, 15, 213,
  253. /* 290 */ 45, 213, 213, 213, 213, 62, 117, 107, 106, 96,
  254. /* 300 */ 60, 108, 51, 40, 110, 109, 63, 213, 213, 213,
  255. /* 310 */ 30, 62, 15, 213, 45, 213, 83, 55, 213, 62,
  256. /* 320 */ 117, 107, 106, 96, 60, 108, 42, 40, 110, 109,
  257. /* 330 */ 63, 213, 213, 213, 30, 213, 15, 213, 45, 213,
  258. /* 340 */ 60, 213, 213, 62, 117, 107, 106, 96, 60, 108,
  259. /* 350 */ 26, 40, 110, 109, 63, 213, 213, 213, 30, 213,
  260. /* 360 */ 15, 213, 45, 213, 213, 213, 213, 62, 117, 107,
  261. /* 370 */ 106, 96, 60, 108, 62, 40, 110, 109, 63, 213,
  262. /* 380 */ 73, 213, 30, 62, 15, 213, 54, 213, 213, 82,
  263. /* 390 */ 213, 62, 117, 107, 106, 96, 60, 108, 62, 40,
  264. /* 400 */ 110, 109, 63, 60, 86, 213, 30, 213, 14, 213,
  265. /* 410 */ 213, 213, 60, 213, 213, 62, 117, 107, 106, 96,
  266. /* 420 */ 60, 108, 62, 40, 110, 109, 63, 60, 89, 213,
  267. /* 430 */ 29, 213, 62, 213, 213, 213, 213, 213, 76, 62,
  268. /* 440 */ 117, 107, 106, 96, 60, 108, 62, 41, 110, 109,
  269. /* 450 */ 63, 60, 87, 213, 62, 213, 62, 213, 213, 213,
  270. /* 460 */ 75, 60, 88, 213, 117, 107, 106, 96, 60, 213,
  271. /* 470 */ 213, 213, 213, 213, 213, 60, 213, 213, 213, 213,
  272. /* 480 */ 213, 213, 213, 60, 213, 60,
  273. );
  274. static public $yy_lookahead = array(
  275. /* 0 */ 1, 20, 21, 22, 23, 24, 25, 89, 8, 2,
  276. /* 10 */ 3, 4, 73, 6, 18, 34, 17, 35, 36, 87,
  277. /* 20 */ 102, 103, 23, 24, 25, 92, 27, 28, 29, 30,
  278. /* 30 */ 34, 31, 32, 101, 45, 46, 7, 37, 38, 39,
  279. /* 40 */ 40, 41, 42, 43, 44, 26, 47, 48, 49, 50,
  280. /* 50 */ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
  281. /* 60 */ 61, 62, 63, 64, 65, 66, 17, 72, 19, 91,
  282. /* 70 */ 75, 2, 23, 24, 25, 6, 27, 28, 29, 30,
  283. /* 80 */ 4, 8, 9, 10, 11, 12, 13, 14, 15, 16,
  284. /* 90 */ 72, 71, 71, 75, 18, 74, 47, 48, 49, 50,
  285. /* 100 */ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
  286. /* 110 */ 61, 62, 63, 64, 65, 66, 17, 3, 4, 73,
  287. /* 120 */ 100, 100, 23, 24, 25, 34, 27, 28, 29, 30,
  288. /* 130 */ 72, 92, 2, 75, 95, 72, 72, 7, 75, 75,
  289. /* 140 */ 5, 17, 71, 26, 33, 71, 47, 48, 49, 50,
  290. /* 150 */ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
  291. /* 160 */ 61, 62, 63, 64, 65, 66, 68, 69, 70, 71,
  292. /* 170 */ 28, 100, 71, 71, 100, 77, 78, 79, 80, 81,
  293. /* 180 */ 82, 100, 85, 71, 86, 6, 88, 17, 90, 77,
  294. /* 190 */ 84, 73, 71, 73, 96, 97, 98, 99, 100, 71,
  295. /* 200 */ 104, 100, 100, 4, 104, 77, 78, 79, 80, 81,
  296. /* 210 */ 82, 83, 100, 104, 86, 104, 88, 18, 90, 104,
  297. /* 220 */ 104, 100, 94, 71, 96, 97, 98, 99, 100, 77,
  298. /* 230 */ 78, 79, 80, 81, 82, 104, 104, 104, 86, 71,
  299. /* 240 */ 88, 104, 90, 104, 76, 77, 94, 71, 96, 97,
  300. /* 250 */ 98, 99, 100, 77, 78, 79, 80, 81, 82, 104,
  301. /* 260 */ 104, 104, 86, 104, 88, 104, 90, 104, 100, 93,
  302. /* 270 */ 70, 71, 96, 97, 98, 99, 100, 77, 78, 79,
  303. /* 280 */ 80, 81, 82, 104, 104, 104, 86, 104, 88, 104,
  304. /* 290 */ 90, 104, 104, 104, 104, 71, 96, 97, 98, 99,
  305. /* 300 */ 100, 77, 78, 79, 80, 81, 82, 104, 104, 104,
  306. /* 310 */ 86, 71, 88, 104, 90, 104, 76, 77, 104, 71,
  307. /* 320 */ 96, 97, 98, 99, 100, 77, 78, 79, 80, 81,
  308. /* 330 */ 82, 104, 104, 104, 86, 104, 88, 104, 90, 104,
  309. /* 340 */ 100, 104, 104, 71, 96, 97, 98, 99, 100, 77,
  310. /* 350 */ 78, 79, 80, 81, 82, 104, 104, 104, 86, 104,
  311. /* 360 */ 88, 104, 90, 104, 104, 104, 104, 71, 96, 97,
  312. /* 370 */ 98, 99, 100, 77, 71, 79, 80, 81, 82, 104,
  313. /* 380 */ 77, 104, 86, 71, 88, 104, 90, 104, 104, 77,
  314. /* 390 */ 104, 71, 96, 97, 98, 99, 100, 77, 71, 79,
  315. /* 400 */ 80, 81, 82, 100, 77, 104, 86, 104, 88, 104,
  316. /* 410 */ 104, 104, 100, 104, 104, 71, 96, 97, 98, 99,
  317. /* 420 */ 100, 77, 71, 79, 80, 81, 82, 100, 77, 104,
  318. /* 430 */ 86, 104, 71, 104, 104, 104, 104, 104, 77, 71,
  319. /* 440 */ 96, 97, 98, 99, 100, 77, 71, 79, 80, 81,
  320. /* 450 */ 82, 100, 77, 104, 71, 104, 71, 104, 104, 104,
  321. /* 460 */ 77, 100, 77, 104, 96, 97, 98, 99, 100, 104,
  322. /* 470 */ 104, 104, 104, 104, 104, 100, 104, 104, 104, 104,
  323. /* 480 */ 104, 104, 104, 100, 104, 100,
  324. );
  325. const YY_SHIFT_USE_DFLT = -20;
  326. const YY_SHIFT_MAX = 63;
  327. static public $yy_shift_ofst = array(
  328. /* 0 */ -1, 49, 49, 99, 99, 99, 99, 99, 99, 99,
  329. /* 10 */ 99, 99, 142, 142, 0, 0, 142, 142, 142, 142,
  330. /* 20 */ 142, 142, 142, 142, 142, 142, -19, 7, 69, -18,
  331. /* 30 */ -18, 142, 179, 179, 142, 142, 179, 142, 142, 142,
  332. /* 40 */ -11, -11, -4, 91, 135, 111, 135, 91, 135, 170,
  333. /* 50 */ 135, 91, 91, 142, 111, 73, 114, 199, 130, 76,
  334. /* 60 */ 117, 29, 19, 124,
  335. );
  336. const YY_REDUCE_USE_DFLT = -83;
  337. const YY_REDUCE_MAX = 54;
  338. static public $yy_reduce_ofst = array(
  339. /* 0 */ 98, 128, 152, 200, 176, 224, 248, 272, 296, 320,
  340. /* 10 */ 344, 368, 168, 240, -82, -82, 21, 383, 385, 351,
  341. /* 20 */ 375, 303, 112, 361, 312, 327, 39, 63, 64, -68,
  342. /* 30 */ -68, 20, -5, 18, 121, 101, 58, 74, 102, 71,
  343. /* 40 */ 106, 106, -67, -67, 120, -22, 46, -67, -61, 97,
  344. /* 50 */ 118, -67, -67, 81, -22,
  345. );
  346. static public $yyExpectedTokens = array(
  347. /* 0 */ array(1, 17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  348. /* 1 */ array(17, 19, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  349. /* 2 */ array(17, 19, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  350. /* 3 */ array(17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  351. /* 4 */ array(17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  352. /* 5 */ array(17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  353. /* 6 */ array(17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  354. /* 7 */ array(17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  355. /* 8 */ array(17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  356. /* 9 */ array(17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  357. /* 10 */ array(17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  358. /* 11 */ array(17, 23, 24, 25, 27, 28, 29, 30, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, ),
  359. /* 12 */ array(28, ),
  360. /* 13 */ array(28, ),
  361. /* 14 */ array(8, 31, 32, 37, 38, 39, 40, 41, 42, 43, 44, ),
  362. /* 15 */ array(8, 31, 32, 37, 38, 39, 40, 41, 42, 43, 44, ),
  363. /* 16 */ array(28, ),
  364. /* 17 */ array(28, ),
  365. /* 18 */ array(28, ),
  366. /* 19 */ array(28, ),
  367. /* 20 */ array(28, ),
  368. /* 21 */ array(28, ),
  369. /* 22 */ array(28, ),
  370. /* 23 */ array(28, ),
  371. /* 24 */ array(28, ),
  372. /* 25 */ array(28, ),
  373. /* 26 */ array(20, 21, 22, 23, 24, 25, 34, ),
  374. /* 27 */ array(2, 3, 4, 6, ),
  375. /* 28 */ array(2, 6, ),
  376. /* 29 */ array(35, 36, ),
  377. /* 30 */ array(35, 36, ),
  378. /* 31 */ array(28, ),
  379. /* 32 */ array(6, ),
  380. /* 33 */ array(6, ),
  381. /* 34 */ array(28, ),
  382. /* 35 */ array(28, ),
  383. /* 36 */ array(6, ),
  384. /* 37 */ array(28, ),
  385. /* 38 */ array(28, ),
  386. /* 39 */ array(28, ),
  387. /* 40 */ array(45, 46, ),
  388. /* 41 */ array(45, 46, ),
  389. /* 42 */ array(18, 34, ),
  390. /* 43 */ array(34, ),
  391. /* 44 */ array(5, ),
  392. /* 45 */ array(33, ),
  393. /* 46 */ array(5, ),
  394. /* 47 */ array(34, ),
  395. /* 48 */ array(5, ),
  396. /* 49 */ array(17, ),
  397. /* 50 */ array(5, ),
  398. /* 51 */ array(34, ),
  399. /* 52 */ array(34, ),
  400. /* 53 */ array(28, ),
  401. /* 54 */ array(33, ),
  402. /* 55 */ array(8, 9, 10, 11, 12, 13, 14, 15, 16, ),
  403. /* 56 */ array(3, 4, ),
  404. /* 57 */ array(4, 18, ),
  405. /* 58 */ array(2, 7, ),
  406. /* 59 */ array(4, 18, ),
  407. /* 60 */ array(26, ),
  408. /* 61 */ array(7, ),
  409. /* 62 */ array(26, ),
  410. /* 63 */ array(17, ),
  411. /* 64 */ array(),
  412. /* 65 */ array(),
  413. /* 66 */ array(),
  414. /* 67 */ array(),
  415. /* 68 */ array(),
  416. /* 69 */ array(),
  417. /* 70 */ array(),
  418. /* 71 */ array(),
  419. /* 72 */ array(),
  420. /* 73 */ array(),
  421. /* 74 */ array(),
  422. /* 75 */ array(),
  423. /* 76 */ array(),
  424. /* 77 */ array(),
  425. /* 78 */ array(),
  426. /* 79 */ array(),
  427. /* 80 */ array(),
  428. /* 81 */ array(),
  429. /* 82 */ array(),
  430. /* 83 */ array(),
  431. /* 84 */ array(),
  432. /* 85 */ array(),
  433. /* 86 */ array(),
  434. /* 87 */ array(),
  435. /* 88 */ array(),
  436. /* 89 */ array(),
  437. /* 90 */ array(),
  438. /* 91 */ array(),
  439. /* 92 */ array(),
  440. /* 93 */ array(),
  441. /* 94 */ array(),
  442. /* 95 */ array(),
  443. /* 96 */ array(),
  444. /* 97 */ array(),
  445. /* 98 */ array(),
  446. /* 99 */ array(),
  447. /* 100 */ array(),
  448. /* 101 */ array(),
  449. /* 102 */ array(),
  450. /* 103 */ array(),
  451. /* 104 */ array(),
  452. /* 105 */ array(),
  453. /* 106 */ array(),
  454. /* 107 */ array(),
  455. /* 108 */ array(),
  456. /* 109 */ array(),
  457. /* 110 */ array(),
  458. /* 111 */ array(),
  459. /* 112 */ array(),
  460. /* 113 */ array(),
  461. /* 114 */ array(),
  462. /* 115 */ array(),
  463. /* 116 */ array(),
  464. /* 117 */ array(),
  465. /* 118 */ array(),
  466. /* 119 */ array(),
  467. /* 120 */ array(),
  468. /* 121 */ array(),
  469. /* 122 */ array(),
  470. /* 123 */ array(),
  471. /* 124 */ array(),
  472. /* 125 */ array(),
  473. /* 126 */ array(),
  474. /* 127 */ array(),
  475. /* 128 */ array(),
  476. /* 129 */ array(),
  477. /* 130 */ array(),
  478. /* 131 */ array(),
  479. /* 132 */ array(),
  480. /* 133 */ array(),
  481. /* 134 */ array(),
  482. /* 135 */ array(),
  483. /* 136 */ array(),
  484. /* 137 */ array(),
  485. /* 138 */ array(),
  486. /* 139 */ array(),
  487. /* 140 */ array(),
  488. /* 141 */ array(),
  489. /* 142 */ array(),
  490. /* 143 */ array(),
  491. /* 144 */ array(),
  492. /* 145 */ array(),
  493. /* 146 */ array(),
  494. /* 147 */ array(),
  495. /* 148 */ array(),
  496. /* 149 */ array(),
  497. /* 150 */ array(),
  498. /* 151 */ array(),
  499. /* 152 */ array(),
  500. );
  501. static public $yy_default = array(
  502. /* 0 */ 260, 195, 260, 260, 260, 260, 260, 260, 260, 260,
  503. /* 10 */ 260, 260, 260, 260, 189, 188, 260, 260, 260, 260,
  504. /* 20 */ 260, 260, 260, 260, 260, 260, 260, 165, 165, 187,
  505. /* 30 */ 186, 260, 165, 164, 260, 260, 165, 260, 260, 260,
  506. /* 40 */ 184, 185, 260, 193, 162, 190, 162, 177, 162, 260,
  507. /* 50 */ 162, 194, 198, 260, 191, 260, 260, 260, 260, 260,
  508. /* 60 */ 210, 260, 260, 260, 192, 204, 205, 199, 202, 201,
  509. /* 70 */ 203, 200, 197, 172, 212, 176, 175, 167, 157, 160,
  510. /* 80 */ 158, 174, 173, 166, 163, 156, 168, 169, 171, 170,
  511. /* 90 */ 196, 221, 215, 216, 213, 214, 209, 211, 237, 238,
  512. /* 100 */ 243, 244, 242, 241, 239, 240, 208, 207, 179, 180,
  513. /* 110 */ 178, 161, 154, 155, 181, 182, 236, 206, 235, 183,
  514. /* 120 */ 224, 245, 246, 153, 222, 220, 219, 226, 218, 227,
  515. /* 130 */ 228, 233, 234, 232, 231, 229, 230, 225, 217, 251,
  516. /* 140 */ 252, 250, 249, 247, 248, 253, 254, 258, 259, 257,
  517. /* 150 */ 256, 255, 223,
  518. );
  519. /* The next thing included is series of defines which control
  520. ** various aspects of the generated parser.
  521. ** self::YYNOCODE is a number which corresponds
  522. ** to no legal terminal or nonterminal number. This
  523. ** number is used to fill in empty slots of the hash
  524. ** table.
  525. ** self::YYFALLBACK If defined, this indicates that one or more tokens
  526. ** have fall-back values which should be used if the
  527. ** original value of the token will not parse.
  528. ** self::YYSTACKDEPTH is the maximum depth of the parser's stack.
  529. ** self::YYNSTATE the combined number of states.
  530. ** self::YYNRULE the number of rules in the grammar
  531. ** self::YYERRORSYMBOL is the code number of the error symbol. If not
  532. ** defined, then do no error processing.
  533. */
  534. const YYNOCODE = 105;
  535. const YYSTACKDEPTH = 100;
  536. const YYNSTATE = 153;
  537. const YYNRULE = 107;
  538. const YYERRORSYMBOL = 67;
  539. const YYERRSYMDT = 'yy0';
  540. const YYFALLBACK = 0;
  541. /** The next table maps tokens into fallback tokens. If a construct
  542. * like the following:
  543. *
  544. * %fallback ID X Y Z.
  545. *
  546. * appears in the grammer, then ID becomes a fallback token for X, Y,
  547. * and Z. Whenever one of the tokens X, Y, or Z is input to the parser
  548. * but it does not parse, the type of the token is changed to ID and
  549. * the parse is retried before an error is thrown.
  550. */
  551. static public $yyFallback = array(
  552. );
  553. /**
  554. * Turn parser tracing on by giving a stream to which to write the trace
  555. * and a prompt to preface each trace message. Tracing is turned off
  556. * by making either argument NULL
  557. *
  558. * Inputs:
  559. *
  560. * - A stream resource to which trace output should be written.
  561. * If NULL, then tracing is turned off.
  562. * - A prefix string written at the beginning of every
  563. * line of trace output. If NULL, then tracing is
  564. * turned off.
  565. *
  566. * Outputs:
  567. *
  568. * - None.
  569. * @param resource
  570. * @param string
  571. */
  572. static function Trace($TraceFILE, $zTracePrompt)
  573. {
  574. if (!$TraceFILE) {
  575. $zTracePrompt = 0;
  576. } elseif (!$zTracePrompt) {
  577. $TraceFILE = 0;
  578. }
  579. self::$yyTraceFILE = $TraceFILE;
  580. self::$yyTracePrompt = $zTracePrompt;
  581. }
  582. /**
  583. * Output debug information to output (php://output stream)
  584. */
  585. static function PrintTrace()
  586. {
  587. self::$yyTraceFILE = fopen('php://output', 'w');
  588. self::$yyTracePrompt = '';
  589. }
  590. /**
  591. * @var resource|0
  592. */
  593. static public $yyTraceFILE;
  594. /**
  595. * String to prepend to debug output
  596. * @var string|0
  597. */
  598. static public $yyTracePrompt;
  599. /**
  600. * @var int
  601. */
  602. public $yyidx = -1; /* Index of top element in stack */
  603. /**
  604. * @var int
  605. */
  606. public $yyerrcnt; /* Shifts left before out of the error */
  607. /**
  608. * @var array
  609. */
  610. public $yystack = array(); /* The parser's stack */
  611. /**
  612. * For tracing shifts, the names of all terminals and nonterminals
  613. * are required. The following table supplies these names
  614. * @var array
  615. */
  616. static public $yyTokenName = array(
  617. '$', 'SELECT', 'AS_ALIAS', 'FROM',
  618. 'COMA', 'WHERE', 'JOIN', 'ON',
  619. 'EQ', 'BELOW', 'BELOW_STRICT', 'NOT_BELOW',
  620. 'NOT_BELOW_STRICT', 'ABOVE', 'ABOVE_STRICT', 'NOT_ABOVE',
  621. 'NOT_ABOVE_STRICT', 'PAR_OPEN', 'PAR_CLOSE', 'INTERVAL',
  622. 'F_SECOND', 'F_MINUTE', 'F_HOUR', 'F_DAY',
  623. 'F_MONTH', 'F_YEAR', 'DOT', 'VARNAME',
  624. 'NAME', 'NUMVAL', 'STRVAL', 'REGEXP',
  625. 'NOT_EQ', 'LOG_AND', 'LOG_OR', 'MATH_DIV',
  626. 'MATH_MULT', 'MATH_PLUS', 'MATH_MINUS', 'GT',
  627. 'LT', 'GE', 'LE', 'LIKE',
  628. 'NOT_LIKE', 'IN', 'NOT_IN', 'F_IF',
  629. 'F_ELT', 'F_COALESCE', 'F_ISNULL', 'F_CONCAT',
  630. 'F_SUBSTR', 'F_TRIM', 'F_DATE', 'F_DATE_FORMAT',
  631. 'F_CURRENT_DATE', 'F_NOW', 'F_TIME', 'F_TO_DAYS',
  632. 'F_FROM_DAYS', 'F_DATE_ADD', 'F_DATE_SUB', 'F_ROUND',
  633. 'F_FLOOR', 'F_INET_ATON', 'F_INET_NTOA', 'error',
  634. 'result', 'query', 'condition', 'class_name',
  635. 'join_statement', 'where_statement', 'class_list', 'join_item',
  636. 'join_condition', 'field_id', 'expression_prio4', 'expression_basic',
  637. 'scalar', 'var_name', 'func_name', 'arg_list',
  638. 'list_operator', 'list', 'expression_prio1', 'operator1',
  639. 'expression_prio2', 'operator2', 'expression_prio3', 'operator3',
  640. 'operator4', 'list_items', 'argument', 'interval_unit',
  641. 'num_scalar', 'str_scalar', 'num_value', 'str_value',
  642. 'name', 'num_operator1', 'num_operator2', 'str_operator',
  643. );
  644. /**
  645. * For tracing reduce actions, the names of all rules are required.
  646. * @var array
  647. */
  648. static public $yyRuleName = array(
  649. /* 0 */ "result ::= query",
  650. /* 1 */ "result ::= condition",
  651. /* 2 */ "query ::= SELECT class_name join_statement where_statement",
  652. /* 3 */ "query ::= SELECT class_name AS_ALIAS class_name join_statement where_statement",
  653. /* 4 */ "query ::= SELECT class_list FROM class_name join_statement where_statement",
  654. /* 5 */ "query ::= SELECT class_list FROM class_name AS_ALIAS class_name join_statement where_statement",
  655. /* 6 */ "class_list ::= class_name",
  656. /* 7 */ "class_list ::= class_list COMA class_name",
  657. /* 8 */ "where_statement ::= WHERE condition",
  658. /* 9 */ "where_statement ::=",
  659. /* 10 */ "join_statement ::= join_item join_statement",
  660. /* 11 */ "join_statement ::= join_item",
  661. /* 12 */ "join_statement ::=",
  662. /* 13 */ "join_item ::= JOIN class_name AS_ALIAS class_name ON join_condition",
  663. /* 14 */ "join_item ::= JOIN class_name ON join_condition",
  664. /* 15 */ "join_condition ::= field_id EQ field_id",
  665. /* 16 */ "join_condition ::= field_id BELOW field_id",
  666. /* 17 */ "join_condition ::= field_id BELOW_STRICT field_id",
  667. /* 18 */ "join_condition ::= field_id NOT_BELOW field_id",
  668. /* 19 */ "join_condition ::= field_id NOT_BELOW_STRICT field_id",
  669. /* 20 */ "join_condition ::= field_id ABOVE field_id",
  670. /* 21 */ "join_condition ::= field_id ABOVE_STRICT field_id",
  671. /* 22 */ "join_condition ::= field_id NOT_ABOVE field_id",
  672. /* 23 */ "join_condition ::= field_id NOT_ABOVE_STRICT field_id",
  673. /* 24 */ "condition ::= expression_prio4",
  674. /* 25 */ "expression_basic ::= scalar",
  675. /* 26 */ "expression_basic ::= field_id",
  676. /* 27 */ "expression_basic ::= var_name",
  677. /* 28 */ "expression_basic ::= func_name PAR_OPEN arg_list PAR_CLOSE",
  678. /* 29 */ "expression_basic ::= PAR_OPEN expression_prio4 PAR_CLOSE",
  679. /* 30 */ "expression_basic ::= expression_basic list_operator list",
  680. /* 31 */ "expression_prio1 ::= expression_basic",
  681. /* 32 */ "expression_prio1 ::= expression_prio1 operator1 expression_basic",
  682. /* 33 */ "expression_prio2 ::= expression_prio1",
  683. /* 34 */ "expression_prio2 ::= expression_prio2 operator2 expression_prio1",
  684. /* 35 */ "expression_prio3 ::= expression_prio2",
  685. /* 36 */ "expression_prio3 ::= expression_prio3 operator3 expression_prio2",
  686. /* 37 */ "expression_prio4 ::= expression_prio3",
  687. /* 38 */ "expression_prio4 ::= expression_prio4 operator4 expression_prio3",
  688. /* 39 */ "list ::= PAR_OPEN list_items PAR_CLOSE",
  689. /* 40 */ "list_items ::= expression_prio4",
  690. /* 41 */ "list_items ::= list_items COMA expression_prio4",
  691. /* 42 */ "arg_list ::=",
  692. /* 43 */ "arg_list ::= argument",
  693. /* 44 */ "arg_list ::= arg_list COMA argument",
  694. /* 45 */ "argument ::= expression_prio4",
  695. /* 46 */ "argument ::= INTERVAL expression_prio4 interval_unit",
  696. /* 47 */ "interval_unit ::= F_SECOND",
  697. /* 48 */ "interval_unit ::= F_MINUTE",
  698. /* 49 */ "interval_unit ::= F_HOUR",
  699. /* 50 */ "interval_unit ::= F_DAY",
  700. /* 51 */ "interval_unit ::= F_MONTH",
  701. /* 52 */ "interval_unit ::= F_YEAR",
  702. /* 53 */ "scalar ::= num_scalar",
  703. /* 54 */ "scalar ::= str_scalar",
  704. /* 55 */ "num_scalar ::= num_value",
  705. /* 56 */ "str_scalar ::= str_value",
  706. /* 57 */ "field_id ::= name",
  707. /* 58 */ "field_id ::= class_name DOT name",
  708. /* 59 */ "class_name ::= name",
  709. /* 60 */ "var_name ::= VARNAME",
  710. /* 61 */ "name ::= NAME",
  711. /* 62 */ "num_value ::= NUMVAL",
  712. /* 63 */ "str_value ::= STRVAL",
  713. /* 64 */ "operator1 ::= num_operator1",
  714. /* 65 */ "operator2 ::= num_operator2",
  715. /* 66 */ "operator2 ::= str_operator",
  716. /* 67 */ "operator2 ::= REGEXP",
  717. /* 68 */ "operator2 ::= EQ",
  718. /* 69 */ "operator2 ::= NOT_EQ",
  719. /* 70 */ "operator3 ::= LOG_AND",
  720. /* 71 */ "operator4 ::= LOG_OR",
  721. /* 72 */ "num_operator1 ::= MATH_DIV",
  722. /* 73 */ "num_operator1 ::= MATH_MULT",
  723. /* 74 */ "num_operator2 ::= MATH_PLUS",
  724. /* 75 */ "num_operator2 ::= MATH_MINUS",
  725. /* 76 */ "num_operator2 ::= GT",
  726. /* 77 */ "num_operator2 ::= LT",
  727. /* 78 */ "num_operator2 ::= GE",
  728. /* 79 */ "num_operator2 ::= LE",
  729. /* 80 */ "str_operator ::= LIKE",
  730. /* 81 */ "str_operator ::= NOT_LIKE",
  731. /* 82 */ "list_operator ::= IN",
  732. /* 83 */ "list_operator ::= NOT_IN",
  733. /* 84 */ "func_name ::= F_IF",
  734. /* 85 */ "func_name ::= F_ELT",
  735. /* 86 */ "func_name ::= F_COALESCE",
  736. /* 87 */ "func_name ::= F_ISNULL",
  737. /* 88 */ "func_name ::= F_CONCAT",
  738. /* 89 */ "func_name ::= F_SUBSTR",
  739. /* 90 */ "func_name ::= F_TRIM",
  740. /* 91 */ "func_name ::= F_DATE",
  741. /* 92 */ "func_name ::= F_DATE_FORMAT",
  742. /* 93 */ "func_name ::= F_CURRENT_DATE",
  743. /* 94 */ "func_name ::= F_NOW",
  744. /* 95 */ "func_name ::= F_TIME",
  745. /* 96 */ "func_name ::= F_TO_DAYS",
  746. /* 97 */ "func_name ::= F_FROM_DAYS",
  747. /* 98 */ "func_name ::= F_YEAR",
  748. /* 99 */ "func_name ::= F_MONTH",
  749. /* 100 */ "func_name ::= F_DAY",
  750. /* 101 */ "func_name ::= F_DATE_ADD",
  751. /* 102 */ "func_name ::= F_DATE_SUB",
  752. /* 103 */ "func_name ::= F_ROUND",
  753. /* 104 */ "func_name ::= F_FLOOR",
  754. /* 105 */ "func_name ::= F_INET_ATON",
  755. /* 106 */ "func_name ::= F_INET_NTOA",
  756. );
  757. /**
  758. * This function returns the symbolic name associated with a token
  759. * value.
  760. * @param int
  761. * @return string
  762. */
  763. function tokenName($tokenType)
  764. {
  765. if ($tokenType === 0) {
  766. return 'End of Input';
  767. }
  768. if ($tokenType > 0 && $tokenType < count(self::$yyTokenName)) {
  769. return self::$yyTokenName[$tokenType];
  770. } else {
  771. return "Unknown";
  772. }
  773. }
  774. /**
  775. * The following function deletes the value associated with a
  776. * symbol. The symbol can be either a terminal or nonterminal.
  777. * @param int the symbol code
  778. * @param mixed the symbol's value
  779. */
  780. static function yy_destructor($yymajor, $yypminor)
  781. {
  782. switch ($yymajor) {
  783. /* Here is inserted the actions which take place when a
  784. ** terminal or non-terminal is destroyed. This can happen
  785. ** when the symbol is popped from the stack during a
  786. ** reduce or during error processing or when a parser is
  787. ** being destroyed before it is finished parsing.
  788. **
  789. ** Note: during a reduce, the only symbols destroyed are those
  790. ** which appear on the RHS of the rule, but which are not used
  791. ** inside the C code.
  792. */
  793. default: break; /* If no destructor action specified: do nothing */
  794. }
  795. }
  796. /**
  797. * Pop the parser's stack once.
  798. *
  799. * If there is a destructor routine associated with the token which
  800. * is popped from the stack, then call it.
  801. *
  802. * Return the major token number for the symbol popped.
  803. * @param OQLParser_yyParser
  804. * @return int
  805. */
  806. function yy_pop_parser_stack()
  807. {
  808. if (!count($this->yystack)) {
  809. return;
  810. }
  811. $yytos = array_pop($this->yystack);
  812. if (self::$yyTraceFILE && $this->yyidx >= 0) {
  813. fwrite(self::$yyTraceFILE,
  814. self::$yyTracePrompt . 'Popping ' . self::$yyTokenName[$yytos->major] .
  815. "\n");
  816. }
  817. $yymajor = $yytos->major;
  818. self::yy_destructor($yymajor, $yytos->minor);
  819. $this->yyidx--;
  820. return $yymajor;
  821. }
  822. /**
  823. * Deallocate and destroy a parser. Destructors are all called for
  824. * all stack elements before shutting the parser down.
  825. */
  826. function __destruct()
  827. {
  828. while ($this->yyidx >= 0) {
  829. $this->yy_pop_parser_stack();
  830. }
  831. if (is_resource(self::$yyTraceFILE)) {
  832. fclose(self::$yyTraceFILE);
  833. }
  834. }
  835. /**
  836. * Based on the current state and parser stack, get a list of all
  837. * possible lookahead tokens
  838. * @param int
  839. * @return array
  840. */
  841. function yy_get_expected_tokens($token)
  842. {
  843. $state = $this->yystack[$this->yyidx]->stateno;
  844. $expected = self::$yyExpectedTokens[$state];
  845. if (in_array($token, self::$yyExpectedTokens[$state], true)) {
  846. return $expected;
  847. }
  848. $stack = $this->yystack;
  849. $yyidx = $this->yyidx;
  850. do {
  851. $yyact = $this->yy_find_shift_action($token);
  852. if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) {
  853. // reduce action
  854. $done = 0;
  855. do {
  856. if ($done++ == 100) {
  857. $this->yyidx = $yyidx;
  858. $this->yystack = $stack;
  859. // too much recursion prevents proper detection
  860. // so give up
  861. return array_unique($expected);
  862. }
  863. $yyruleno = $yyact - self::YYNSTATE;
  864. $this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs'];
  865. $nextstate = $this->yy_find_reduce_action(
  866. $this->yystack[$this->yyidx]->stateno,
  867. self::$yyRuleInfo[$yyruleno]['lhs']);
  868. if (isset(self::$yyExpectedTokens[$nextstate])) {
  869. $expected += self::$yyExpectedTokens[$nextstate];
  870. if (in_array($token,
  871. self::$yyExpectedTokens[$nextstate], true)) {
  872. $this->yyidx = $yyidx;
  873. $this->yystack = $stack;
  874. return array_unique($expected);
  875. }
  876. }
  877. if ($nextstate < self::YYNSTATE) {
  878. // we need to shift a non-terminal
  879. $this->yyidx++;
  880. $x = new OQLParser_yyStackEntry;
  881. $x->stateno = $nextstate;
  882. $x->major = self::$yyRuleInfo[$yyruleno]['lhs'];
  883. $this->yystack[$this->yyidx] = $x;
  884. continue 2;
  885. } elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
  886. $this->yyidx = $yyidx;
  887. $this->yystack = $stack;
  888. // the last token was just ignored, we can't accept
  889. // by ignoring input, this is in essence ignoring a
  890. // syntax error!
  891. return array_unique($expected);
  892. } elseif ($nextstate === self::YY_NO_ACTION) {
  893. $this->yyidx = $yyidx;
  894. $this->yystack = $stack;
  895. // input accepted, but not shifted (I guess)
  896. return $expected;
  897. } else {
  898. $yyact = $nextstate;
  899. }
  900. } while (true);
  901. }
  902. break;
  903. } while (true);
  904. return array_unique($expected);
  905. }
  906. /**
  907. * Based on the parser state and current parser stack, determine whether
  908. * the lookahead token is possible.
  909. *
  910. * The parser will convert the token value to an error token if not. This
  911. * catches some unusual edge cases where the parser would fail.
  912. * @param int
  913. * @return bool
  914. */
  915. function yy_is_expected_token($token)
  916. {
  917. if ($token === 0) {
  918. return true; // 0 is not part of this
  919. }
  920. $state = $this->yystack[$this->yyidx]->stateno;
  921. if (in_array($token, self::$yyExpectedTokens[$state], true)) {
  922. return true;
  923. }
  924. $stack = $this->yystack;
  925. $yyidx = $this->yyidx;
  926. do {
  927. $yyact = $this->yy_find_shift_action($token);
  928. if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) {
  929. // reduce action
  930. $done = 0;
  931. do {
  932. if ($done++ == 100) {
  933. $this->yyidx = $yyidx;
  934. $this->yystack = $stack;
  935. // too much recursion prevents proper detection
  936. // so give up
  937. return true;
  938. }
  939. $yyruleno = $yyact - self::YYNSTATE;
  940. $this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs'];
  941. $nextstate = $this->yy_find_reduce_action(
  942. $this->yystack[$this->yyidx]->stateno,
  943. self::$yyRuleInfo[$yyruleno]['lhs']);
  944. if (isset(self::$yyExpectedTokens[$nextstate]) &&
  945. in_array($token, self::$yyExpectedTokens[$nextstate], true)) {
  946. $this->yyidx = $yyidx;
  947. $this->yystack = $stack;
  948. return true;
  949. }
  950. if ($nextstate < self::YYNSTATE) {
  951. // we need to shift a non-terminal
  952. $this->yyidx++;
  953. $x = new OQLParser_yyStackEntry;
  954. $x->stateno = $nextstate;
  955. $x->major = self::$yyRuleInfo[$yyruleno]['lhs'];
  956. $this->yystack[$this->yyidx] = $x;
  957. continue 2;
  958. } elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
  959. $this->yyidx = $yyidx;
  960. $this->yystack = $stack;
  961. if (!$token) {
  962. // end of input: this is valid
  963. return true;
  964. }
  965. // the last token was just ignored, we can't accept
  966. // by ignoring input, this is in essence ignoring a
  967. // syntax error!
  968. return false;
  969. } elseif ($nextstate === self::YY_NO_ACTION) {
  970. $this->yyidx = $yyidx;
  971. $this->yystack = $stack;
  972. // input accepted, but not shifted (I guess)
  973. return true;
  974. } else {
  975. $yyact = $nextstate;
  976. }
  977. } while (true);
  978. }
  979. break;
  980. } while (true);
  981. $this->yyidx = $yyidx;
  982. $this->yystack = $stack;
  983. return true;
  984. }
  985. /**
  986. * Find the appropriate action for a parser given the terminal
  987. * look-ahead token iLookAhead.
  988. *
  989. * If the look-ahead token is YYNOCODE, then check to see if the action is
  990. * independent of the look-ahead. If it is, return the action, otherwise
  991. * return YY_NO_ACTION.
  992. * @param int The look-ahead token
  993. */
  994. function yy_find_shift_action($iLookAhead)
  995. {
  996. $stateno = $this->yystack[$this->yyidx]->stateno;
  997. /* if ($this->yyidx < 0) return self::YY_NO_ACTION; */
  998. if (!isset(self::$yy_shift_ofst[$stateno])) {
  999. // no shift actions
  1000. return self::$yy_default[$stateno];
  1001. }
  1002. $i = self::$yy_shift_ofst[$stateno];
  1003. if ($i === self::YY_SHIFT_USE_DFLT) {
  1004. return self::$yy_default[$stateno];
  1005. }
  1006. if ($iLookAhead == self::YYNOCODE) {
  1007. return self::YY_NO_ACTION;
  1008. }
  1009. $i += $iLookAhead;
  1010. if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
  1011. self::$yy_lookahead[$i] != $iLookAhead) {
  1012. if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback)
  1013. && ($iFallback = self::$yyFallback[$iLookAhead]) != 0) {
  1014. if (self::$yyTraceFILE) {
  1015. fwrite(self::$yyTraceFILE, self::$yyTracePrompt . "FALLBACK " .
  1016. self::$yyTokenName[$iLookAhead] . " => " .
  1017. self::$yyTokenName[$iFallback] . "\n");
  1018. }
  1019. return $this->yy_find_shift_action($iFallback);
  1020. }
  1021. return self::$yy_default[$stateno];
  1022. } else {
  1023. return self::$yy_action[$i];
  1024. }
  1025. }
  1026. /**
  1027. * Find the appropriate action for a parser given the non-terminal
  1028. * look-ahead token $iLookAhead.
  1029. *
  1030. * If the look-ahead token is self::YYNOCODE, then check to see if the action is
  1031. * independent of the look-ahead. If it is, return the action, otherwise
  1032. * return self::YY_NO_ACTION.
  1033. * @param int Current state number
  1034. * @param int The look-ahead token
  1035. */
  1036. function yy_find_reduce_action($stateno, $iLookAhead)
  1037. {
  1038. /* $stateno = $this->yystack[$this->yyidx]->stateno; */
  1039. if (!isset(self::$yy_reduce_ofst[$stateno])) {
  1040. return self::$yy_default[$stateno];
  1041. }
  1042. $i = self::$yy_reduce_ofst[$stateno];
  1043. if ($i == self::YY_REDUCE_USE_DFLT) {
  1044. return self::$yy_default[$stateno];
  1045. }
  1046. if ($iLookAhead == self::YYNOCODE) {
  1047. return self::YY_NO_ACTION;
  1048. }
  1049. $i += $iLookAhead;
  1050. if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
  1051. self::$yy_lookahead[$i] != $iLookAhead) {
  1052. return self::$yy_default[$stateno];
  1053. } else {
  1054. return self::$yy_action[$i];
  1055. }
  1056. }
  1057. /**
  1058. * Perform a shift action.
  1059. * @param int The new state to shift in
  1060. * @param int The major token to shift in
  1061. * @param mixed the minor token to shift in
  1062. */
  1063. function yy_shift($yyNewState, $yyMajor, $yypMinor)
  1064. {
  1065. $this->yyidx++;
  1066. if ($this->yyidx >= self::YYSTACKDEPTH) {
  1067. $this->yyidx--;
  1068. if (self::$yyTraceFILE) {
  1069. fprintf(self::$yyTraceFILE, "%sStack Overflow!\n", self::$yyTracePrompt);
  1070. }
  1071. while ($this->yyidx >= 0) {
  1072. $this->yy_pop_parser_stack();
  1073. }
  1074. /* Here code is inserted which will execute if the parser
  1075. ** stack ever overflows */
  1076. return;
  1077. }
  1078. $yytos = new OQLParser_yyStackEntry;
  1079. $yytos->stateno = $yyNewState;
  1080. $yytos->major = $yyMajor;
  1081. $yytos->minor = $yypMinor;
  1082. array_push($this->yystack, $yytos);
  1083. if (self::$yyTraceFILE && $this->yyidx > 0) {
  1084. fprintf(self::$yyTraceFILE, "%sShift %d\n", self::$yyTracePrompt,
  1085. $yyNewState);
  1086. fprintf(self::$yyTraceFILE, "%sStack:", self::$yyTracePrompt);
  1087. for ($i = 1; $i <= $this->yyidx; $i++) {
  1088. fprintf(self::$yyTraceFILE, " %s",
  1089. self::$yyTokenName[$this->yystack[$i]->major]);
  1090. }
  1091. fwrite(self::$yyTraceFILE,"\n");
  1092. }
  1093. }
  1094. /**
  1095. * The following table contains information about every rule that
  1096. * is used during the reduce.
  1097. *
  1098. * <pre>
  1099. * array(
  1100. * array(
  1101. * int $lhs; Symbol on the left-hand side of the rule
  1102. * int $nrhs; Number of right-hand side symbols in the rule
  1103. * ),...
  1104. * );
  1105. * </pre>
  1106. */
  1107. static public $yyRuleInfo = array(
  1108. array( 'lhs' => 68, 'rhs' => 1 ),
  1109. array( 'lhs' => 68, 'rhs' => 1 ),
  1110. array( 'lhs' => 69, 'rhs' => 4 ),
  1111. array( 'lhs' => 69, 'rhs' => 6 ),
  1112. array( 'lhs' => 69, 'rhs' => 6 ),
  1113. array( 'lhs' => 69, 'rhs' => 8 ),
  1114. array( 'lhs' => 74, 'rhs' => 1 ),
  1115. array( 'lhs' => 74, 'rhs' => 3 ),
  1116. array( 'lhs' => 73, 'rhs' => 2 ),
  1117. array( 'lhs' => 73, 'rhs' => 0 ),
  1118. array( 'lhs' => 72, 'rhs' => 2 ),
  1119. array( 'lhs' => 72, 'rhs' => 1 ),
  1120. array( 'lhs' => 72, 'rhs' => 0 ),
  1121. array( 'lhs' => 75, 'rhs' => 6 ),
  1122. array( 'lhs' => 75, 'rhs' => 4 ),
  1123. array( 'lhs' => 76, 'rhs' => 3 ),
  1124. array( 'lhs' => 76, 'rhs' => 3 ),
  1125. array( 'lhs' => 76, 'rhs' => 3 ),
  1126. array( 'lhs' => 76, 'rhs' => 3 ),
  1127. array( 'lhs' => 76, 'rhs' => 3 ),
  1128. array( 'lhs' => 76, 'rhs' => 3 ),
  1129. array( 'lhs' => 76, 'rhs' => 3 ),
  1130. array( 'lhs' => 76, 'rhs' => 3 ),
  1131. array( 'lhs' => 76, 'rhs' => 3 ),
  1132. array( 'lhs' => 70, 'rhs' => 1 ),
  1133. array( 'lhs' => 79, 'rhs' => 1 ),
  1134. array( 'lhs' => 79, 'rhs' => 1 ),
  1135. array( 'lhs' => 79, 'rhs' => 1 ),
  1136. array( 'lhs' => 79, 'rhs' => 4 ),
  1137. array( 'lhs' => 79, 'rhs' => 3 ),
  1138. array( 'lhs' => 79, 'rhs' => 3 ),
  1139. array( 'lhs' => 86, 'rhs' => 1 ),
  1140. array( 'lhs' => 86, 'rhs' => 3 ),
  1141. array( 'lhs' => 88, 'rhs' => 1 ),
  1142. array( 'lhs' => 88, 'rhs' => 3 ),
  1143. array( 'lhs' => 90, 'rhs' => 1 ),
  1144. array( 'lhs' => 90, 'rhs' => 3 ),
  1145. array( 'lhs' => 78, 'rhs' => 1 ),
  1146. array( 'lhs' => 78, 'rhs' => 3 ),
  1147. array( 'lhs' => 85, 'rhs' => 3 ),
  1148. array( 'lhs' => 93, 'rhs' => 1 ),
  1149. array( 'lhs' => 93, 'rhs' => 3 ),
  1150. array( 'lhs' => 83, 'rhs' => 0 ),
  1151. array( 'lhs' => 83, 'rhs' => 1 ),
  1152. array( 'lhs' => 83, 'rhs' => 3 ),
  1153. array( 'lhs' => 94, 'rhs' => 1 ),
  1154. array( 'lhs' => 94, 'rhs' => 3 ),
  1155. array( 'lhs' => 95, 'rhs' => 1 ),
  1156. array( 'lhs' => 95, 'rhs' => 1 ),
  1157. array( 'lhs' => 95, 'rhs' => 1 ),
  1158. array( 'lhs' => 95, 'rhs' => 1 ),
  1159. array( 'lhs' => 95, 'rhs' => 1 ),
  1160. array( 'lhs' => 95, 'rhs' => 1 ),
  1161. array( 'lhs' => 80, 'rhs' => 1 ),
  1162. array( 'lhs' => 80, 'rhs' => 1 ),
  1163. array( 'lhs' => 96, 'rhs' => 1 ),
  1164. array( 'lhs' => 97, 'rhs' => 1 ),
  1165. array( 'lhs' => 77, 'rhs' => 1 ),
  1166. array( 'lhs' => 77, 'rhs' => 3 ),
  1167. array( 'lhs' => 71, 'rhs' => 1 ),
  1168. array( 'lhs' => 81, 'rhs' => 1 ),
  1169. array( 'lhs' => 100, 'rhs' => 1 ),
  1170. array( 'lhs' => 98, 'rhs' => 1 ),
  1171. array( 'lhs' => 99, 'rhs' => 1 ),
  1172. array( 'lhs' => 87, 'rhs' => 1 ),
  1173. array( 'lhs' => 89, 'rhs' => 1 ),
  1174. array( 'lhs' => 89, 'rhs' => 1 ),
  1175. array( 'lhs' => 89, 'rhs' => 1 ),
  1176. array( 'lhs' => 89, 'rhs' => 1 ),
  1177. array( 'lhs' => 89, 'rhs' => 1 ),
  1178. array( 'lhs' => 91, 'rhs' => 1 ),
  1179. array( 'lhs' => 92, 'rhs' => 1 ),
  1180. array( 'lhs' => 101, 'rhs' => 1 ),
  1181. array( 'lhs' => 101, 'rhs' => 1 ),
  1182. array( 'lhs' => 102, 'rhs' => 1 ),
  1183. array( 'lhs' => 102, 'rhs' => 1 ),
  1184. array( 'lhs' => 102, 'rhs' => 1 ),
  1185. array( 'lhs' => 102, 'rhs' => 1 ),
  1186. array( 'lhs' => 102, 'rhs' => 1 ),
  1187. array( 'lhs' => 102, 'rhs' => 1 ),
  1188. array( 'lhs' => 103, 'rhs' => 1 ),
  1189. array( 'lhs' => 103, 'rhs' => 1 ),
  1190. array( 'lhs' => 84, 'rhs' => 1 ),
  1191. array( 'lhs' => 84, 'rhs' => 1 ),
  1192. array( 'lhs' => 82, 'rhs' => 1 ),
  1193. array( 'lhs' => 82, 'rhs' => 1 ),
  1194. array( 'lhs' => 82, 'rhs' => 1 ),
  1195. array( 'lhs' => 82, 'rhs' => 1 ),
  1196. array( 'lhs' => 82, 'rhs' => 1 ),
  1197. array( 'lhs' => 82, 'rhs' => 1 ),
  1198. array( 'lhs' => 82, 'rhs' => 1 ),
  1199. array( 'lhs' => 82, 'rhs' => 1 ),
  1200. array( 'lhs' => 82, 'rhs' => 1 ),
  1201. array( 'lhs' => 82, 'rhs' => 1 ),
  1202. array( 'lhs' => 82, 'rhs' => 1 ),
  1203. array( 'lhs' => 82, 'rhs' => 1 ),
  1204. array( 'lhs' => 82, 'rhs' => 1 ),
  1205. array( 'lhs' => 82, 'rhs' => 1 ),
  1206. array( 'lhs' => 82, 'rhs' => 1 ),
  1207. array( 'lhs' => 82, 'rhs' => 1 ),
  1208. array( 'lhs' => 82, 'rhs' => 1 ),
  1209. array( 'lhs' => 82, 'rhs' => 1 ),
  1210. array( 'lhs' => 82, 'rhs' => 1 ),
  1211. array( 'lhs' => 82, 'rhs' => 1 ),
  1212. array( 'lhs' => 82, 'rhs' => 1 ),
  1213. array( 'lhs' => 82, 'rhs' => 1 ),
  1214. array( 'lhs' => 82, 'rhs' => 1 ),
  1215. );
  1216. /**
  1217. * The following table contains a mapping of reduce action to method name
  1218. * that handles the reduction.
  1219. *
  1220. * If a rule is not set, it has no handler.
  1221. */
  1222. static public $yyReduceMap = array(
  1223. 0 => 0,
  1224. 1 => 0,
  1225. 2 => 2,
  1226. 3 => 3,
  1227. 4 => 4,
  1228. 5 => 5,
  1229. 6 => 6,
  1230. 40 => 6,
  1231. 43 => 6,
  1232. 7 => 7,
  1233. 41 => 7,
  1234. 44 => 7,
  1235. 8 => 8,
  1236. 9 => 9,
  1237. 12 => 9,
  1238. 10 => 10,
  1239. 11 => 11,
  1240. 13 => 13,
  1241. 14 => 14,
  1242. 15 => 15,
  1243. 16 => 16,
  1244. 17 => 17,
  1245. 18 => 18,
  1246. 19 => 19,
  1247. 20 => 20,
  1248. 21 => 21,
  1249. 22 => 22,
  1250. 23 => 23,
  1251. 24 => 24,
  1252. 25 => 24,
  1253. 26 => 24,
  1254. 27 => 24,
  1255. 31 => 24,
  1256. 33 => 24,
  1257. 35 => 24,
  1258. 37 => 24,
  1259. 45 => 24,
  1260. 47 => 24,
  1261. 48 => 24,
  1262. 49 => 24,
  1263. 50 => 24,
  1264. 51 => 24,
  1265. 52 => 24,
  1266. 53 => 24,
  1267. 54 => 24,
  1268. 28 => 28,
  1269. 29 => 29,
  1270. 30 => 30,
  1271. 32 => 30,
  1272. 34 => 30,
  1273. 36 => 30,
  1274. 38 => 30,
  1275. 39 => 39,
  1276. 42 => 42,
  1277. 46 => 46,
  1278. 55 => 55,
  1279. 56 => 55,
  1280. 57 => 57,
  1281. 58 => 58,
  1282. 59 => 59,
  1283. 84 => 59,
  1284. 85 => 59,
  1285. 86 => 59,
  1286. 87 => 59,
  1287. 88 => 59,
  1288. 89 => 59,
  1289. 90 => 59,
  1290. 91 => 59,
  1291. 92 => 59,
  1292. 93 => 59,
  1293. 94 => 59,
  1294. 95 => 59,
  1295. 96 => 59,
  1296. 97 => 59,
  1297. 98 => 59,
  1298. 99 => 59,
  1299. 100 => 59,
  1300. 101 => 59,
  1301. 102 => 59,
  1302. 103 => 59,
  1303. 104 => 59,
  1304. 105 => 59,
  1305. 106 => 59,
  1306. 60 => 60,
  1307. 61 => 61,
  1308. 62 => 62,
  1309. 64 => 62,
  1310. 65 => 62,
  1311. 66 => 62,
  1312. 67 => 62,
  1313. 68 => 62,
  1314. 69 => 62,
  1315. 70 => 62,
  1316. 71 => 62,
  1317. 72 => 62,
  1318. 73 => 62,
  1319. 74 => 62,
  1320. 75 => 62,
  1321. 76 => 62,
  1322. 77 => 62,
  1323. 78 => 62,
  1324. 79 => 62,
  1325. 80 => 62,
  1326. 81 => 62,
  1327. 82 => 62,
  1328. 83 => 62,
  1329. 63 => 63,
  1330. );
  1331. /* Beginning here are the reduction cases. A typical example
  1332. ** follows:
  1333. ** #line <lineno> <grammarfile>
  1334. ** function yy_r0($yymsp){ ... } // User supplied code
  1335. ** #line <lineno> <thisfile>
  1336. */
  1337. #line 29 "oql-parser.y"
  1338. function yy_r0(){ $this->my_result = $this->yystack[$this->yyidx + 0]->minor; }
  1339. #line 1372 "oql-parser.php"
  1340. #line 32 "oql-parser.y"
  1341. function yy_r2(){
  1342. $this->_retvalue = new OqlObjectQuery($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor, array($this->yystack[$this->yyidx + -2]->minor));
  1343. }
  1344. #line 1377 "oql-parser.php"
  1345. #line 35 "oql-parser.y"
  1346. function yy_r3(){
  1347. $this->_retvalue = new OqlObjectQuery($this->yystack[$this->yyidx + -4]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor, array($this->yystack[$this->yyidx + -2]->minor));
  1348. }
  1349. #line 1382 "oql-parser.php"
  1350. #line 39 "oql-parser.y"
  1351. function yy_r4(){
  1352. $this->_retvalue = new OqlObjectQuery($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + -4]->minor);
  1353. }
  1354. #line 1387 "oql-parser.php"
  1355. #line 42 "oql-parser.y"
  1356. function yy_r5(){
  1357. $this->_retvalue = new OqlObjectQuery($this->yystack[$this->yyidx + -4]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + -6]->minor);
  1358. }
  1359. #line 1392 "oql-parser.php"
  1360. #line 47 "oql-parser.y"
  1361. function yy_r6(){
  1362. $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor);
  1363. }
  1364. #line 1397 "oql-parser.php"
  1365. #line 50 "oql-parser.y"
  1366. function yy_r7(){
  1367. array_push($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor);
  1368. $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor;
  1369. }
  1370. #line 1403 "oql-parser.php"
  1371. #line 55 "oql-parser.y"
  1372. function yy_r8(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
  1373. #line 1406 "oql-parser.php"
  1374. #line 56 "oql-parser.y"
  1375. function yy_r9(){ $this->_retvalue = null; }
  1376. #line 1409 "oql-parser.php"
  1377. #line 58 "oql-parser.y"
  1378. function yy_r10(){
  1379. // insert the join statement on top of the existing list
  1380. array_unshift($this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor);
  1381. // and return the updated array
  1382. $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
  1383. }
  1384. #line 1417 "oql-parser.php"
  1385. #line 64 "oql-parser.y"
  1386. function yy_r11(){
  1387. $this->_retvalue = Array($this->yystack[$this->yyidx + 0]->minor);
  1388. }
  1389. #line 1422 "oql-parser.php"
  1390. #line 70 "oql-parser.y"
  1391. function yy_r13(){
  1392. // create an array with one single item
  1393. $this->_retvalue = new OqlJoinSpec($this->yystack[$this->yyidx + -4]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor);
  1394. }
  1395. #line 1428 "oql-parser.php"
  1396. #line 75 "oql-parser.y"
  1397. function yy_r14(){
  1398. // create an array with one single item
  1399. $this->_retvalue = new OqlJoinSpec($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor);
  1400. }
  1401. #line 1434 "oql-parser.php"
  1402. #line 80 "oql-parser.y"
  1403. function yy_r15(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, '=', $this->yystack[$this->yyidx + 0]->minor); }
  1404. #line 1437 "oql-parser.php"
  1405. #line 81 "oql-parser.y"
  1406. function yy_r16(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'BELOW', $this->yystack[$this->yyidx + 0]->minor); }
  1407. #line 1440 "oql-parser.php"
  1408. #line 82 "oql-parser.y"
  1409. function yy_r17(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'BELOW_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
  1410. #line 1443 "oql-parser.php"
  1411. #line 83 "oql-parser.y"
  1412. function yy_r18(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_BELOW', $this->yystack[$this->yyidx + 0]->minor); }
  1413. #line 1446 "oql-parser.php"
  1414. #line 84 "oql-parser.y"
  1415. function yy_r19(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_BELOW_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
  1416. #line 1449 "oql-parser.php"
  1417. #line 85 "oql-parser.y"
  1418. function yy_r20(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'ABOVE', $this->yystack[$this->yyidx + 0]->minor); }
  1419. #line 1452 "oql-parser.php"
  1420. #line 86 "oql-parser.y"
  1421. function yy_r21(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'ABOVE_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
  1422. #line 1455 "oql-parser.php"
  1423. #line 87 "oql-parser.y"
  1424. function yy_r22(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_ABOVE', $this->yystack[$this->yyidx + 0]->minor); }
  1425. #line 1458 "oql-parser.php"
  1426. #line 88 "oql-parser.y"
  1427. function yy_r23(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, 'NOT_ABOVE_STRICT', $this->yystack[$this->yyidx + 0]->minor); }
  1428. #line 1461 "oql-parser.php"
  1429. #line 90 "oql-parser.y"
  1430. function yy_r24(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
  1431. #line 1464 "oql-parser.php"
  1432. #line 95 "oql-parser.y"
  1433. function yy_r28(){ $this->_retvalue = new FunctionOqlExpression($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + -1]->minor); }
  1434. #line 1467 "oql-parser.php"
  1435. #line 96 "oql-parser.y"
  1436. function yy_r29(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; }
  1437. #line 1470 "oql-parser.php"
  1438. #line 97 "oql-parser.y"
  1439. function yy_r30(){ $this->_retvalue = new BinaryOqlExpression($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor); }
  1440. #line 1473 "oql-parser.php"
  1441. #line 112 "oql-parser.y"
  1442. function yy_r39(){
  1443. $this->_retvalue = new ListOqlExpression($this->yystack[$this->yyidx + -1]->minor);
  1444. }
  1445. #line 1478 "oql-parser.php"
  1446. #line 123 "oql-parser.y"
  1447. function yy_r42(){
  1448. $this->_retvalue = array();
  1449. }
  1450. #line 1483 "oql-parser.php"
  1451. #line 134 "oql-parser.y"
  1452. function yy_r46(){ $this->_retvalue = new IntervalOqlExpression($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor); }
  1453. #line 1486 "oql-parser.php"
  1454. #line 146 "oql-parser.y"
  1455. function yy_r55(){ $this->_retvalue = new ScalarOqlExpression($this->yystack[$this->yyidx + 0]->minor); }
  1456. #line 1489 "oql-parser.php"
  1457. #line 149 "oql-parser.y"
  1458. function yy_r57(){ $this->_retvalue = new FieldOqlExpression($this->yystack[$this->yyidx + 0]->minor); }
  1459. #line 1492 "oql-parser.php"
  1460. #line 150 "oql-parser.y"
  1461. function yy_r58(){ $this->_retvalue = new FieldOqlExpression($this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -2]->minor); }
  1462. #line 1495 "oql-parser.php"
  1463. #line 151 "oql-parser.y"
  1464. function yy_r59(){ $this->_retvalue=$this->yystack[$this->yyidx + 0]->minor; }
  1465. #line 1498 "oql-parser.php"
  1466. #line 154 "oql-parser.y"
  1467. function yy_r60(){ $this->_retvalue = new VariableOqlExpression(substr($this->yystack[$this->yyidx + 0]->minor, 1)); }
  1468. #line 1501 "oql-parser.php"
  1469. #line 156 "oql-parser.y"
  1470. function yy_r61(){
  1471. if ($this->yystack[$this->yyidx + 0]->minor[0] == '`')
  1472. {
  1473. $name = substr($this->yystack[$this->yyidx + 0]->minor, 1, strlen($this->yystack[$this->yyidx + 0]->minor) - 2);
  1474. }
  1475. else
  1476. {
  1477. $name = $this->yystack[$this->yyidx + 0]->minor;
  1478. }
  1479. $this->_retvalue = new OqlName($name, $this->m_iColPrev);
  1480. }
  1481. #line 1514 "oql-parser.php"
  1482. #line 168 "oql-parser.y"
  1483. function yy_r62(){$this->_retvalue=$this->yystack[$this->yyidx + 0]->minor; }
  1484. #line 1517 "oql-parser.php"
  1485. #line 169 "oql-parser.y"
  1486. function yy_r63(){$this->_retvalue=stripslashes(substr($this->yystack[$this->yyidx + 0]->minor, 1, strlen($this->yystack[$this->yyidx + 0]->minor) - 2)); }
  1487. #line 1520 "oql-parser.php"
  1488. /**
  1489. * placeholder for the left hand side in a reduce operation.
  1490. *
  1491. * For a parser with a rule like this:
  1492. * <pre>
  1493. * rule(A) ::= B. { A = 1; }
  1494. * </pre>
  1495. *
  1496. * The parser will translate to something like:
  1497. *
  1498. * <code>
  1499. * function yy_r0(){$this->_retvalue = 1;}
  1500. * </code>
  1501. */
  1502. private $_retvalue;
  1503. /**
  1504. * Perform a reduce action and the shift that must immediately
  1505. * follow the reduce.
  1506. *
  1507. * For a rule such as:
  1508. *
  1509. * <pre>
  1510. * A ::= B blah C. { dosomething(); }
  1511. * </pre>
  1512. *
  1513. * This function will first call the action, if any, ("dosomething();" in our
  1514. * example), and then it will pop three states from the stack,
  1515. * one for each entry on the right-hand side of the expression
  1516. * (B, blah, and C in our example rule), and then push the result of the action
  1517. * back on to the stack with the resulting state reduced to (as described in the .out
  1518. * file)
  1519. * @param int Number of the rule by which to reduce
  1520. */
  1521. function yy_reduce($yyruleno)
  1522. {
  1523. //int $yygoto; /* The next state */
  1524. //int $yyact; /* The next action */
  1525. //mixed $yygotominor; /* The LHS of the rule reduced */
  1526. //OQLParser_yyStackEntry $yymsp; /* The top of the parser's stack */
  1527. //int $yysize; /* Amount to pop the stack */
  1528. $yymsp = $this->yystack[$this->yyidx];
  1529. if (self::$yyTraceFILE && $yyruleno >= 0
  1530. && $yyruleno < count(self::$yyRuleName)) {
  1531. fprintf(self::$yyTraceFILE, "%sReduce (%d) [%s].\n",
  1532. self::$yyTracePrompt, $yyruleno,
  1533. self::$yyRuleName[$yyruleno]);
  1534. }
  1535. $this->_retvalue = $yy_lefthand_side = null;
  1536. if (array_key_exists($yyruleno, self::$yyReduceMap)) {
  1537. // call the action
  1538. $this->_retvalue = null;
  1539. $this->{'yy_r' . self::$yyReduceMap[$yyruleno]}();
  1540. $yy_lefthand_side = $this->_retvalue;
  1541. }
  1542. $yygoto = self::$yyRuleInfo[$yyruleno]['lhs'];
  1543. $yysize = self::$yyRuleInfo[$yyruleno]['rhs'];
  1544. $this->yyidx -= $yysize;
  1545. for ($i = $yysize; $i; $i--) {
  1546. // pop all of the right-hand side parameters
  1547. array_pop($this->yystack);
  1548. }
  1549. $yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto);
  1550. if ($yyact < self::YYNSTATE) {
  1551. /* If we are not debugging and the reduce action popped at least
  1552. ** one element off the stack, then we can push the new element back
  1553. ** onto the stack here, and skip the stack overflow test in yy_shift().
  1554. ** That gives a significant speed improvement. */
  1555. if (!self::$yyTraceFILE && $yysize) {
  1556. $this->yyidx++;
  1557. $x = new OQLParser_yyStackEntry;
  1558. $x->stateno = $yyact;
  1559. $x->major = $yygoto;
  1560. $x->minor = $yy_lefthand_side;
  1561. $this->yystack[$this->yyidx] = $x;
  1562. } else {
  1563. $this->yy_shift($yyact, $yygoto, $yy_lefthand_side);
  1564. }
  1565. } elseif ($yyact == self::YYNSTATE + self::YYNRULE + 1) {
  1566. $this->yy_accept();
  1567. }
  1568. }
  1569. /**
  1570. * The following code executes when the parse fails
  1571. *
  1572. * Code from %parse_fail is inserted here
  1573. */
  1574. function yy_parse_failed()
  1575. {
  1576. if (self::$yyTraceFILE) {
  1577. fprintf(self::$yyTraceFILE, "%sFail!\n", self::$yyTracePrompt);
  1578. }
  1579. while ($this->yyidx >= 0) {
  1580. $this->yy_pop_parser_stack();
  1581. }
  1582. /* Here code is inserted which will be executed whenever the
  1583. ** parser fails */
  1584. }
  1585. /**
  1586. * The following code executes when a syntax error first occurs.
  1587. *
  1588. * %syntax_error code is inserted here
  1589. * @param int The major type of the error token
  1590. * @param mixed The minor type of the error token
  1591. */
  1592. function yy_syntax_error($yymajor, $TOKEN)
  1593. {
  1594. #line 25 "oql-parser.y"
  1595. throw new OQLParserException($this->m_sSourceQuery, $this->m_iLine, $this->m_iCol, $this->tokenName($yymajor), $TOKEN);
  1596. #line 1636 "oql-parser.php"
  1597. }
  1598. /**
  1599. * The following is executed when the parser accepts
  1600. *
  1601. * %parse_accept code is inserted here
  1602. */
  1603. function yy_accept()
  1604. {
  1605. if (self::$yyTraceFILE) {
  1606. fprintf(self::$yyTraceFILE, "%sAccept!\n", self::$yyTracePrompt);
  1607. }
  1608. while ($this->yyidx >= 0) {
  1609. $stack = $this->yy_pop_parser_stack();
  1610. }
  1611. /* Here code is inserted which will be executed whenever the
  1612. ** parser accepts */
  1613. }
  1614. /**
  1615. * The main parser program.
  1616. *
  1617. * The first argument is the major token number. The second is
  1618. * the token value string as scanned from the input.
  1619. *
  1620. * @param int $yymajor the token number
  1621. * @param mixed $yytokenvalue the token value
  1622. * @param mixed ... any extra arguments that should be passed to handlers
  1623. *
  1624. * @return void
  1625. */
  1626. function doParse($yymajor, $yytokenvalue)
  1627. {
  1628. // $yyact; /* The parser action. */
  1629. // $yyendofinput; /* True if we are at the end of input */
  1630. $yyerrorhit = 0; /* True if yymajor has invoked an error */
  1631. /* (re)initialize the parser, if necessary */
  1632. if ($this->yyidx === null || $this->yyidx < 0) {
  1633. /* if ($yymajor == 0) return; // not sure why this was here... */
  1634. $this->yyidx = 0;
  1635. $this->yyerrcnt = -1;
  1636. $x = new OQLParser_yyStackEntry;
  1637. $x->stateno = 0;
  1638. $x->major = 0;
  1639. $this->yystack = array();
  1640. array_push($this->yystack, $x);
  1641. }
  1642. $yyendofinput = ($yymajor==0);
  1643. if (self::$yyTraceFILE) {
  1644. fprintf(
  1645. self::$yyTraceFILE,
  1646. "%sInput %s\n",
  1647. self::$yyTracePrompt,
  1648. self::$yyTokenName[$yymajor]
  1649. );
  1650. }
  1651. do {
  1652. $yyact = $this->yy_find_shift_action($yymajor);
  1653. if ($yymajor < self::YYERRORSYMBOL
  1654. && !$this->yy_is_expected_token($yymajor)
  1655. ) {
  1656. // force a syntax error
  1657. $yyact = self::YY_ERROR_ACTION;
  1658. }
  1659. if ($yyact < self::YYNSTATE) {
  1660. $this->yy_shift($yyact, $yymajor, $yytokenvalue);
  1661. $this->yyerrcnt--;
  1662. if ($yyendofinput && $this->yyidx >= 0) {
  1663. $yymajor = 0;
  1664. } else {
  1665. $yymajor = self::YYNOCODE;
  1666. }
  1667. } elseif ($yyact < self::YYNSTATE + self::YYNRULE) {
  1668. $this->yy_reduce($yyact - self::YYNSTATE);
  1669. } elseif ($yyact == self::YY_ERROR_ACTION) {
  1670. if (self::$yyTraceFILE) {
  1671. fprintf(
  1672. self::$yyTraceFILE,
  1673. "%sSyntax Error!\n",
  1674. self::$yyTracePrompt
  1675. );
  1676. }
  1677. if (self::YYERRORSYMBOL) {
  1678. /* A syntax error has occurred.
  1679. ** The response to an error depends upon whether or not the
  1680. ** grammar defines an error token "ERROR".
  1681. **
  1682. ** This is what we do if the grammar does define ERROR:
  1683. **
  1684. ** * Call the %syntax_error function.
  1685. **
  1686. ** * Begin popping the stack until we enter a state where
  1687. ** it is legal to shift the error symbol, then shift
  1688. ** the error symbol.
  1689. **
  1690. ** * Set the error count to three.
  1691. **
  1692. ** * Begin accepting and shifting new tokens. No new error
  1693. ** processing will occur until three tokens have been
  1694. ** shifted successfully.
  1695. **
  1696. */
  1697. if ($this->yyerrcnt < 0) {
  1698. $this->yy_syntax_error($yymajor, $yytokenvalue);
  1699. }
  1700. $yymx = $this->yystack[$this->yyidx]->major;
  1701. if ($yymx == self::YYERRORSYMBOL || $yyerrorhit ) {
  1702. if (self::$yyTraceFILE) {
  1703. fprintf(
  1704. self::$yyTraceFILE,
  1705. "%sDiscard input token %s\n",
  1706. self::$yyTracePrompt,
  1707. self::$yyTokenName[$yymajor]
  1708. );
  1709. }
  1710. $this->yy_destructor($yymajor, $yytokenvalue);
  1711. $yymajor = self::YYNOCODE;
  1712. } else {
  1713. while ($this->yyidx >= 0
  1714. && $yymx != self::YYERRORSYMBOL
  1715. && ($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE
  1716. ) {
  1717. $this->yy_pop_parser_stack();
  1718. }
  1719. if ($this->yyidx < 0 || $yymajor==0) {
  1720. $this->yy_destructor($yymajor, $yytokenvalue);
  1721. $this->yy_parse_failed();
  1722. $yymajor = self::YYNOCODE;
  1723. } elseif ($yymx != self::YYERRORSYMBOL) {
  1724. $u2 = 0;
  1725. $this->yy_shift($yyact, self::YYERRORSYMBOL, $u2);
  1726. }
  1727. }
  1728. $this->yyerrcnt = 3;
  1729. $yyerrorhit = 1;
  1730. } else {
  1731. /* YYERRORSYMBOL is not defined */
  1732. /* This is what we do if the grammar does not define ERROR:
  1733. **
  1734. ** * Report an error message, and throw away the input token.
  1735. **
  1736. ** * If the input token is $, then fail the parse.
  1737. **
  1738. ** As before, subsequent error messages are suppressed until
  1739. ** three input tokens have been successfully shifted.
  1740. */
  1741. if ($this->yyerrcnt <= 0) {
  1742. $this->yy_syntax_error($yymajor, $yytokenvalue);
  1743. }
  1744. $this->yyerrcnt = 3;
  1745. $this->yy_destructor($yymajor, $yytokenvalue);
  1746. if ($yyendofinput) {
  1747. $this->yy_parse_failed();
  1748. }
  1749. $yymajor = self::YYNOCODE;
  1750. }
  1751. } else {
  1752. $this->yy_accept();
  1753. $yymajor = self::YYNOCODE;
  1754. }
  1755. } while ($yymajor != self::YYNOCODE && $this->yyidx >= 0);
  1756. }
  1757. }
  1758. #line 221 "oql-parser.y"
  1759. class OQLParserException extends OQLException
  1760. {
  1761. public function __construct($sInput, $iLine, $iCol, $sTokenName, $sTokenValue)
  1762. {
  1763. $sIssue = "Unexpected token $sTokenName";
  1764. parent::__construct($sIssue, $sInput, $iLine, $iCol, $sTokenValue);
  1765. }
  1766. }
  1767. class OQLParser extends OQLParserRaw
  1768. {
  1769. // dirty, but working for us (no other mean to get the final result :-(
  1770. protected $my_result;
  1771. public function GetResult()
  1772. {
  1773. return $this->my_result;
  1774. }
  1775. // More info on the source query and the current position while parsing it
  1776. // Data used when an exception is raised
  1777. protected $m_iLine; // still not used
  1778. protected $m_iCol;
  1779. protected $m_iColPrev; // this is the interesting one, because the parser will reduce on the next token
  1780. protected $m_sSourceQuery;
  1781. public function __construct($sQuery)
  1782. {
  1783. $this->m_iLine = 0;
  1784. $this->m_iCol = 0;
  1785. $this->m_iColPrev = 0;
  1786. $this->m_sSourceQuery = $sQuery;
  1787. // no constructor - parent::__construct();
  1788. }
  1789. public function doParse($token, $value, $iCurrPosition = 0)
  1790. {
  1791. $this->m_iColPrev = $this->m_iCol;
  1792. $this->m_iCol = $iCurrPosition;
  1793. return parent::DoParse($token, $value);
  1794. }
  1795. public function doFinish()
  1796. {
  1797. $this->doParse(0, 0);
  1798. return $this->my_result;
  1799. }
  1800. public function __destruct()
  1801. {
  1802. // Bug in the original destructor, causing an infinite loop !
  1803. // This is a real issue when a fatal error occurs on the first token (the error could not be seen)
  1804. if (is_null($this->yyidx))
  1805. {
  1806. $this->yyidx = -1;
  1807. }
  1808. parent::__destruct();
  1809. }
  1810. }
  1811. #line 1869 "oql-parser.php"