oql-parser.php 65 KB

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