oql-parser.php 69 KB

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