oql-parser.php 72 KB

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