oql-parser.php 66 KB

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