oql-parser.php 65 KB

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