oql-parser.php 66 KB

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