oql-parser.php 68 KB

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