PageRenderTime 65ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/lib/a2s/svg-path.php

https://bitbucket.org/yoander/mtrack
PHP | 890 lines | 542 code | 38 blank | 310 comment | 64 complexity | 6f5d78be21dba258bb86db62f90ae134 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0
  1. <?php # vim:ts=2:sw=2:et:
  2. /* Driver template for the LEMON parser generator.
  3. ** The author disclaims copyright to this source code.
  4. */
  5. /* First off, code is included which follows the "include" declaration
  6. ** in the input file. */
  7. /* The following structure represents a single element of the
  8. ** parser's stack. Information stored includes:
  9. **
  10. ** + The state number for the parser at this level of the stack.
  11. **
  12. ** + The value of the token stored at this level of the stack.
  13. ** (In other words, the "major" token.)
  14. **
  15. ** + The semantic value stored at this level of the stack. This is
  16. ** the information used by the action routines in the grammar.
  17. ** It is sometimes called the "minor" token.
  18. */
  19. class A2S_SVGPathyyStackEntry {
  20. var /* int */ $stateno; /* The state-number */
  21. var /* int */ $major; /* The major token value. This is the code
  22. ** number for the token at this stack level */
  23. var $minor; /* The user-supplied minor token value. This
  24. ** is the value of the token */
  25. };
  26. /* The state of the parser is completely contained in an instance of
  27. ** the following structure */
  28. class A2S_SVGPathParser {
  29. var /* int */ $yyidx = -1; /* Index of top element in stack */
  30. var /* int */ $yyerrcnt; /* Shifts left before out of the error */
  31. // A2S_SVGPathARG_SDECL /* A place to hold %extra_argument */
  32. var /* yyStackEntry */ $yystack = array(
  33. /* of YYSTACKDEPTH elements */
  34. ); /* The parser's stack */
  35. var $yyTraceFILE = null;
  36. var $yyTracePrompt = null;
  37. /* Next is all token values, in a form suitable for use by makeheaders.
  38. ** This section will be null unless lemon is run with the -m switch.
  39. */
  40. /*
  41. ** These constants (all generated automatically by the parser generator)
  42. ** specify the various kinds of tokens (terminals) that the parser
  43. ** understands.
  44. **
  45. ** Each symbol here is a terminal symbol in the grammar.
  46. */
  47. const TK_ANY = 1;
  48. const TK_MCMD = 2;
  49. const TK_ZCMD = 3;
  50. const TK_LCMD = 4;
  51. const TK_HCMD = 5;
  52. const TK_VCMD = 6;
  53. const TK_CCMD = 7;
  54. const TK_SCMD = 8;
  55. const TK_QCMD = 9;
  56. const TK_TCMD = 10;
  57. const TK_ACMD = 11;
  58. const TK_POSNUM = 12;
  59. const TK_FLAG = 13;
  60. const TK_NEGNUM = 14;
  61. /* The next thing included is series of defines which control
  62. ** various aspects of the generated parser.
  63. ** YYCODETYPE is the data type used for storing terminal
  64. ** and nonterminal numbers. "unsigned char" is
  65. ** used if there are fewer than 250 terminals
  66. ** and nonterminals. "int" is used otherwise.
  67. ** YYNOCODE is a number of type YYCODETYPE which corresponds
  68. ** to no legal terminal or nonterminal number. This
  69. ** number is used to fill in empty slots of the hash
  70. ** table.
  71. ** YYFALLBACK If defined, this indicates that one or more tokens
  72. ** have fall-back values which should be used if the
  73. ** original value of the token will not parse.
  74. ** YYACTIONTYPE is the data type used for storing terminal
  75. ** and nonterminal numbers. "unsigned char" is
  76. ** used if there are fewer than 250 rules and
  77. ** states combined. "int" is used otherwise.
  78. ** A2S_SVGPathTOKENTYPE is the data type used for minor tokens given
  79. ** directly to the parser from the tokenizer.
  80. ** YYMINORTYPE is the data type used for all minor tokens.
  81. ** This is typically a union of many types, one of
  82. ** which is A2S_SVGPathTOKENTYPE. The entry in the union
  83. ** for base tokens is called "yy0".
  84. ** YYSTACKDEPTH is the maximum depth of the parser's stack.
  85. ** A2S_SVGPathARG_SDECL A static variable declaration for the %extra_argument
  86. ** A2S_SVGPathARG_PDECL A parameter declaration for the %extra_argument
  87. ** A2S_SVGPathARG_STORE Code to store %extra_argument into yypParser
  88. ** A2S_SVGPathARG_FETCH Code to extract %extra_argument from yypParser
  89. ** YYNSTATE the combined number of states.
  90. ** YYNRULE the number of rules in the grammar
  91. ** YYERRORSYMBOL is the code number of the error symbol. If not
  92. ** defined, then do no error processing.
  93. */
  94. const YYNOCODE = 48;
  95. const YYWILDCARD = 1;
  96. #define A2S_SVGPathTOKENTYPE void*
  97. const YYSTACKDEPTH = 100;
  98. const YYNSTATE = 74;
  99. const YYNRULE = 52;
  100. const YYERRORSYMBOL = 15;
  101. /* since we cant use expressions to initialize these as class
  102. * constants, we do so during parser init. */
  103. var $YY_NO_ACTION;
  104. var $YY_ACCEPT_ACTION;
  105. var $YY_ERROR_ACTION;
  106. /* Next are that tables used to determine what action to take based on the
  107. ** current state and lookahead token. These tables are used to implement
  108. ** functions that take a state number and lookahead value and return an
  109. ** action integer.
  110. **
  111. ** Suppose the action integer is N. Then the action is determined as
  112. ** follows
  113. **
  114. ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
  115. ** token onto the stack and goto state N.
  116. **
  117. ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
  118. **
  119. ** N == YYNSTATE+YYNRULE A syntax error has occurred.
  120. **
  121. ** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
  122. **
  123. ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
  124. ** slots in the yy_action[] table.
  125. **
  126. ** The action table is constructed as a single large table named yy_action[].
  127. ** Given state S and lookahead X, the action is computed as
  128. **
  129. ** yy_action[ yy_shift_ofst[S] + X ]
  130. **
  131. ** If the index value yy_shift_ofst[S]+X is out of range or if the value
  132. ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
  133. ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
  134. ** and that yy_default[S] should be used instead.
  135. **
  136. ** The formula above is for computing the action when the lookahead is
  137. ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
  138. ** a reduce action) then the yy_reduce_ofst[] array is used in place of
  139. ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
  140. ** YY_SHIFT_USE_DFLT.
  141. **
  142. ** The following are the tables generated in this section:
  143. **
  144. ** yy_action[] A single table containing all actions.
  145. ** yy_lookahead[] A table containing the lookahead for each entry in
  146. ** yy_action. Used to detect hash collisions.
  147. ** yy_shift_ofst[] For each state, the offset into yy_action for
  148. ** shifting terminals.
  149. ** yy_reduce_ofst[] For each state, the offset into yy_action for
  150. ** shifting non-terminals after a reduce.
  151. ** yy_default[] Default action for each state.
  152. */
  153. static $yy_action = array(
  154. /* 0 */ 2, 39, 44, 45, 46, 47, 48, 49, 50, 51,
  155. /* 10 */ 52, 43, 44, 45, 46, 47, 48, 49, 50, 51,
  156. /* 20 */ 52, 53, 7, 20, 16, 4, 5, 3, 9, 26,
  157. /* 30 */ 21, 17, 22, 22, 10, 67, 35, 12, 22, 8,
  158. /* 40 */ 73, 42, 1, 56, 56, 14, 18, 22, 34, 56,
  159. /* 50 */ 22, 11, 70, 40, 19, 30, 63, 22, 56, 15,
  160. /* 60 */ 60, 56, 22, 14, 21, 22, 22, 56, 56, 65,
  161. /* 70 */ 68, 36, 6, 56, 32, 101, 56, 56, 31, 127,
  162. /* 80 */ 25, 41, 1, 17, 27, 22, 57, 58, 59, 29,
  163. /* 90 */ 61, 22, 71, 24, 62, 13, 56, 22, 94, 94,
  164. /* 100 */ 94, 56, 56, 33, 37, 56, 22, 101, 56, 95,
  165. /* 110 */ 95, 95, 101, 66, 69, 22, 22, 56, 64, 23,
  166. /* 120 */ 54, 72, 22, 22, 55, 101, 56, 56, 101, 56,
  167. /* 130 */ 101, 101, 101, 56, 56, 56, 28, 38,
  168. );
  169. static $yy_lookahead = array(
  170. /* 0 */ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  171. /* 10 */ 30, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  172. /* 20 */ 30, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  173. /* 30 */ 33, 33, 35, 35, 37, 38, 33, 13, 35, 41,
  174. /* 40 */ 42, 18, 19, 46, 46, 33, 43, 35, 33, 46,
  175. /* 50 */ 35, 39, 40, 31, 32, 33, 35, 35, 46, 32,
  176. /* 60 */ 33, 46, 35, 33, 33, 35, 35, 46, 46, 38,
  177. /* 70 */ 40, 45, 2, 46, 46, 47, 46, 46, 12, 16,
  178. /* 80 */ 17, 18, 19, 33, 12, 35, 12, 13, 14, 33,
  179. /* 90 */ 35, 35, 42, 34, 35, 33, 46, 35, 12, 13,
  180. /* 100 */ 14, 46, 46, 13, 33, 46, 35, 47, 46, 12,
  181. /* 110 */ 13, 14, 47, 33, 33, 35, 35, 46, 35, 36,
  182. /* 120 */ 33, 33, 35, 35, 35, 47, 46, 46, 47, 46,
  183. /* 130 */ 47, 47, 47, 46, 46, 46, 44, 45,
  184. );
  185. const YY_SHIFT_USE_DFLT = -1;
  186. const YY_SHIFT_MAX = 33;
  187. static $yy_shift_ofst = array(
  188. /* 0 */ 70, 18, 18, 74, 74, 74, 74, 74, 74, 74,
  189. /* 10 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
  190. /* 20 */ 74, 74, 74, 74, 74, 70, 66, 74, 66, 86,
  191. /* 30 */ 97, 72, 90, 24,
  192. );
  193. const YY_REDUCE_USE_DFLT = -21;
  194. const YY_REDUCE_MAX = 28;
  195. static $yy_reduce_ofst = array(
  196. /* 0 */ 63, -20, -10, -2, -3, 12, 22, 27, 50, 3,
  197. /* 10 */ 31, 30, 71, 80, 81, 87, 83, 88, 15, 56,
  198. /* 20 */ 59, 62, 89, 21, 55, 23, 92, 28, 26,
  199. );
  200. static $yy_default = array(
  201. /* 0 */ 126, 126, 77, 126, 126, 126, 126, 126, 110, 126,
  202. /* 10 */ 102, 106, 126, 126, 126, 93, 126, 126, 114, 126,
  203. /* 20 */ 126, 126, 126, 99, 96, 74, 126, 126, 117, 90,
  204. /* 30 */ 91, 126, 126, 126, 115, 116, 118, 120, 119, 79,
  205. /* 40 */ 89, 76, 75, 78, 80, 81, 82, 83, 84, 85,
  206. /* 50 */ 86, 87, 88, 92, 94, 121, 122, 123, 124, 125,
  207. /* 60 */ 95, 97, 98, 100, 101, 103, 105, 104, 107, 109,
  208. /* 70 */ 108, 111, 113, 112,
  209. );
  210. /* The next table maps tokens into fallback tokens. If a construct
  211. ** like the following:
  212. **
  213. ** %fallback ID X Y Z.
  214. **
  215. ** appears in the grammer, then ID becomes a fallback token for X, Y,
  216. ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
  217. ** but it does not parse, the type of the token is changed to ID and
  218. ** the parse is retried before an error is thrown.
  219. */
  220. static $yyFallback = array(
  221. );
  222. /*
  223. ** Turn parser tracing on by giving a stream to which to write the trace
  224. ** and a prompt to preface each trace message. Tracing is turned off
  225. ** by making either argument NULL
  226. **
  227. ** Inputs:
  228. ** <ul>
  229. ** <li> A FILE* to which trace output should be written.
  230. ** If NULL, then tracing is turned off.
  231. ** <li> A prefix string written at the beginning of every
  232. ** line of trace output. If NULL, then tracing is
  233. ** turned off.
  234. ** </ul>
  235. **
  236. ** Outputs:
  237. ** None.
  238. */
  239. function A2S_SVGPathTrace(/* stream */ $TraceFILE, /* string */ $zTracePrompt){
  240. $this->yyTraceFILE = $TraceFILE;
  241. $this->yyTracePrompt = $zTracePrompt;
  242. if( $this->yyTraceFILE===null ) $this->yyTracePrompt = null;
  243. else if( $this->yyTracePrompt===null ) $this->yyTraceFILE = null;
  244. }
  245. /* For tracing shifts, the names of all terminals and nonterminals
  246. ** are required. The following table supplies these names */
  247. static $yyTokenName = array(
  248. '$', 'ANY', 'MCMD', 'ZCMD',
  249. 'LCMD', 'HCMD', 'VCMD', 'CCMD',
  250. 'SCMD', 'QCMD', 'TCMD', 'ACMD',
  251. 'POSNUM', 'FLAG', 'NEGNUM', 'error',
  252. 'svg_path', 'moveto_drawto_command_groups', 'moveto_drawto_command_group', 'moveto',
  253. 'drawto_commands', 'drawto_command', 'closepath', 'lineto',
  254. 'horizontal_lineto', 'vertical_lineto', 'curveto', 'smooth_curveto',
  255. 'quadratic_bezier_curveto', 'smooth_quadratic_bezier_curveto', 'elliptical_arc', 'moveto_argument_sequence',
  256. 'lineto_argument_sequence', 'coordinate_pair', 'horizontal_lineto_argument_sequence', 'coordinate',
  257. 'vertical_lineto_argument_sequence', 'curveto_argument_sequence', 'curveto_argument', 'smooth_curveto_argument_sequence',
  258. 'smooth_curveto_argument', 'quadratic_bezier_curveto_argument_sequence', 'quadratic_bezier_curveto_argument', 'smooth_quadratic_bezier_curveto_argument_sequence',
  259. 'elliptical_arc_argument_sequence', 'elliptical_arc_argument', 'number',
  260. );
  261. /* For tracing reduce actions, the names of all rules are required.
  262. */
  263. static $yyRuleName = array(
  264. /* 0 */ "svg_path ::= moveto_drawto_command_groups",
  265. /* 1 */ "moveto_drawto_command_groups ::= moveto_drawto_command_groups moveto_drawto_command_group",
  266. /* 2 */ "moveto_drawto_command_groups ::= moveto_drawto_command_group",
  267. /* 3 */ "moveto_drawto_command_group ::= moveto drawto_commands",
  268. /* 4 */ "drawto_commands ::= drawto_commands drawto_command",
  269. /* 5 */ "drawto_commands ::= drawto_command",
  270. /* 6 */ "drawto_command ::= closepath",
  271. /* 7 */ "drawto_command ::= lineto",
  272. /* 8 */ "drawto_command ::= horizontal_lineto",
  273. /* 9 */ "drawto_command ::= vertical_lineto",
  274. /* 10 */ "drawto_command ::= curveto",
  275. /* 11 */ "drawto_command ::= smooth_curveto",
  276. /* 12 */ "drawto_command ::= quadratic_bezier_curveto",
  277. /* 13 */ "drawto_command ::= smooth_quadratic_bezier_curveto",
  278. /* 14 */ "drawto_command ::= elliptical_arc",
  279. /* 15 */ "moveto ::= MCMD moveto_argument_sequence",
  280. /* 16 */ "moveto_argument_sequence ::= lineto_argument_sequence coordinate_pair",
  281. /* 17 */ "moveto_argument_sequence ::= coordinate_pair",
  282. /* 18 */ "closepath ::= ZCMD",
  283. /* 19 */ "lineto ::= LCMD lineto_argument_sequence",
  284. /* 20 */ "lineto_argument_sequence ::= lineto_argument_sequence coordinate_pair",
  285. /* 21 */ "lineto_argument_sequence ::= coordinate_pair",
  286. /* 22 */ "horizontal_lineto ::= HCMD horizontal_lineto_argument_sequence",
  287. /* 23 */ "horizontal_lineto_argument_sequence ::= horizontal_lineto_argument_sequence coordinate",
  288. /* 24 */ "horizontal_lineto_argument_sequence ::= coordinate",
  289. /* 25 */ "vertical_lineto ::= VCMD vertical_lineto_argument_sequence",
  290. /* 26 */ "vertical_lineto_argument_sequence ::= vertical_lineto_argument_sequence coordinate",
  291. /* 27 */ "vertical_lineto_argument_sequence ::= coordinate",
  292. /* 28 */ "curveto ::= CCMD curveto_argument_sequence",
  293. /* 29 */ "curveto_argument_sequence ::= curveto_argument_sequence curveto_argument",
  294. /* 30 */ "curveto_argument_sequence ::= curveto_argument",
  295. /* 31 */ "curveto_argument ::= coordinate_pair coordinate_pair coordinate_pair",
  296. /* 32 */ "smooth_curveto ::= SCMD smooth_curveto_argument_sequence",
  297. /* 33 */ "smooth_curveto_argument_sequence ::= smooth_curveto_argument_sequence smooth_curveto_argument",
  298. /* 34 */ "smooth_curveto_argument_sequence ::= smooth_curveto_argument",
  299. /* 35 */ "smooth_curveto_argument ::= coordinate_pair coordinate_pair",
  300. /* 36 */ "quadratic_bezier_curveto ::= QCMD quadratic_bezier_curveto_argument_sequence",
  301. /* 37 */ "quadratic_bezier_curveto_argument_sequence ::= quadratic_bezier_curveto_argument_sequence quadratic_bezier_curveto_argument",
  302. /* 38 */ "quadratic_bezier_curveto_argument_sequence ::= quadratic_bezier_curveto_argument",
  303. /* 39 */ "quadratic_bezier_curveto_argument ::= coordinate_pair coordinate_pair",
  304. /* 40 */ "smooth_quadratic_bezier_curveto ::= TCMD smooth_quadratic_bezier_curveto_argument_sequence",
  305. /* 41 */ "smooth_quadratic_bezier_curveto_argument_sequence ::= smooth_quadratic_bezier_curveto_argument_sequence coordinate_pair",
  306. /* 42 */ "smooth_quadratic_bezier_curveto_argument_sequence ::= coordinate_pair",
  307. /* 43 */ "elliptical_arc ::= ACMD elliptical_arc_argument_sequence",
  308. /* 44 */ "elliptical_arc_argument_sequence ::= elliptical_arc_argument_sequence elliptical_arc_argument",
  309. /* 45 */ "elliptical_arc_argument_sequence ::= elliptical_arc_argument",
  310. /* 46 */ "elliptical_arc_argument ::= POSNUM POSNUM number FLAG FLAG coordinate_pair",
  311. /* 47 */ "coordinate_pair ::= coordinate coordinate",
  312. /* 48 */ "coordinate ::= number",
  313. /* 49 */ "number ::= POSNUM",
  314. /* 50 */ "number ::= FLAG",
  315. /* 51 */ "number ::= NEGNUM",
  316. );
  317. /*
  318. ** This function returns the symbolic name associated with a token
  319. ** value.
  320. */
  321. function A2S_SVGPathTokenName(/* int */ $tokenType){
  322. if (isset(self::$yyTokenName[$tokenType]))
  323. return self::$yyTokenName[$tokenType];
  324. return "Unknown";
  325. }
  326. /* The following function deletes the value associated with a
  327. ** symbol. The symbol can be either a terminal or nonterminal.
  328. ** "yymajor" is the symbol code, and "yypminor" is a pointer to
  329. ** the value.
  330. */
  331. private function yy_destructor($yymajor, $yypminor){
  332. switch( $yymajor ){
  333. /* Here is inserted the actions which take place when a
  334. ** terminal or non-terminal is destroyed. This can happen
  335. ** when the symbol is popped from the stack during a
  336. ** reduce or during error processing or when a parser is
  337. ** being destroyed before it is finished parsing.
  338. **
  339. ** Note: during a reduce, the only symbols destroyed are those
  340. ** which appear on the RHS of the rule, but which are not used
  341. ** inside the C code.
  342. */
  343. default: break; /* If no destructor action specified: do nothing */
  344. }
  345. }
  346. /*
  347. ** Pop the parser's stack once.
  348. **
  349. ** If there is a destructor routine associated with the token which
  350. ** is popped from the stack, then call it.
  351. **
  352. ** Return the major token number for the symbol popped.
  353. */
  354. private function yy_pop_parser_stack() {
  355. if ($this->yyidx < 0) return 0;
  356. $yytos = $this->yystack[$this->yyidx];
  357. if( $this->yyTraceFILE ) {
  358. fprintf($this->yyTraceFILE,"%sPopping %s\n",
  359. $this->yyTracePrompt,
  360. self::$yyTokenName[$yytos->major]);
  361. }
  362. $this->yy_destructor( $yytos->major, $yytos->minor);
  363. unset($this->yystack[$this->yyidx]);
  364. $this->yyidx--;
  365. return $yytos->major;
  366. }
  367. /*
  368. ** Deallocate and destroy a parser. Destructors are all called for
  369. ** all stack elements before shutting the parser down.
  370. **
  371. ** Inputs:
  372. ** <ul>
  373. ** <li> A pointer to the parser. This should be a pointer
  374. ** obtained from A2S_SVGPathAlloc.
  375. ** <li> A pointer to a function used to reclaim memory obtained
  376. ** from malloc.
  377. ** </ul>
  378. */
  379. function __destruct()
  380. {
  381. while($this->yyidx >= 0)
  382. $this->yy_pop_parser_stack();
  383. }
  384. /*
  385. ** Find the appropriate action for a parser given the terminal
  386. ** look-ahead token iLookAhead.
  387. **
  388. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  389. ** independent of the look-ahead. If it is, return the action, otherwise
  390. ** return YY_NO_ACTION.
  391. */
  392. private function yy_find_shift_action(
  393. $iLookAhead /* The look-ahead token */
  394. ){
  395. $i = 0;
  396. $stateno = $this->yystack[$this->yyidx]->stateno;
  397. if( $stateno>self::YY_SHIFT_MAX ||
  398. ($i = self::$yy_shift_ofst[$stateno])==self::YY_SHIFT_USE_DFLT ){
  399. return self::$yy_default[$stateno];
  400. }
  401. if( $iLookAhead==self::YYNOCODE ){
  402. return $this->YY_NO_ACTION;
  403. }
  404. $i += $iLookAhead;
  405. if( $i<0 || $i>=count(self::$yy_action) || self::$yy_lookahead[$i]!=$iLookAhead ){
  406. if( $iLookAhead>0 ){
  407. if (isset(self::$yyFallback[$iLookAhead]) &&
  408. ($iFallback = self::$yyFallback[$iLookAhead]) != 0) {
  409. if( $this->yyTraceFILE ){
  410. fprintf($this->yyTraceFILE, "%sFALLBACK %s => %s\n",
  411. $this->yyTracePrompt, self::$yyTokenName[$iLookAhead],
  412. self::$yyTokenName[$iFallback]);
  413. }
  414. return $this->yy_find_shift_action($iFallback);
  415. }
  416. {
  417. $j = $i - $iLookAhead + self::YYWILDCARD;
  418. if( $j>=0 && $j<count(self::$yy_action) && self::$yy_lookahead[$j]==self::YYWILDCARD ){
  419. if( $this->yyTraceFILE ){
  420. fprintf($this->yyTraceFILE, "%sWILDCARD %s => %s\n",
  421. $this->yyTracePrompt, self::$yyTokenName[$iLookAhead],
  422. self::$yyTokenName[self::YYWILDCARD]);
  423. }
  424. return self::$yy_action[$j];
  425. }
  426. }
  427. }
  428. return self::$yy_default[$stateno];
  429. }else{
  430. return self::$yy_action[$i];
  431. }
  432. }
  433. /*
  434. ** Find the appropriate action for a parser given the non-terminal
  435. ** look-ahead token iLookAhead.
  436. **
  437. ** If the look-ahead token is YYNOCODE, then check to see if the action is
  438. ** independent of the look-ahead. If it is, return the action, otherwise
  439. ** return YY_NO_ACTION.
  440. */
  441. private function yy_find_reduce_action(
  442. $stateno, /* Current state number */
  443. $iLookAhead /* The look-ahead token */
  444. ){
  445. $i = 0;
  446. if( $stateno>self::YY_REDUCE_MAX ||
  447. ($i = self::$yy_reduce_ofst[$stateno])==self::YY_REDUCE_USE_DFLT ){
  448. return self::$yy_default[$stateno];
  449. }
  450. if( $iLookAhead==self::YYNOCODE ){
  451. return $this->YY_NO_ACTION;
  452. }
  453. $i += $iLookAhead;
  454. if( $i<0 || $i>=count(self::$yy_action) || self::$yy_lookahead[$i]!=$iLookAhead ){
  455. return self::$yy_default[$stateno];
  456. }else{
  457. return self::$yy_action[$i];
  458. }
  459. }
  460. /*
  461. ** Perform a shift action.
  462. */
  463. private function yy_shift(
  464. $yyNewState, /* The new state to shift in */
  465. $yyMajor, /* The major token to shift in */
  466. $yypMinor /* Pointer ot the minor token to shift in */
  467. ){
  468. $this->yyidx++;
  469. if (isset($this->yystack[$this->yyidx])) {
  470. $yytos = $this->yystack[$this->yyidx];
  471. } else {
  472. $yytos = new A2S_SVGPathyyStackEntry;
  473. $this->yystack[$this->yyidx] = $yytos;
  474. }
  475. $yytos->stateno = $yyNewState;
  476. $yytos->major = $yyMajor;
  477. $yytos->minor = $yypMinor;
  478. if( $this->yyTraceFILE) {
  479. fprintf($this->yyTraceFILE,"%sShift %d\n",$this->yyTracePrompt,$yyNewState);
  480. fprintf($this->yyTraceFILE,"%sStack:",$this->yyTracePrompt);
  481. for ($i = 1; $i <= $this->yyidx; $i++) {
  482. $ent = $this->yystack[$i];
  483. fprintf($this->yyTraceFILE," %s",self::$yyTokenName[$ent->major]);
  484. }
  485. fprintf($this->yyTraceFILE,"\n");
  486. }
  487. }
  488. private function __overflow_dead_code() {
  489. /* if the stack can overflow (it can't in the PHP implementation)
  490. * Then the following code would be emitted */
  491. }
  492. /* The following table contains information about every rule that
  493. ** is used during the reduce.
  494. ** Rather than pollute memory with a large number of arrays,
  495. ** we store both data points in the same array, indexing by
  496. ** rule number * 2.
  497. static const struct {
  498. YYCODETYPE lhs; // Symbol on the left-hand side of the rule
  499. unsigned char nrhs; // Number of right-hand side symbols in the rule
  500. } yyRuleInfo[] = {
  501. */
  502. static $yyRuleInfo = array(
  503. 16, 1,
  504. 17, 2,
  505. 17, 1,
  506. 18, 2,
  507. 20, 2,
  508. 20, 1,
  509. 21, 1,
  510. 21, 1,
  511. 21, 1,
  512. 21, 1,
  513. 21, 1,
  514. 21, 1,
  515. 21, 1,
  516. 21, 1,
  517. 21, 1,
  518. 19, 2,
  519. 31, 2,
  520. 31, 1,
  521. 22, 1,
  522. 23, 2,
  523. 32, 2,
  524. 32, 1,
  525. 24, 2,
  526. 34, 2,
  527. 34, 1,
  528. 25, 2,
  529. 36, 2,
  530. 36, 1,
  531. 26, 2,
  532. 37, 2,
  533. 37, 1,
  534. 38, 3,
  535. 27, 2,
  536. 39, 2,
  537. 39, 1,
  538. 40, 2,
  539. 28, 2,
  540. 41, 2,
  541. 41, 1,
  542. 42, 2,
  543. 29, 2,
  544. 43, 2,
  545. 43, 1,
  546. 30, 2,
  547. 44, 2,
  548. 44, 1,
  549. 45, 6,
  550. 33, 2,
  551. 35, 1,
  552. 46, 1,
  553. 46, 1,
  554. 46, 1,
  555. );
  556. /*
  557. ** Perform a reduce action and the shift that must immediately
  558. ** follow the reduce.
  559. */
  560. private function yy_reduce(
  561. $yyruleno /* Number of the rule by which to reduce */
  562. ){
  563. $yygoto = 0; /* The next state */
  564. $yyact = 0; /* The next action */
  565. $yygotominor = null; /* The LHS of the rule reduced */
  566. $yymsp = null; /* The top of the parser's stack */
  567. $yysize = 0; /* Amount to pop the stack */
  568. $yymsp = $this->yystack[$this->yyidx];
  569. if( $this->yyTraceFILE && isset(self::$yyRuleName[$yyruleno])) {
  570. fprintf($this->yyTraceFILE, "%sReduce [%s].\n", $this->yyTracePrompt,
  571. self::$yyRuleName[$yyruleno]);
  572. }
  573. switch( $yyruleno ){
  574. /* Beginning here are the reduction cases. A typical example
  575. ** follows:
  576. ** case 0:
  577. ** #line <lineno> <grammarfile>
  578. ** { ... } // User supplied code
  579. ** #line <lineno> <thisfile>
  580. ** break;
  581. */
  582. case 15:
  583. #line 26 "svg-path.y"
  584. {
  585. if (count($this->yystack[$this->yyidx + 0]->minor) == 2) {
  586. $this->commands[] = array_merge(array($this->yystack[$this->yyidx + -1]->minor), $this->yystack[$this->yyidx + 0]->minor);
  587. } else {
  588. if ($this->yystack[$this->yyidx + -1]->minor->value == 'm') {
  589. $arr = array ('value' => 'l');
  590. } else {
  591. $arr = array ('value' => 'L');
  592. }
  593. $c = array_splice($this->yystack[$this->yyidx + 0]->minor, 2);
  594. $this->commands[] = array_merge(array($this->yystack[$this->yyidx + -1]->minor), $this->yystack[$this->yyidx + 0]->minor);
  595. $this->commands[] = array_merge(array($arr), $c);
  596. }
  597. }
  598. #line 604 "svg-path.php"
  599. break;
  600. case 16:
  601. case 20:
  602. case 29:
  603. case 33:
  604. case 35:
  605. case 37:
  606. case 39:
  607. case 41:
  608. case 44:
  609. #line 42 "svg-path.y"
  610. { $yygotominor = array_merge($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor); }
  611. #line 617 "svg-path.php"
  612. break;
  613. case 17:
  614. case 21:
  615. case 30:
  616. case 34:
  617. case 38:
  618. case 42:
  619. case 45:
  620. case 48:
  621. case 49:
  622. case 50:
  623. case 51:
  624. #line 43 "svg-path.y"
  625. { $yygotominor = $this->yystack[$this->yyidx + 0]->minor; }
  626. #line 632 "svg-path.php"
  627. break;
  628. case 18:
  629. #line 45 "svg-path.y"
  630. { $this->commands[] = array($this->yystack[$this->yyidx + 0]->minor); }
  631. #line 637 "svg-path.php"
  632. break;
  633. case 19:
  634. case 22:
  635. case 25:
  636. case 28:
  637. case 32:
  638. case 36:
  639. case 40:
  640. case 43:
  641. #line 48 "svg-path.y"
  642. { $this->commands[] = array_merge(array($this->yystack[$this->yyidx + -1]->minor), $this->yystack[$this->yyidx + 0]->minor); }
  643. #line 649 "svg-path.php"
  644. break;
  645. case 23:
  646. case 26:
  647. #line 59 "svg-path.y"
  648. { $yygotominor = array_merge($this->yystack[$this->yyidx + -1]->minor, array($this->yystack[$this->yyidx + 0]->minor)); }
  649. #line 655 "svg-path.php"
  650. break;
  651. case 24:
  652. case 27:
  653. #line 60 "svg-path.y"
  654. { $yygotominor = array($this->yystack[$this->yyidx + 0]->minor); }
  655. #line 661 "svg-path.php"
  656. break;
  657. case 31:
  658. #line 80 "svg-path.y"
  659. { $yygotominor = array_merge($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor); }
  660. #line 666 "svg-path.php"
  661. break;
  662. case 46:
  663. #line 131 "svg-path.y"
  664. { $yygotominor = array_merge(array($this->yystack[$this->yyidx + -5]->minor, $this->yystack[$this->yyidx + -4]->minor, $this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -1]->minor), $this->yystack[$this->yyidx + 0]->minor); }
  665. #line 671 "svg-path.php"
  666. break;
  667. case 47:
  668. #line 133 "svg-path.y"
  669. { $yygotominor = array($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor); }
  670. #line 676 "svg-path.php"
  671. break;
  672. };
  673. $yygoto = self::$yyRuleInfo[2*$yyruleno];
  674. $yysize = self::$yyRuleInfo[(2*$yyruleno)+1];
  675. $state_for_reduce = $this->yystack[$this->yyidx - $yysize]->stateno;
  676. $this->yyidx -= $yysize;
  677. $yyact = $this->yy_find_reduce_action($state_for_reduce,$yygoto);
  678. if( $yyact < self::YYNSTATE ){
  679. $this->yy_shift($yyact, $yygoto, $yygotominor);
  680. }else if( $yyact == self::YYNSTATE + self::YYNRULE + 1 ){
  681. $this->yy_accept();
  682. }
  683. }
  684. /*
  685. ** The following code executes when the parse fails
  686. */
  687. private function yy_parse_failed(
  688. ){
  689. if( $this->yyTraceFILE ){
  690. fprintf($this->yyTraceFILE,"%sFail!\n",$this->yyTracePrompt);
  691. }
  692. while( $this->yyidx>=0 ) $this->yy_pop_parser_stack();
  693. /* Here code is inserted which will be executed whenever the
  694. ** parser fails */
  695. }
  696. /*
  697. ** The following code executes when a syntax error first occurs.
  698. */
  699. private function yy_syntax_error(
  700. $yymajor, /* The major type of the error token */
  701. $yyminor /* The minor type of the error token */
  702. ){
  703. }
  704. /*
  705. ** The following is executed when the parser accepts
  706. */
  707. private function yy_accept(
  708. ){
  709. if( $this->yyTraceFILE ){
  710. fprintf($this->yyTraceFILE,"%sAccept!\n",$this->yyTracePrompt);
  711. }
  712. while( $this->yyidx>=0 ) $this->yy_pop_parser_stack();
  713. /* Here code is inserted which will be executed whenever the
  714. ** parser accepts */
  715. }
  716. /* The main parser program.
  717. ** The first argument is a pointer to a structure obtained from
  718. ** "A2S_SVGPathAlloc" which describes the current state of the parser.
  719. ** The second argument is the major token number. The third is
  720. ** the minor token. The fourth optional argument is whatever the
  721. ** user wants (and specified in the grammar) and is available for
  722. ** use by the action routines.
  723. **
  724. ** Inputs:
  725. ** <ul>
  726. ** <li> A pointer to the parser (an opaque structure.)
  727. ** <li> The major token number.
  728. ** <li> The minor token number.
  729. ** <li> An option argument of a grammar-specified type.
  730. ** </ul>
  731. **
  732. ** Outputs:
  733. ** None.
  734. */
  735. function A2S_SVGPath(
  736. $yymajor, /* The major token code number */
  737. $yyminor = null /* The value for the token */
  738. ){
  739. $yyact = 0; /* The parser action. */
  740. $yyendofinput = 0; /* True if we are at the end of input */
  741. $yyerrorhit = 0; /* True if yymajor has invoked an error */
  742. /* (re)initialize the parser, if necessary */
  743. if( $this->yyidx<0 ){
  744. $this->yyidx = 0;
  745. $this->yyerrcnt = -1;
  746. $ent = new A2S_SVGPathyyStackEntry;
  747. $ent->stateno = 0;
  748. $ent->major = 0;
  749. $this->yystack = array( 0 => $ent );
  750. $this->YY_NO_ACTION = self::YYNSTATE + self::YYNRULE + 2;
  751. $this->YY_ACCEPT_ACTION = self::YYNSTATE + self::YYNRULE + 1;
  752. $this->YY_ERROR_ACTION = self::YYNSTATE + self::YYNRULE;
  753. }
  754. $yyendofinput = ($yymajor==0);
  755. if( $this->yyTraceFILE ){
  756. fprintf($this->yyTraceFILE,"%sInput %s\n",$this->yyTracePrompt,
  757. self::$yyTokenName[$yymajor]);
  758. }
  759. do{
  760. $yyact = $this->yy_find_shift_action($yymajor);
  761. if( $yyact<self::YYNSTATE ){
  762. $this->yy_shift($yyact,$yymajor,$yyminor);
  763. $this->yyerrcnt--;
  764. if( $yyendofinput && $this->yyidx>=0 ){
  765. $yymajor = 0;
  766. }else{
  767. $yymajor = self::YYNOCODE;
  768. }
  769. }else if( $yyact < self::YYNSTATE + self::YYNRULE ){
  770. $this->yy_reduce($yyact-self::YYNSTATE);
  771. }else if( $yyact == $this->YY_ERROR_ACTION ){
  772. if( $this->yyTraceFILE ){
  773. fprintf($this->yyTraceFILE,"%sSyntax Error!\n",$this->yyTracePrompt);
  774. }
  775. if (self::YYERRORSYMBOL) {
  776. /* A syntax error has occurred.
  777. ** The response to an error depends upon whether or not the
  778. ** grammar defines an error token "ERROR".
  779. **
  780. ** This is what we do if the grammar does define ERROR:
  781. **
  782. ** * Call the %syntax_error function.
  783. **
  784. ** * Begin popping the stack until we enter a state where
  785. ** it is legal to shift the error symbol, then shift
  786. ** the error symbol.
  787. **
  788. ** * Set the error count to three.
  789. **
  790. ** * Begin accepting and shifting new tokens. No new error
  791. ** processing will occur until three tokens have been
  792. ** shifted successfully.
  793. **
  794. */
  795. if( $this->yyerrcnt<0 ){
  796. $this->yy_syntax_error($yymajor, $yyminor);
  797. }
  798. $yymx = $this->yystack[$this->yyidx]->major;
  799. if( $yymx==self::YYERRORSYMBOL || $yyerrorhit ){
  800. if( $this->yyTraceFILE ){
  801. fprintf($this->yyTraceFILE,"%sDiscard input token %s\n",
  802. $this->yyTracePrompt,self::$yyTokenName[$yymajor]);
  803. }
  804. $this->yy_destructor($yymajor,$yyminor);
  805. $yymajor = self::YYNOCODE;
  806. }else{
  807. while(
  808. $this->yyidx >= 0 &&
  809. $yymx != self::YYERRORSYMBOL &&
  810. ($yyact = $this->yy_find_reduce_action(
  811. $this->yystack[$this->yyidx]->stateno,
  812. self::YYERRORSYMBOL)) >= self::YYNSTATE
  813. ){
  814. $this->yy_pop_parser_stack();
  815. }
  816. if( $this->yyidx < 0 || $yymajor==0 ){
  817. $this->yy_destructor($yymajor,$yyminor);
  818. $this->yy_parse_failed();
  819. $yymajor = self::YYNOCODE;
  820. }else if( $yymx!=self::YYERRORSYMBOL ){
  821. $this->yy_shift($yyact,self::YYERRORSYMBOL,0);
  822. }
  823. }
  824. $this->yyerrcnt = 3;
  825. $yyerrorhit = 1;
  826. } else { /* YYERRORSYMBOL is not defined */
  827. /* This is what we do if the grammar does not define ERROR:
  828. **
  829. ** * Report an error message, and throw away the input token.
  830. **
  831. ** * If the input token is $, then fail the parse.
  832. **
  833. ** As before, subsequent error messages are suppressed until
  834. ** three input tokens have been successfully shifted.
  835. */
  836. if( $this->yyerrcnt<=0 ){
  837. $this->yy_syntax_error($yymajor, $yyminor);
  838. }
  839. $this->yyerrcnt = 3;
  840. $this->yy_destructor($yymajor,$yyminor);
  841. if( $yyendofinput ){
  842. $this->yy_parse_failed();
  843. }
  844. $yymajor = self::YYNOCODE;
  845. }
  846. }else{
  847. $this->yy_accept();
  848. $yymajor = self::YYNOCODE;
  849. }
  850. }while( $yymajor!=self::YYNOCODE && $this->yyidx>=0 );
  851. }
  852. }