oql-parser.php 67 KB

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