Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Include pikchr source text in the generated SVG. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
041390d3f88afd480c03b0c0ad0901de |
User & Date: | drh 2020-09-15 13:24:47 |
Context
2020-09-15
| ||
13:42 | Make use of the new PIKCHR_INCLUDE_SOURCE flag via /pikchrshow and the pikchr CLI command. ... (check-in: 7da8813e user: stephan tags: trunk) | |
13:24 | Include pikchr source text in the generated SVG. ... (check-in: 041390d3 user: drh tags: trunk) | |
12:59 | Fix the file_mkfolder() function so that it works for files in the root directory. ... (check-in: 74c4732f user: drh tags: trunk) | |
Changes
Changes to src/markdown_html.c.
︙ | ︙ | |||
333 334 335 336 337 338 339 | void pikchr_to_html( Blob *ob, /* Write the generated SVG here */ const char *zSrc, int nSrc, /* The Pikchr source text */ const char *zArg, int nArg /* Addition arguments */ ){ int w = 0, h = 0; char *zIn = fossil_strndup(zSrc, nSrc); | | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | void pikchr_to_html( Blob *ob, /* Write the generated SVG here */ const char *zSrc, int nSrc, /* The Pikchr source text */ const char *zArg, int nArg /* Addition arguments */ ){ int w = 0, h = 0; char *zIn = fossil_strndup(zSrc, nSrc); char *zOut = pikchr(zIn, "pikchr", PIKCHR_INCLUDE_SOURCE, &w, &h); fossil_free(zIn); if( w>0 && h>0 ){ const char *zNonce = safe_html_nonce(1); Blob css; blob_init(&css,0,0); blob_appendf(&css,"max-width:%dpx;",w); blob_append(ob, zNonce, -1); |
︙ | ︙ |
Changes to src/pikchr.c.
︙ | ︙ | |||
27 28 29 30 31 32 33 | ** ** This file implements a C-language subroutine that accepts a string ** of PIKCHR language text and generates a second string of SVG output that ** renders the drawing defined by the input. Space to hold the returned ** string is obtained from malloc() and should be freed by the caller. ** NULL might be returned if there is a memory allocation error. ** | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ** ** This file implements a C-language subroutine that accepts a string ** of PIKCHR language text and generates a second string of SVG output that ** renders the drawing defined by the input. Space to hold the returned ** string is obtained from malloc() and should be freed by the caller. ** NULL might be returned if there is a memory allocation error. ** ** If there are errors in the PIKCHR input, the output will consist of an ** error message and the original PIKCHR input text (inside of <pre>...</pre>). ** ** The subroutine implemented by this file is intended to be stand-alone. ** It uses no external routines other than routines commonly found in ** the standard C library. ** **************************************************************************** |
︙ | ︙ | |||
70 71 72 73 74 75 76 | ** track its internal state. The Pik structure lives for the duration ** of the pikchr() call. ** ** The input is a sequence of objects or "elements". Each element is ** parsed into a PElem object. These are stored on an extensible array ** called PEList. All parameters to each PElem are computed as the ** object is parsed. (Hence, the parameters to a PElem may only refer | | | | | | | | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | ** track its internal state. The Pik structure lives for the duration ** of the pikchr() call. ** ** The input is a sequence of objects or "elements". Each element is ** parsed into a PElem object. These are stored on an extensible array ** called PEList. All parameters to each PElem are computed as the ** object is parsed. (Hence, the parameters to a PElem may only refer ** to prior elements.) Once the PElem is completely assembled, it is ** added to the end of a PEList and never changes thereafter - except, ** PElem objects that are part of a "[...]" block might have their ** absolute position shifted when the outer [...] block is positioned. ** But apart from this repositioning, PElem objects are unchanged once ** they are added to the list. The order of elements on a PEList does ** not change. ** ** After all input has been parsed, the top-level PEList is walked to ** generate output. Sub-lists resulting from [...] blocks are scanned ** as they are encountered. All input must be collected and parsed ahead ** of output generation because the size and position of elements must be ** known in order to compute a bounding box on the output. ** ** Each PElem is on a "layer". (The common case is that all PElem's are ** on a single layer, but multiple layers are possible.) A separate pass ** is made through the list for each layer. ** ** After all output is generated, the Pik object and all the PEList ** and PElem objects are deallocated and the generated output string is ** returned. Upon any error, the Pik.nErr flag is set, processing quickly ** stops, and the stack unwinds. No attempt is made to continue reading ** input after an error. ** ** Most elements begin with a class name like "box" or "arrow" or "move". ** There is a class named "text" which is used for elements that begin ** with a string literal. You can also specify the "text" class. ** A Sublist ("[...]") is a single object that contains a pointer to ** its subelements, all gathered onto a separate PEList object. ** ** Variables go into PVar objects that form a linked list. ** ** Each PElem has zero or one names. Input constructs that attempt ** to assign a new name from an older name, for example: ** ** Abc: Abc + (0.5cm, 0) ** ** Statements like these generate a new "noop" object at the specified ** place and with the given name. As place-names are searched by scanning ** the list in reverse order, this has the effect of overriding the "Abc" ** name when referenced by subsequent objects. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <math.h> #include <assert.h> |
︙ | ︙ | |||
233 234 235 236 237 238 239 | const char *z; /* Pointer to the token text */ unsigned int n; /* Length of the token in bytes */ short int eCode; /* Auxiliary code */ unsigned char eType; /* The numeric parser code */ unsigned char eEdge; /* Corner value for corner keywords */ }; | | | | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | const char *z; /* Pointer to the token text */ unsigned int n; /* Length of the token in bytes */ short int eCode; /* Auxiliary code */ unsigned char eType; /* The numeric parser code */ unsigned char eEdge; /* Corner value for corner keywords */ }; /* Return negative, zero, or positive if pToken is less than, equal to ** or greater than the zero-terminated string z[] */ static int pik_token_eq(PToken *pToken, const char *z){ int c = strncmp(pToken->z,z,pToken->n); if( c==0 && z[pToken->n]!=0 ) c = -1; return c; } |
︙ | ︙ | |||
258 259 260 261 262 263 264 | #define DIR_LEFT 2 #define DIR_UP 3 #define ValidDir(X) ((X)>=0 && (X)<=3) #define IsUpDown(X) (((X)&1)==1) #define IsLeftRight(X) (((X)&1)==0) /* Bitmask for the various attributes for PElem. These bits are | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | #define DIR_LEFT 2 #define DIR_UP 3 #define ValidDir(X) ((X)>=0 && (X)<=3) #define IsUpDown(X) (((X)&1)==1) #define IsLeftRight(X) (((X)&1)==0) /* Bitmask for the various attributes for PElem. These bits are ** collected in PElem.mProp and PElem.mCalc to check for constraint ** errors. */ #define A_WIDTH 0x000001 #define A_HEIGHT 0x000002 #define A_RADIUS 0x000004 #define A_THICKNESS 0x000008 #define A_DASHED 0x000010 /* Includes "dotted" */ #define A_FILL 0x000020 |
︙ | ︙ | |||
286 287 288 289 290 291 292 | struct PElem { const PClass *type; /* Element type */ PToken errTok; /* Reference token for error messages */ PPoint ptAt; /* Reference point for the object */ PPoint ptEnter, ptExit; /* Entry and exit points */ PEList *pSublist; /* Substructure for [...] elements */ char *zName; /* Name assigned to this element */ | | | | | | | | | < < < < | | | 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | struct PElem { const PClass *type; /* Element type */ PToken errTok; /* Reference token for error messages */ PPoint ptAt; /* Reference point for the object */ PPoint ptEnter, ptExit; /* Entry and exit points */ PEList *pSublist; /* Substructure for [...] elements */ char *zName; /* Name assigned to this element */ PNum w; /* "width" property */ PNum h; /* "height" property */ PNum rad; /* "radius" property */ PNum sw; /* "thickness" property. (Mnemonic: "stroke width")*/ PNum dotted; /* "dotted" property. <=0.0 for off */ PNum dashed; /* "dashed" property. <=0.0 for off */ PNum fill; /* "fill" property. Negative for off */ PNum color; /* "color" property */ PPoint with; /* Position constraint from WITH clause */ char eWith; /* Type of heading point on WITH clause */ char cw; /* True for clockwise arc */ char larrow; /* Arrow at beginning (<- or <->) */ char rarrow; /* Arrow at end (-> or <->) */ char bClose; /* True if "close" is seen */ char bChop; /* True if "chop" is seen */ unsigned char nTxt; /* Number of text values */ unsigned mProp; /* Masks of properties set so far */ unsigned mCalc; /* Values computed from other constraints */ PToken aTxt[5]; /* Text with .eCode holding TP flags */ int iLayer; /* Rendering order */ |
︙ | ︙ | |||
334 335 336 337 338 339 340 341 342 343 344 345 346 347 | unsigned nErr; /* Number of errors seen */ const char *zIn; /* Input PIKCHR-language text. zero-terminated */ unsigned int nIn; /* Number of bytes in zIn */ char *zOut; /* Result accumulates here */ unsigned int nOut; /* Bytes written to zOut[] so far */ unsigned int nOutAlloc; /* Space allocated to zOut[] */ unsigned char eDir; /* Current direction */ PElem *cur; /* Element under construction */ PEList *list; /* Element list under construction */ PVar *pVar; /* Application-defined variables */ PBox bbox; /* Bounding box around all elements */ /* Cache of layout values. <=0.0 for unknown... */ PNum rScale; /* Multiply to convert inches to pixels */ PNum fontScale; /* Scale fonts by this percent */ | > | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | unsigned nErr; /* Number of errors seen */ const char *zIn; /* Input PIKCHR-language text. zero-terminated */ unsigned int nIn; /* Number of bytes in zIn */ char *zOut; /* Result accumulates here */ unsigned int nOut; /* Bytes written to zOut[] so far */ unsigned int nOutAlloc; /* Space allocated to zOut[] */ unsigned char eDir; /* Current direction */ unsigned int mFlags; /* Flags passed to pikchr() */ PElem *cur; /* Element under construction */ PEList *list; /* Element list under construction */ PVar *pVar; /* Application-defined variables */ PBox bbox; /* Bounding box around all elements */ /* Cache of layout values. <=0.0 for unknown... */ PNum rScale; /* Multiply to convert inches to pixels */ PNum fontScale; /* Scale fonts by this percent */ |
︙ | ︙ | |||
356 357 358 359 360 361 362 363 364 | /* Paths for lines are constructed here first, then transferred into ** the PElem object at the end: */ int nTPath; /* Number of entries on aTPath[] */ int mTPath; /* For last entry, 1: x set, 2: y set */ PPoint aTPath[1000]; /* Path under construction */ }; /* ** The behavior of an object class is defined by an instance of | > > > > > > > > > > > | | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | /* Paths for lines are constructed here first, then transferred into ** the PElem object at the end: */ int nTPath; /* Number of entries on aTPath[] */ int mTPath; /* For last entry, 1: x set, 2: y set */ PPoint aTPath[1000]; /* Path under construction */ }; /* ** Flag values for Pik.mFlags (to be picked up by makeheaders on systems ** that use makeheaders. */ #undef INTERFACE #define INTERFACE 1 #if INTERFACE #define PIKCHR_INCLUDE_SOURCE 0x0001 /* Include Pikchr src in SVG output */ #endif /* INTERFACE */ /* ** The behavior of an object class is defined by an instance of ** this structure. This is the "virtual method" table. */ struct PClass { const char *zName; /* Name of class */ char isLine; /* True if a line class */ char eJust; /* Use box-style text justification */ void (*xInit)(Pik*,PElem*); /* Initializer */ void (*xNumProp)(Pik*,PElem*,PToken*); /* Value change notification */ |
︙ | ︙ | |||
443 444 445 446 447 448 449 | static PToken pik_next_semantic_token(Pik *p, PToken *pThis); static void pik_compute_layout_settings(Pik*); static void pik_behind(Pik*,PElem*); static PElem *pik_assert(Pik*,PNum,PToken*,PNum); static PElem *pik_place_assert(Pik*,PPoint*,PToken*,PPoint*); | | | 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | static PToken pik_next_semantic_token(Pik *p, PToken *pThis); static void pik_compute_layout_settings(Pik*); static void pik_behind(Pik*,PElem*); static PElem *pik_assert(Pik*,PNum,PToken*,PNum); static PElem *pik_place_assert(Pik*,PPoint*,PToken*,PPoint*); #line 484 "pikchr.c" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols. ***************** Begin token definitions *************************************/ #ifndef T_ID #define T_ID 1 #define T_EDGEPT 2 #define T_OF 3 |
︙ | ︙ | |||
1619 1620 1621 1622 1623 1624 1625 | ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are *not* used ** inside the C code. */ /********* Begin destructor definitions ***************************************/ case 94: /* element_list */ { | | | | | | 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 | ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are *not* used ** inside the C code. */ /********* Begin destructor definitions ***************************************/ case 94: /* element_list */ { #line 473 "pikchr.y" pik_elist_free(p,(yypminor->yy72)); #line 1661 "pikchr.c" } break; case 95: /* element */ case 96: /* unnamed_element */ case 97: /* basetype */ { #line 475 "pikchr.y" pik_elem_free(p,(yypminor->yy254)); #line 1670 "pikchr.c" } break; /********* End destructor definitions *****************************************/ default: break; /* If no destructor action specified: do nothing */ } } |
︙ | ︙ | |||
1848 1849 1850 1851 1852 1853 1854 | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ | | | | 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ #line 506 "pikchr.y" pik_error(p, 0, "parser stack overflow"); #line 1891 "pikchr.c" /******** End %stack_overflow code ********************************************/ pik_parserARG_STORE /* Suppress warning about unused %extra_argument var */ pik_parserCTX_STORE } /* ** Print tracing information for a SHIFT action |
︙ | ︙ | |||
2320 2321 2322 2323 2324 2325 2326 | ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* document ::= element_list */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 | ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* document ::= element_list */ #line 510 "pikchr.y" {pik_render(p,yymsp[0].minor.yy72);} #line 2362 "pikchr.c" break; case 1: /* element_list ::= element */ #line 513 "pikchr.y" { yylhsminor.yy72 = pik_elist_append(p,0,yymsp[0].minor.yy254); } #line 2367 "pikchr.c" yymsp[0].minor.yy72 = yylhsminor.yy72; break; case 2: /* element_list ::= element_list EOL element */ #line 515 "pikchr.y" { yylhsminor.yy72 = pik_elist_append(p,yymsp[-2].minor.yy72,yymsp[0].minor.yy254); } #line 2373 "pikchr.c" yymsp[-2].minor.yy72 = yylhsminor.yy72; break; case 3: /* element ::= */ #line 518 "pikchr.y" { yymsp[1].minor.yy254 = 0; } #line 2379 "pikchr.c" break; case 4: /* element ::= direction */ #line 519 "pikchr.y" { pik_set_direction(p,yymsp[0].minor.yy0.eCode); yylhsminor.yy254=0; } #line 2384 "pikchr.c" yymsp[0].minor.yy254 = yylhsminor.yy254; break; case 5: /* element ::= lvalue ASSIGN rvalue */ #line 520 "pikchr.y" {pik_set_var(p,&yymsp[-2].minor.yy0,yymsp[0].minor.yy73,&yymsp[-1].minor.yy0); yylhsminor.yy254=0;} #line 2390 "pikchr.c" yymsp[-2].minor.yy254 = yylhsminor.yy254; break; case 6: /* element ::= PLACENAME COLON unnamed_element */ #line 522 "pikchr.y" { yylhsminor.yy254 = yymsp[0].minor.yy254; pik_elem_setname(p,yymsp[0].minor.yy254,&yymsp[-2].minor.yy0); } #line 2396 "pikchr.c" yymsp[-2].minor.yy254 = yylhsminor.yy254; break; case 7: /* element ::= PLACENAME COLON position */ #line 524 "pikchr.y" { yylhsminor.yy254 = pik_elem_new(p,0,0,0); if(yylhsminor.yy254){ yylhsminor.yy254->ptAt = yymsp[0].minor.yy139; pik_elem_setname(p,yylhsminor.yy254,&yymsp[-2].minor.yy0); }} #line 2403 "pikchr.c" yymsp[-2].minor.yy254 = yylhsminor.yy254; break; case 8: /* element ::= unnamed_element */ #line 526 "pikchr.y" {yylhsminor.yy254 = yymsp[0].minor.yy254;} #line 2409 "pikchr.c" yymsp[0].minor.yy254 = yylhsminor.yy254; break; case 9: /* element ::= print prlist */ #line 527 "pikchr.y" {pik_append(p,"<br>\n",5); yymsp[-1].minor.yy254=0;} #line 2415 "pikchr.c" break; case 10: /* element ::= ASSERT LP expr EQ expr RP */ #line 532 "pikchr.y" {yymsp[-5].minor.yy254=pik_assert(p,yymsp[-3].minor.yy73,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy73);} #line 2420 "pikchr.c" break; case 11: /* element ::= ASSERT LP place EQ place RP */ #line 534 "pikchr.y" {yymsp[-5].minor.yy254=pik_place_assert(p,&yymsp[-3].minor.yy139,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy139);} #line 2425 "pikchr.c" break; case 12: /* rvalue ::= PLACENAME */ #line 545 "pikchr.y" {yylhsminor.yy73 = pik_lookup_color(p,&yymsp[0].minor.yy0);} #line 2430 "pikchr.c" yymsp[0].minor.yy73 = yylhsminor.yy73; break; case 13: /* pritem ::= FILL */ case 14: /* pritem ::= COLOR */ yytestcase(yyruleno==14); case 15: /* pritem ::= THICKNESS */ yytestcase(yyruleno==15); #line 550 "pikchr.y" {pik_append_num(p,"",pik_value(p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.n,0));} #line 2438 "pikchr.c" break; case 16: /* pritem ::= rvalue */ #line 553 "pikchr.y" {pik_append_num(p,"",yymsp[0].minor.yy73);} #line 2443 "pikchr.c" break; case 17: /* pritem ::= STRING */ #line 554 "pikchr.y" {pik_append_text(p,yymsp[0].minor.yy0.z+1,yymsp[0].minor.yy0.n-2,0);} #line 2448 "pikchr.c" break; case 18: /* prsep ::= COMMA */ #line 555 "pikchr.y" {pik_append(p, " ", 1);} #line 2453 "pikchr.c" break; case 19: /* unnamed_element ::= basetype attribute_list */ #line 558 "pikchr.y" {yylhsminor.yy254 = yymsp[-1].minor.yy254; pik_after_adding_attributes(p,yylhsminor.yy254);} #line 2458 "pikchr.c" yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 20: /* basetype ::= CLASSNAME */ #line 560 "pikchr.y" {yylhsminor.yy254 = pik_elem_new(p,&yymsp[0].minor.yy0,0,0); } #line 2464 "pikchr.c" yymsp[0].minor.yy254 = yylhsminor.yy254; break; case 21: /* basetype ::= STRING textposition */ #line 562 "pikchr.y" {yymsp[-1].minor.yy0.eCode = yymsp[0].minor.yy74; yylhsminor.yy254 = pik_elem_new(p,0,&yymsp[-1].minor.yy0,0); } #line 2470 "pikchr.c" yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 22: /* basetype ::= LB savelist element_list RB */ #line 564 "pikchr.y" { p->list = yymsp[-2].minor.yy72; yymsp[-3].minor.yy254 = pik_elem_new(p,0,0,yymsp[-1].minor.yy72); if(yymsp[-3].minor.yy254) yymsp[-3].minor.yy254->errTok = yymsp[0].minor.yy0; } #line 2476 "pikchr.c" break; case 23: /* savelist ::= */ #line 569 "pikchr.y" {yymsp[1].minor.yy72 = p->list; p->list = 0;} #line 2481 "pikchr.c" break; case 24: /* relexpr ::= expr */ #line 576 "pikchr.y" {yylhsminor.yy60.rAbs = yymsp[0].minor.yy73; yylhsminor.yy60.rRel = 0;} #line 2486 "pikchr.c" yymsp[0].minor.yy60 = yylhsminor.yy60; break; case 25: /* relexpr ::= expr PERCENT */ #line 577 "pikchr.y" {yylhsminor.yy60.rAbs = 0; yylhsminor.yy60.rRel = yymsp[-1].minor.yy73/100;} #line 2492 "pikchr.c" yymsp[-1].minor.yy60 = yylhsminor.yy60; break; case 26: /* optrelexpr ::= */ #line 579 "pikchr.y" {yymsp[1].minor.yy60.rAbs = 0; yymsp[1].minor.yy60.rRel = 1.0;} #line 2498 "pikchr.c" break; case 27: /* attribute_list ::= relexpr alist */ #line 581 "pikchr.y" {pik_add_direction(p,0,&yymsp[-1].minor.yy60);} #line 2503 "pikchr.c" break; case 28: /* attribute ::= numproperty relexpr */ #line 585 "pikchr.y" { pik_set_numprop(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy60); } #line 2508 "pikchr.c" break; case 29: /* attribute ::= dashproperty expr */ #line 586 "pikchr.y" { pik_set_dashed(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy73); } #line 2513 "pikchr.c" break; case 30: /* attribute ::= dashproperty */ #line 587 "pikchr.y" { pik_set_dashed(p,&yymsp[0].minor.yy0,0); } #line 2518 "pikchr.c" break; case 31: /* attribute ::= colorproperty rvalue */ #line 588 "pikchr.y" { pik_set_clrprop(p,&yymsp[-1].minor.yy0,yymsp[0].minor.yy73); } #line 2523 "pikchr.c" break; case 32: /* attribute ::= go direction optrelexpr */ #line 589 "pikchr.y" { pik_add_direction(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy60);} #line 2528 "pikchr.c" break; case 33: /* attribute ::= go direction even position */ #line 590 "pikchr.y" {pik_evenwith(p,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy139);} #line 2533 "pikchr.c" break; case 34: /* attribute ::= CLOSE */ #line 591 "pikchr.y" { pik_close_path(p,&yymsp[0].minor.yy0); } #line 2538 "pikchr.c" break; case 35: /* attribute ::= CHOP */ #line 592 "pikchr.y" { p->cur->bChop = 1; } #line 2543 "pikchr.c" break; case 36: /* attribute ::= FROM position */ #line 593 "pikchr.y" { pik_set_from(p,p->cur,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy139); } #line 2548 "pikchr.c" break; case 37: /* attribute ::= TO position */ #line 594 "pikchr.y" { pik_add_to(p,p->cur,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy139); } #line 2553 "pikchr.c" break; case 38: /* attribute ::= THEN */ #line 595 "pikchr.y" { pik_then(p, &yymsp[0].minor.yy0, p->cur); } #line 2558 "pikchr.c" break; case 39: /* attribute ::= THEN optrelexpr HEADING expr */ case 41: /* attribute ::= GO optrelexpr HEADING expr */ yytestcase(yyruleno==41); #line 597 "pikchr.y" {pik_move_hdg(p,&yymsp[-2].minor.yy60,&yymsp[-1].minor.yy0,yymsp[0].minor.yy73,0,&yymsp[-3].minor.yy0);} #line 2564 "pikchr.c" break; case 40: /* attribute ::= THEN optrelexpr EDGEPT */ case 42: /* attribute ::= GO optrelexpr EDGEPT */ yytestcase(yyruleno==42); #line 598 "pikchr.y" {pik_move_hdg(p,&yymsp[-1].minor.yy60,0,0,&yymsp[0].minor.yy0,&yymsp[-2].minor.yy0);} #line 2570 "pikchr.c" break; case 43: /* attribute ::= AT position */ #line 603 "pikchr.y" { pik_set_at(p,0,&yymsp[0].minor.yy139,&yymsp[-1].minor.yy0); } #line 2575 "pikchr.c" break; case 44: /* attribute ::= SAME */ #line 605 "pikchr.y" {pik_same(p,0,&yymsp[0].minor.yy0);} #line 2580 "pikchr.c" break; case 45: /* attribute ::= SAME AS object */ #line 606 "pikchr.y" {pik_same(p,yymsp[0].minor.yy254,&yymsp[-2].minor.yy0);} #line 2585 "pikchr.c" break; case 46: /* attribute ::= STRING textposition */ #line 607 "pikchr.y" {pik_add_txt(p,&yymsp[-1].minor.yy0,yymsp[0].minor.yy74);} #line 2590 "pikchr.c" break; case 47: /* attribute ::= FIT */ #line 608 "pikchr.y" {pik_size_to_fit(p,&yymsp[0].minor.yy0); } #line 2595 "pikchr.c" break; case 48: /* attribute ::= BEHIND object */ #line 609 "pikchr.y" {pik_behind(p,yymsp[0].minor.yy254);} #line 2600 "pikchr.c" break; case 49: /* withclause ::= DOT_E edge AT position */ case 50: /* withclause ::= edge AT position */ yytestcase(yyruleno==50); #line 617 "pikchr.y" { pik_set_at(p,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy139,&yymsp[-1].minor.yy0); } #line 2606 "pikchr.c" break; case 51: /* numproperty ::= HEIGHT|WIDTH|RADIUS|DIAMETER|THICKNESS */ #line 621 "pikchr.y" {yylhsminor.yy0 = yymsp[0].minor.yy0;} #line 2611 "pikchr.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 52: /* boolproperty ::= CW */ #line 632 "pikchr.y" {p->cur->cw = 1;} #line 2617 "pikchr.c" break; case 53: /* boolproperty ::= CCW */ #line 633 "pikchr.y" {p->cur->cw = 0;} #line 2622 "pikchr.c" break; case 54: /* boolproperty ::= LARROW */ #line 634 "pikchr.y" {p->cur->larrow=1; p->cur->rarrow=0; } #line 2627 "pikchr.c" break; case 55: /* boolproperty ::= RARROW */ #line 635 "pikchr.y" {p->cur->larrow=0; p->cur->rarrow=1; } #line 2632 "pikchr.c" break; case 56: /* boolproperty ::= LRARROW */ #line 636 "pikchr.y" {p->cur->larrow=1; p->cur->rarrow=1; } #line 2637 "pikchr.c" break; case 57: /* boolproperty ::= INVIS */ #line 637 "pikchr.y" {p->cur->sw = 0.0;} #line 2642 "pikchr.c" break; case 58: /* boolproperty ::= THICK */ #line 638 "pikchr.y" {p->cur->sw *= 1.5;} #line 2647 "pikchr.c" break; case 59: /* boolproperty ::= THIN */ #line 639 "pikchr.y" {p->cur->sw *= 0.67;} #line 2652 "pikchr.c" break; case 60: /* textposition ::= */ #line 641 "pikchr.y" {yymsp[1].minor.yy74 = 0;} #line 2657 "pikchr.c" break; case 61: /* textposition ::= textposition CENTER|LJUST|RJUST|ABOVE|BELOW|ITALIC|BOLD|ALIGNED|BIG|SMALL */ #line 644 "pikchr.y" {yylhsminor.yy74 = pik_text_position(p,yymsp[-1].minor.yy74,&yymsp[0].minor.yy0);} #line 2662 "pikchr.c" yymsp[-1].minor.yy74 = yylhsminor.yy74; break; case 62: /* position ::= expr COMMA expr */ #line 647 "pikchr.y" {yylhsminor.yy139.x=yymsp[-2].minor.yy73; yylhsminor.yy139.y=yymsp[0].minor.yy73;} #line 2668 "pikchr.c" yymsp[-2].minor.yy139 = yylhsminor.yy139; break; case 63: /* position ::= place PLUS expr COMMA expr */ #line 649 "pikchr.y" {yylhsminor.yy139.x=yymsp[-4].minor.yy139.x+yymsp[-2].minor.yy73; yylhsminor.yy139.y=yymsp[-4].minor.yy139.y+yymsp[0].minor.yy73;} #line 2674 "pikchr.c" yymsp[-4].minor.yy139 = yylhsminor.yy139; break; case 64: /* position ::= place MINUS expr COMMA expr */ #line 650 "pikchr.y" {yylhsminor.yy139.x=yymsp[-4].minor.yy139.x-yymsp[-2].minor.yy73; yylhsminor.yy139.y=yymsp[-4].minor.yy139.y-yymsp[0].minor.yy73;} #line 2680 "pikchr.c" yymsp[-4].minor.yy139 = yylhsminor.yy139; break; case 65: /* position ::= place PLUS LP expr COMMA expr RP */ #line 652 "pikchr.y" {yylhsminor.yy139.x=yymsp[-6].minor.yy139.x+yymsp[-3].minor.yy73; yylhsminor.yy139.y=yymsp[-6].minor.yy139.y+yymsp[-1].minor.yy73;} #line 2686 "pikchr.c" yymsp[-6].minor.yy139 = yylhsminor.yy139; break; case 66: /* position ::= place MINUS LP expr COMMA expr RP */ #line 654 "pikchr.y" {yylhsminor.yy139.x=yymsp[-6].minor.yy139.x-yymsp[-3].minor.yy73; yylhsminor.yy139.y=yymsp[-6].minor.yy139.y-yymsp[-1].minor.yy73;} #line 2692 "pikchr.c" yymsp[-6].minor.yy139 = yylhsminor.yy139; break; case 67: /* position ::= LP position COMMA position RP */ #line 655 "pikchr.y" {yymsp[-4].minor.yy139.x=yymsp[-3].minor.yy139.x; yymsp[-4].minor.yy139.y=yymsp[-1].minor.yy139.y;} #line 2698 "pikchr.c" break; case 68: /* position ::= LP position RP */ #line 656 "pikchr.y" {yymsp[-2].minor.yy139=yymsp[-1].minor.yy139;} #line 2703 "pikchr.c" break; case 69: /* position ::= expr between position AND position */ #line 658 "pikchr.y" {yylhsminor.yy139 = pik_position_between(p,yymsp[-4].minor.yy73,yymsp[-2].minor.yy139,yymsp[0].minor.yy139);} #line 2708 "pikchr.c" yymsp[-4].minor.yy139 = yylhsminor.yy139; break; case 70: /* position ::= expr LT position COMMA position GT */ #line 660 "pikchr.y" {yylhsminor.yy139 = pik_position_between(p,yymsp[-5].minor.yy73,yymsp[-3].minor.yy139,yymsp[-1].minor.yy139);} #line 2714 "pikchr.c" yymsp[-5].minor.yy139 = yylhsminor.yy139; break; case 71: /* position ::= expr ABOVE position */ #line 661 "pikchr.y" {yylhsminor.yy139=yymsp[0].minor.yy139; yylhsminor.yy139.y += yymsp[-2].minor.yy73;} #line 2720 "pikchr.c" yymsp[-2].minor.yy139 = yylhsminor.yy139; break; case 72: /* position ::= expr BELOW position */ #line 662 "pikchr.y" {yylhsminor.yy139=yymsp[0].minor.yy139; yylhsminor.yy139.y -= yymsp[-2].minor.yy73;} #line 2726 "pikchr.c" yymsp[-2].minor.yy139 = yylhsminor.yy139; break; case 73: /* position ::= expr LEFT OF position */ #line 663 "pikchr.y" {yylhsminor.yy139=yymsp[0].minor.yy139; yylhsminor.yy139.x -= yymsp[-3].minor.yy73;} #line 2732 "pikchr.c" yymsp[-3].minor.yy139 = yylhsminor.yy139; break; case 74: /* position ::= expr RIGHT OF position */ #line 664 "pikchr.y" {yylhsminor.yy139=yymsp[0].minor.yy139; yylhsminor.yy139.x += yymsp[-3].minor.yy73;} #line 2738 "pikchr.c" yymsp[-3].minor.yy139 = yylhsminor.yy139; break; case 75: /* position ::= expr ON HEADING EDGEPT OF position */ #line 666 "pikchr.y" {yylhsminor.yy139 = pik_position_at_hdg(p,yymsp[-5].minor.yy73,&yymsp[-2].minor.yy0,yymsp[0].minor.yy139);} #line 2744 "pikchr.c" yymsp[-5].minor.yy139 = yylhsminor.yy139; break; case 76: /* position ::= expr HEADING EDGEPT OF position */ #line 668 "pikchr.y" {yylhsminor.yy139 = pik_position_at_hdg(p,yymsp[-4].minor.yy73,&yymsp[-2].minor.yy0,yymsp[0].minor.yy139);} #line 2750 "pikchr.c" yymsp[-4].minor.yy139 = yylhsminor.yy139; break; case 77: /* position ::= expr EDGEPT OF position */ #line 670 "pikchr.y" {yylhsminor.yy139 = pik_position_at_hdg(p,yymsp[-3].minor.yy73,&yymsp[-2].minor.yy0,yymsp[0].minor.yy139);} #line 2756 "pikchr.c" yymsp[-3].minor.yy139 = yylhsminor.yy139; break; case 78: /* position ::= expr ON HEADING expr FROM position */ #line 672 "pikchr.y" {yylhsminor.yy139 = pik_position_at_angle(p,yymsp[-5].minor.yy73,yymsp[-2].minor.yy73,yymsp[0].minor.yy139);} #line 2762 "pikchr.c" yymsp[-5].minor.yy139 = yylhsminor.yy139; break; case 79: /* position ::= expr HEADING expr FROM position */ #line 674 "pikchr.y" {yylhsminor.yy139 = pik_position_at_angle(p,yymsp[-4].minor.yy73,yymsp[-2].minor.yy73,yymsp[0].minor.yy139);} #line 2768 "pikchr.c" yymsp[-4].minor.yy139 = yylhsminor.yy139; break; case 80: /* place ::= edge OF object */ #line 686 "pikchr.y" {yylhsminor.yy139 = pik_place_of_elem(p,yymsp[0].minor.yy254,&yymsp[-2].minor.yy0);} #line 2774 "pikchr.c" yymsp[-2].minor.yy139 = yylhsminor.yy139; break; case 81: /* place2 ::= object */ #line 687 "pikchr.y" {yylhsminor.yy139 = pik_place_of_elem(p,yymsp[0].minor.yy254,0);} #line 2780 "pikchr.c" yymsp[0].minor.yy139 = yylhsminor.yy139; break; case 82: /* place2 ::= object DOT_E edge */ #line 688 "pikchr.y" {yylhsminor.yy139 = pik_place_of_elem(p,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);} #line 2786 "pikchr.c" yymsp[-2].minor.yy139 = yylhsminor.yy139; break; case 83: /* place2 ::= NTH VERTEX OF object */ #line 689 "pikchr.y" {yylhsminor.yy139 = pik_nth_vertex(p,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,yymsp[0].minor.yy254);} #line 2792 "pikchr.c" yymsp[-3].minor.yy139 = yylhsminor.yy139; break; case 84: /* object ::= nth */ #line 701 "pikchr.y" {yylhsminor.yy254 = pik_find_nth(p,0,&yymsp[0].minor.yy0);} #line 2798 "pikchr.c" yymsp[0].minor.yy254 = yylhsminor.yy254; break; case 85: /* object ::= nth OF|IN object */ #line 702 "pikchr.y" {yylhsminor.yy254 = pik_find_nth(p,yymsp[0].minor.yy254,&yymsp[-2].minor.yy0);} #line 2804 "pikchr.c" yymsp[-2].minor.yy254 = yylhsminor.yy254; break; case 86: /* objectname ::= PLACENAME */ #line 704 "pikchr.y" {yylhsminor.yy254 = pik_find_byname(p,0,&yymsp[0].minor.yy0);} #line 2810 "pikchr.c" yymsp[0].minor.yy254 = yylhsminor.yy254; break; case 87: /* objectname ::= objectname DOT_U PLACENAME */ #line 706 "pikchr.y" {yylhsminor.yy254 = pik_find_byname(p,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);} #line 2816 "pikchr.c" yymsp[-2].minor.yy254 = yylhsminor.yy254; break; case 88: /* nth ::= NTH CLASSNAME */ #line 708 "pikchr.y" {yylhsminor.yy0=yymsp[0].minor.yy0; yylhsminor.yy0.eCode = pik_nth_value(p,&yymsp[-1].minor.yy0); } #line 2822 "pikchr.c" yymsp[-1].minor.yy0 = yylhsminor.yy0; break; case 89: /* nth ::= NTH LAST CLASSNAME */ #line 709 "pikchr.y" {yylhsminor.yy0=yymsp[0].minor.yy0; yylhsminor.yy0.eCode = -pik_nth_value(p,&yymsp[-2].minor.yy0); } #line 2828 "pikchr.c" yymsp[-2].minor.yy0 = yylhsminor.yy0; break; case 90: /* nth ::= LAST CLASSNAME */ #line 710 "pikchr.y" {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.eCode = -1;} #line 2834 "pikchr.c" break; case 91: /* nth ::= LAST */ #line 711 "pikchr.y" {yylhsminor.yy0=yymsp[0].minor.yy0; yylhsminor.yy0.eCode = -1;} #line 2839 "pikchr.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 92: /* nth ::= NTH LB RB */ #line 712 "pikchr.y" {yylhsminor.yy0=yymsp[-1].minor.yy0; yylhsminor.yy0.eCode = pik_nth_value(p,&yymsp[-2].minor.yy0);} #line 2845 "pikchr.c" yymsp[-2].minor.yy0 = yylhsminor.yy0; break; case 93: /* nth ::= NTH LAST LB RB */ #line 713 "pikchr.y" {yylhsminor.yy0=yymsp[-1].minor.yy0; yylhsminor.yy0.eCode = -pik_nth_value(p,&yymsp[-3].minor.yy0);} #line 2851 "pikchr.c" yymsp[-3].minor.yy0 = yylhsminor.yy0; break; case 94: /* nth ::= LAST LB RB */ #line 714 "pikchr.y" {yymsp[-2].minor.yy0=yymsp[-1].minor.yy0; yymsp[-2].minor.yy0.eCode = -1; } #line 2857 "pikchr.c" break; case 95: /* expr ::= expr PLUS expr */ #line 716 "pikchr.y" {yylhsminor.yy73=yymsp[-2].minor.yy73+yymsp[0].minor.yy73;} #line 2862 "pikchr.c" yymsp[-2].minor.yy73 = yylhsminor.yy73; break; case 96: /* expr ::= expr MINUS expr */ #line 717 "pikchr.y" {yylhsminor.yy73=yymsp[-2].minor.yy73-yymsp[0].minor.yy73;} #line 2868 "pikchr.c" yymsp[-2].minor.yy73 = yylhsminor.yy73; break; case 97: /* expr ::= expr STAR expr */ #line 718 "pikchr.y" {yylhsminor.yy73=yymsp[-2].minor.yy73*yymsp[0].minor.yy73;} #line 2874 "pikchr.c" yymsp[-2].minor.yy73 = yylhsminor.yy73; break; case 98: /* expr ::= expr SLASH expr */ #line 719 "pikchr.y" { if( yymsp[0].minor.yy73==0.0 ){ pik_error(p, &yymsp[-1].minor.yy0, "division by zero"); yylhsminor.yy73 = 0.0; } else{ yylhsminor.yy73 = yymsp[-2].minor.yy73/yymsp[0].minor.yy73; } } #line 2883 "pikchr.c" yymsp[-2].minor.yy73 = yylhsminor.yy73; break; case 99: /* expr ::= MINUS expr */ #line 723 "pikchr.y" {yymsp[-1].minor.yy73=-yymsp[0].minor.yy73;} #line 2889 "pikchr.c" break; case 100: /* expr ::= PLUS expr */ #line 724 "pikchr.y" {yymsp[-1].minor.yy73=yymsp[0].minor.yy73;} #line 2894 "pikchr.c" break; case 101: /* expr ::= LP expr RP */ #line 725 "pikchr.y" {yymsp[-2].minor.yy73=yymsp[-1].minor.yy73;} #line 2899 "pikchr.c" break; case 102: /* expr ::= NUMBER */ #line 726 "pikchr.y" {yylhsminor.yy73=pik_atof(p,&yymsp[0].minor.yy0);} #line 2904 "pikchr.c" yymsp[0].minor.yy73 = yylhsminor.yy73; break; case 103: /* expr ::= ID */ #line 727 "pikchr.y" {yylhsminor.yy73=pik_get_var(p,&yymsp[0].minor.yy0);} #line 2910 "pikchr.c" yymsp[0].minor.yy73 = yylhsminor.yy73; break; case 104: /* expr ::= FUNC1 LP expr RP */ #line 728 "pikchr.y" {yylhsminor.yy73 = pik_func(p,&yymsp[-3].minor.yy0,yymsp[-1].minor.yy73,0.0);} #line 2916 "pikchr.c" yymsp[-3].minor.yy73 = yylhsminor.yy73; break; case 105: /* expr ::= FUNC2 LP expr COMMA expr RP */ #line 729 "pikchr.y" {yylhsminor.yy73 = pik_func(p,&yymsp[-5].minor.yy0,yymsp[-3].minor.yy73,yymsp[-1].minor.yy73);} #line 2922 "pikchr.c" yymsp[-5].minor.yy73 = yylhsminor.yy73; break; case 106: /* expr ::= place2 DOT_XY X */ #line 730 "pikchr.y" {yylhsminor.yy73 = yymsp[-2].minor.yy139.x;} #line 2928 "pikchr.c" yymsp[-2].minor.yy73 = yylhsminor.yy73; break; case 107: /* expr ::= place2 DOT_XY Y */ #line 731 "pikchr.y" {yylhsminor.yy73 = yymsp[-2].minor.yy139.y;} #line 2934 "pikchr.c" yymsp[-2].minor.yy73 = yylhsminor.yy73; break; case 108: /* expr ::= object DOT_L numproperty */ case 109: /* expr ::= object DOT_L dashproperty */ yytestcase(yyruleno==109); case 110: /* expr ::= object DOT_L colorproperty */ yytestcase(yyruleno==110); #line 732 "pikchr.y" {yylhsminor.yy73=pik_property_of(p,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);} #line 2942 "pikchr.c" yymsp[-2].minor.yy73 = yylhsminor.yy73; break; default: /* (111) lvalue ::= ID */ yytestcase(yyruleno==111); /* (112) lvalue ::= FILL */ yytestcase(yyruleno==112); /* (113) lvalue ::= COLOR */ yytestcase(yyruleno==113); /* (114) lvalue ::= THICKNESS */ yytestcase(yyruleno==114); |
︙ | ︙ | |||
3005 3006 3007 3008 3009 3010 3011 | int yymajor, /* The major type of the error token */ pik_parserTOKENTYPE yyminor /* The minor type of the error token */ ){ pik_parserARG_FETCH pik_parserCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ | | | | 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 | int yymajor, /* The major type of the error token */ pik_parserTOKENTYPE yyminor /* The minor type of the error token */ ){ pik_parserARG_FETCH pik_parserCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ #line 499 "pikchr.y" if( TOKEN.z && TOKEN.z[0] ){ pik_error(p, &TOKEN, "syntax error"); }else{ pik_error(p, 0, "syntax error"); } #line 3052 "pikchr.c" /************ End %syntax_error code ******************************************/ pik_parserARG_STORE /* Suppress warning about unused %extra_argument variable */ pik_parserCTX_STORE } /* ** The following is executed when the parser accepts |
︙ | ︙ | |||
3245 3246 3247 3248 3249 3250 3251 | assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif } | | | 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 | assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif } #line 737 "pikchr.y" /* Chart of the 140 official HTML color names with their ** corresponding RGB value. ** ** Two new names "None" and "Off" are added with a value |
︙ | ︙ | |||
3853 3854 3855 3856 3857 3858 3859 | /* Methods for the "file" object */ static void fileInit(Pik *p, PElem *pElem){ pElem->w = pik_value(p, "filewid",7,0); pElem->h = pik_value(p, "fileht",6,0); pElem->rad = pik_value(p, "filerad",7,0); } | | | 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 | /* Methods for the "file" object */ static void fileInit(Pik *p, PElem *pElem){ pElem->w = pik_value(p, "filewid",7,0); pElem->h = pik_value(p, "fileht",6,0); pElem->rad = pik_value(p, "filerad",7,0); } /* Return offset from the center of the file to the compass point ** given by parameter cp */ static PPoint fileOffset(Pik *p, PElem *pElem, int cp){ PPoint pt; PNum w2 = 0.5*pElem->w; PNum h2 = 0.5*pElem->h; PNum rx = pElem->rad; PNum mn = w2<h2 ? w2 : h2; |
︙ | ︙ | |||
4002 4003 4004 4005 4006 4007 4008 | static void splineInit(Pik *p, PElem *pElem){ pElem->w = pik_value(p, "linewid",7,0); pElem->h = pik_value(p, "lineht",6,0); pElem->rad = 1000; pElem->fill = -1.0; /* Disable fill by default */ } /* Return a point along the path from "f" to "t" that is r units | | | 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 | static void splineInit(Pik *p, PElem *pElem){ pElem->w = pik_value(p, "linewid",7,0); pElem->h = pik_value(p, "lineht",6,0); pElem->rad = 1000; pElem->fill = -1.0; /* Disable fill by default */ } /* Return a point along the path from "f" to "t" that is r units ** prior to reaching "t", except if the path is less than 2*r total, ** return the midpoint. */ static PPoint radiusMidpoint(PPoint f, PPoint t, PNum r, int *pbMid){ PNum dx = t.x - f.x; PNum dy = t.y - f.y; PNum dist = hypot(dx,dy); PPoint m; |
︙ | ︙ | |||
4366 4367 4368 4369 4370 4371 4372 | ** Append text to zOut with HTML characters escaped. ** ** * The space character is changed into non-breaking space (U+0080) ** if mFlags has the 0x01 bit set. This is needed when outputting ** text to preserve leading and trailing whitespace. Turns out we ** cannot use as that is an HTML-ism and is not valid in XML. ** | | | 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 | ** Append text to zOut with HTML characters escaped. ** ** * The space character is changed into non-breaking space (U+0080) ** if mFlags has the 0x01 bit set. This is needed when outputting ** text to preserve leading and trailing whitespace. Turns out we ** cannot use as that is an HTML-ism and is not valid in XML. ** ** * The "&" character is changed into "&" if mFlags has the ** 0x02 bit set. This is needed when generating error message text. ** ** * Except for the above, only "<" and ">" are escaped. */ static void pik_append_text(Pik *p, const char *zText, int n, int mFlags){ int i; char c; |
︙ | ︙ | |||
4482 4483 4484 4485 4486 4487 4488 | pik_append(p, buf, -1); } /* Append a style="..." text. But, leave the quote unterminated, in case ** the caller wants to add some more. */ static void pik_append_style(Pik *p, PElem *pElem){ | | | 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 | pik_append(p, buf, -1); } /* Append a style="..." text. But, leave the quote unterminated, in case ** the caller wants to add some more. */ static void pik_append_style(Pik *p, PElem *pElem){ pik_append(p, " style=\"", -1); if( pElem->fill>=0 ){ pik_append_clr(p, "fill:", pElem->fill, ";"); }else{ pik_append(p,"fill:none;",-1); } if( pElem->sw>0.0 && pElem->color>=0.0 ){ PNum sw = pElem->sw; |
︙ | ︙ | |||
4540 4541 4542 4543 4544 4545 4546 | j++; }else{ aTxt[i].eCode = (aTxt[i].eCode & ~TP_VMASK) | TP_ABOVE2; break; } } } | | | 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 | j++; }else{ aTxt[i].eCode = (aTxt[i].eCode & ~TP_VMASK) | TP_ABOVE2; break; } } } /* If there is more than one TP_BELOW, change the last to TP_BELOW2 */ for(j=mJust=0, i=0; i<n; i++){ if( aTxt[i].eCode & TP_BELOW ){ if( j==0 ){ j++; mJust = aTxt[i].eCode & TP_JMASK; }else if( j==1 && mJust!=0 && (aTxt[i].eCode & mJust)==0 ){ j++; |
︙ | ︙ | |||
4583 4584 4585 4586 4587 4588 4589 | if( (aTxt[i].eCode & TP_VMASK)==0 ){ aTxt[i].eCode |= aFree[iSlot++]; } } } } | | < < < | 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 | if( (aTxt[i].eCode & TP_VMASK)==0 ){ aTxt[i].eCode |= aFree[iSlot++]; } } } } /* Append multiple <text> SVG element for the text fields of the PElem. ** Parameters: ** ** p The Pik object into which we are rendering ** ** pElem Object containing the text to be rendered ** ** pBox If not NULL, do no rendering at all. Instead ** expand the box object so that it will include all ** of the text. */ static void pik_append_txt(Pik *p, PElem *pElem, PBox *pBox){ PNum dy; /* Half the height of a single line of text */ PNum dy2; /* Extra vertical space around the center */ |
︙ | ︙ | |||
4769 4770 4771 4772 4773 4774 4775 | return 0; } /* ** Process an "assert( place1 == place2 )" statement. Always return NULL. */ static PElem *pik_place_assert(Pik *p, PPoint *e1, PToken *pEq, PPoint *e2){ | | | 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 | return 0; } /* ** Process an "assert( place1 == place2 )" statement. Always return NULL. */ static PElem *pik_place_assert(Pik *p, PPoint *e1, PToken *pEq, PPoint *e2){ char zE1[100], zE2[100], zMsg[210]; /* Convert the numbers to strings using %g for comparison. This ** limits the precision of the comparison to account for rounding error. */ snprintf(zE1, sizeof(zE1), "(%g,%g)", e1->x, e1->y); zE1[sizeof(zE1)-1] = 0; snprintf(zE2, sizeof(zE2), "(%g,%g)", e2->x, e2->y); zE1[sizeof(zE2)-1] = 0; if( strcmp(zE1,zE2)!=0 ){ snprintf(zMsg, sizeof(zMsg), "%s != %s", zE1, zE2); |
︙ | ︙ | |||
4872 4873 4874 4875 4876 4877 4878 | if( pA->sw.x>pB->sw.x ) pA->sw.x = pB->sw.x; if( pA->sw.y>pB->sw.y ) pA->sw.y = pB->sw.y; if( pA->ne.x<pB->ne.x ) pA->ne.x = pB->ne.x; if( pA->ne.y<pB->ne.y ) pA->ne.y = pB->ne.y; } /* Enlarge the PBox of the first argument, if necessary, so that | | | 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 | if( pA->sw.x>pB->sw.x ) pA->sw.x = pB->sw.x; if( pA->sw.y>pB->sw.y ) pA->sw.y = pB->sw.y; if( pA->ne.x<pB->ne.x ) pA->ne.x = pB->ne.x; if( pA->ne.y<pB->ne.y ) pA->ne.y = pB->ne.y; } /* Enlarge the PBox of the first argument, if necessary, so that ** it contains the point described by the 2nd and 3rd arguments. */ static void pik_bbox_add_xy(PBox *pA, PNum x, PNum y){ if( pik_bbox_isempty(pA) ){ pA->ne.x = x; pA->ne.y = y; pA->sw.x = x; pA->sw.y = y; |
︙ | ︙ | |||
5187 5188 5189 5190 5191 5192 5193 | if( pElem->type->xNumProp ){ pElem->type->xNumProp(p, pElem, pId); } return; } /* | | | 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 | if( pElem->type->xNumProp ){ pElem->type->xNumProp(p, pElem, pId); } return; } /* ** Set a "dashed" property like "dash 0.05" ** ** Use the value supplied by pVal if available. If pVal==0, use ** a default. */ void pik_set_dashed(Pik *p, PToken *pId, PNum *pVal){ PElem *pElem = p->cur; PNum v; |
︙ | ︙ | |||
5349 5350 5351 5352 5353 5354 5355 | } /* Process a movement attribute of the form "right until even with ..." ** ** pDir is the first keyword, "right" or "left" or "up" or "down". ** The movement is in that direction until its closest approach to | | | 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 | } /* Process a movement attribute of the form "right until even with ..." ** ** pDir is the first keyword, "right" or "left" or "up" or "down". ** The movement is in that direction until its closest approach to ** the point specified by pPoint. */ static void pik_evenwith(Pik *p, PToken *pDir, PPoint *pPlace){ PElem *pElem = p->cur; int n; if( !pElem->type->isLine ){ pik_error(p, pDir, "use with line-oriented objects only"); return; |
︙ | ︙ | |||
5519 5520 5521 5522 5523 5524 5525 | else iRes = (iRes &~TP_SZMASK)|TP_BIG; break; case T_SMALL: if( iRes & TP_SMALL ) iRes |= TP_XTRA; else iRes = (iRes &~TP_SZMASK)|TP_SMALL; break; } return iRes; } | | | > | | 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 | else iRes = (iRes &~TP_SZMASK)|TP_BIG; break; case T_SMALL: if( iRes & TP_SMALL ) iRes |= TP_XTRA; else iRes = (iRes &~TP_SZMASK)|TP_SMALL; break; } return iRes; } /* Return an estimate of the actual number of displayed characters ** in a character string. ** ** Omit "\" used to escape characters. And count entities like ** "<" as a single character. Multi-byte UTF8 characters count ** as a single character. */ static int pik_text_length(const PToken *pToken){ int n = pToken->n; const char *z = pToken->z; int cnt, j; for(j=1, cnt=0; j<n-1; j++){ if( (z[j] & 0xc0)==0xc0 ) continue; cnt++; if( z[j]=='\\' && z[j+1]!='&' ){ j++; }else if( z[j]=='&' ){ int k; for(k=j+1; k<j+7 && z[k]!=';'; k++){} if( z[k]==';' ) j = k; } } return cnt; } /* Adjust the width, height, and/or radius of the object so that ** it fits around the text that has been added so far. ** ** (1) Only text specified prior to this attribute is considered. ** (2) The text size is estimated based on the charht and charwid ** variable settings. ** (3) The fitted attributes can be changed again after this ** attribute, for example using "width 110%" if this auto-fit |
︙ | ︙ | |||
5854 5855 5856 5857 5858 5859 5860 | } } pik_error(p, pName, "no such object"); return 0; } /* Change most of the settings for the current object to be the | | | | 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 | } } pik_error(p, pName, "no such object"); return 0; } /* Change most of the settings for the current object to be the ** same as the pOther object, or the most recent element of the same ** type if pOther is NULL. */ static void pik_same(Pik *p, PElem *pOther, PToken *pErrTok){ PElem *pElem = p->cur; if( p->nErr ) return; if( pOther==0 ){ int i; for(i=(p->list ? p->list->n : 0)-1; i>=0; i--){ |
︙ | ︙ | |||
5945 5946 5947 5948 5949 5950 5951 | out.x = p2.x*x + p1.x*(1.0 - x); out.y = p2.y*x + p1.y*(1.0 - x); return out; } /* Compute the position that is dist away from pt at an heading angle of r ** | | | 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 | out.x = p2.x*x + p1.x*(1.0 - x); out.y = p2.y*x + p1.y*(1.0 - x); return out; } /* Compute the position that is dist away from pt at an heading angle of r ** ** The angle is a compass heading in degrees. North is 0 (or 360). ** East is 90. South is 180. West is 270. And so forth. */ static PPoint pik_position_at_angle(Pik *p, PNum dist, PNum r, PPoint pt){ r *= 0.017453292519943295769; /* degrees to radians */ pt.x += dist*sin(r); pt.y += dist*cos(r); return pt; |
︙ | ︙ | |||
6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 | } w = p->bbox.ne.x - p->bbox.sw.x; h = p->bbox.ne.y - p->bbox.sw.y; p->wSVG = (int)(p->rScale*w); p->hSVG = (int)(p->rScale*h); pik_append_dis(p, " viewBox=\"0 0 ",w,""); pik_append_dis(p, " ",h,"\">\n"); pik_elist_render(p, pEList); pik_append(p,"</svg>\n", -1); }else{ p->wSVG = -1; p->hSVG = -1; } pik_elist_free(p, pEList); | > > > > > > > > > > > > > | 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 | } w = p->bbox.ne.x - p->bbox.sw.x; h = p->bbox.ne.y - p->bbox.sw.y; p->wSVG = (int)(p->rScale*w); p->hSVG = (int)(p->rScale*h); pik_append_dis(p, " viewBox=\"0 0 ",w,""); pik_append_dis(p, " ",h,"\">\n"); if( (p->mFlags & PIKCHR_INCLUDE_SOURCE)!=0 ){ /* emit original pikchr source code as metadata */ /* FIXME: emit this only if a certain p->mFlags is set. */ pik_append(p, "<metadata>\n", 11); pik_append(p, "<pikchr:pikchr xmlns:pikchr=" "\"https://pikchr.org/home/doc/trunk/doc/grammar.md\">\n", -1); pik_append(p, "<pikchr:src><![CDATA[", 21); pik_append(p, p->zIn, (int)p->nIn); pik_append(p, "]]></pikchr:src>\n", 17); pik_append(p, "</pikchr:pikchr>\n", 17); pik_append(p, "</metadata>\n", 12); } pik_elist_render(p, pEList); pik_append(p,"</svg>\n", -1); }else{ p->wSVG = -1; p->hSVG = -1; } pik_elist_free(p, pEList); |
︙ | ︙ | |||
6480 6481 6482 6483 6484 6485 6486 | { "width", 5, T_WIDTH, 0, 0 }, { "with", 4, T_WITH, 0, 0 }, { "x", 1, T_X, 0, 0 }, { "y", 1, T_Y, 0, 0 }, }; /* | | | 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 | { "width", 5, T_WIDTH, 0, 0 }, { "with", 4, T_WITH, 0, 0 }, { "x", 1, T_X, 0, 0 }, { "y", 1, T_Y, 0, 0 }, }; /* ** Search a PikWordlist for the given keyword. Return a pointer to the ** element found. Or return 0 if not found. */ static const PikWord *pik_find_word( const char *zIn, /* Word to search for */ int n, /* Length of zIn */ const PikWord *aList, /* List to search */ int nList /* Number of entries in aList */ |
︙ | ︙ | |||
6807 6808 6809 6810 6811 6812 6813 | /* ** Parse the PIKCHR script contained in zText[]. Return a rendering. Or ** if an error is encountered, return the error text. The error message ** is HTML formatted. So regardless of what happens, the return text ** is safe to be insertd into an HTML output stream. ** | | | 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 | /* ** Parse the PIKCHR script contained in zText[]. Return a rendering. Or ** if an error is encountered, return the error text. The error message ** is HTML formatted. So regardless of what happens, the return text ** is safe to be insertd into an HTML output stream. ** ** If pnWidth and pnHeight are not NULL, then this routine writes the ** width and height of the <SVG> object into the integers that they ** point to. A value of -1 is written if an error is seen. ** ** If zClass is not NULL, then it is a class name to be included in ** the <SVG> markup. ** ** The returned string is contained in memory obtained from malloc() |
︙ | ︙ | |||
6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 | yyParser sParse; memset(&s, 0, sizeof(s)); s.zIn = zText; s.nIn = (unsigned int)strlen(zText); s.eDir = DIR_RIGHT; s.zClass = zClass; pik_parserInit(&sParse, &s); #if 0 pik_parserTrace(stdout, "parser: "); #endif for(i=0; zText[i] && s.nErr==0; i+=sz){ token.eCode = 0; token.eEdge = 0; | > | 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 | yyParser sParse; memset(&s, 0, sizeof(s)); s.zIn = zText; s.nIn = (unsigned int)strlen(zText); s.eDir = DIR_RIGHT; s.zClass = zClass; s.mFlags = mFlags; pik_parserInit(&sParse, &s); #if 0 pik_parserTrace(stdout, "parser: "); #endif for(i=0; zText[i] && s.nErr==0; i+=sz){ token.eCode = 0; token.eEdge = 0; |
︙ | ︙ | |||
6909 6910 6911 6912 6913 6914 6915 | ** ** Generate HTML on standard output that displays both the original ** input text and the rendered SVG for all files named on the command ** line. */ int main(int argc, char **argv){ int i; | | > | 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 | ** ** Generate HTML on standard output that displays both the original ** input text and the rendered SVG for all files named on the command ** line. */ int main(int argc, char **argv){ int i; int bNoEcho = 0; /* Do not the text of the script */ int mPikchrFlags = 0; /* Flags passed into pikchr() */ printf( "<!DOCTYPE html>\n" "<html lang=\"en-US\">\n" "<head>\n<title>PIKCHR Test</title>\n" "<meta charset=\"utf-8\">\n" "</head>\n" "<body>\n" |
︙ | ︙ | |||
6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 | if( argv[i][0]=='-' ){ char *z = argv[i]; z++; if( z[0]=='-' ) z++; if( strcmp(z,"no-echo")==0 ){ bNoEcho = 1; }else { fprintf(stderr,"unknown option: \"%s\"\n", argv[i]); exit(1); } continue; } printf("<h1>File %s</h1>\n", argv[i]); | > > > | 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 | if( argv[i][0]=='-' ){ char *z = argv[i]; z++; if( z[0]=='-' ) z++; if( strcmp(z,"no-echo")==0 ){ bNoEcho = 1; }else if( strcmp(z,"include-source")==0 ){ mPikchrFlags |= PIKCHR_INCLUDE_SOURCE; }else { fprintf(stderr,"unknown option: \"%s\"\n", argv[i]); exit(1); } continue; } printf("<h1>File %s</h1>\n", argv[i]); |
︙ | ︙ | |||
6978 6979 6980 6981 6982 6983 6984 | printf("&"); }else if( c==0 ){ break; } } printf("</pre></blockquote>\n"); } | | | | 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 | printf("&"); }else if( c==0 ){ break; } } printf("</pre></blockquote>\n"); } zOut = pikchr(zIn, "pikchr", mPikchrFlags, &w, &h); free(zIn); if( zOut ){ if( w<0 ){ printf("<p>ERROR:</p>\n"); }else if( bNoEcho==0 ){ printf("<p>Output size: %d by %d</p>\n", w, h); } printf("<div style='border:3px solid lightgray;max-width:%dpx'>\n" "%s</div>\n", w, zOut); free(zOut); } } printf("</body></html>\n"); return 0; } #endif /* PIKCHR_SHELL */ #line 7053 "pikchr.c" |