-
Notifications
You must be signed in to change notification settings - Fork 0
/
pikchr.c
8256 lines (7975 loc) · 277 KB
/
pikchr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* This file is automatically generated by Lemon from input grammar
** source file "pikchr.y".
*/
/*
** Zero-Clause BSD license:
**
** Copyright (C) 2020-09-01 by D. Richard Hipp <[email protected]>
**
** Permission to use, copy, modify, and/or distribute this software for
** any purpose with or without fee is hereby granted.
**
****************************************************************************
**
** This software translates a PIC-inspired diagram language into SVG.
**
** PIKCHR (pronounced like "picture") is *mostly* backwards compatible
** with legacy PIC, though some features of legacy PIC are removed
** (for example, the "sh" command is removed for security) and
** many enhancements are added.
**
** PIKCHR is designed for use in an internet facing web environment.
** In particular, PIKCHR is designed to safely generate benign SVG from
** source text that provided by a hostile agent.
**
** This code was originally written by D. Richard Hipp using documentation
** from prior PIC implementations but without reference to prior code.
** All of the code in this project is original.
**
** 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.
**
****************************************************************************
** COMPILING:
**
** The original source text is a mixture of C99 and "Lemon"
** (See https://sqlite.org/src/file/doc/lemon.html). Lemon is an LALR(1)
** parser generator program, similar to Yacc. The grammar of the
** input language is specified in Lemon. C-code is attached. Lemon
** runs to generate a single output file ("pikchr.c") which is then
** compiled to generate the Pikchr library. This header comment is
** preserved in the Lemon output, so you might be reading this in either
** the generated "pikchr.c" file that is output by Lemon, or in the
** "pikchr.y" source file that is input into Lemon. If you make changes,
** you should change the input source file "pikchr.y", not the
** Lemon-generated output file.
**
** Basic compilation steps:
**
** lemon pikchr.y
** cc pikchr.c -o pikchr.o
**
** Add -DPIKCHR_SHELL to add a main() routine that reads input files
** and sends them through Pikchr, for testing. Add -DPIKCHR_FUZZ for
** -fsanitizer=fuzzer testing.
**
****************************************************************************
** IMPLEMENTATION NOTES (for people who want to understand the internal
** operation of this software, perhaps to extend the code or to fix bugs):
**
** Each call to pikchr() uses a single instance of the Pik structure to
** track its internal state. The Pik structure lives for the duration
** of the pikchr() call.
**
** The input is a sequence of objects or "statements". Each statement is
** parsed into a PObj object. These are stored on an extensible array
** called PList. All parameters to each PObj are computed as the
** object is parsed. (Hence, the parameters to a PObj may only refer
** to prior statements.) Once the PObj is completely assembled, it is
** added to the end of a PList and never changes thereafter - except,
** PObj objects that are part of a "[...]" block might have their
** absolute position shifted when the outer [...] block is positioned.
** But apart from this repositioning, PObj objects are unchanged once
** they are added to the list. The order of statements on a PList does
** not change.
**
** After all input has been parsed, the top-level PList 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 statements must be
** known in order to compute a bounding box on the output.
**
** Each PObj is on a "layer". (The common case is that all PObj'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 PList
** and PObj 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 statements begin with a class name like "box" or "arrow" or "move".
** There is a class named "text" which is used for statements 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 substatements, all gathered onto a separate PList object.
**
** Variables go into PVar objects that form a linked list.
**
** Each PObj 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>
#define count(X) (sizeof(X)/sizeof(X[0]))
#ifndef M_PI
# define M_PI 3.1415926535897932385
#endif
/* Limit the number of tokens in a single script to avoid run-away
** macro expansion attacks. See forum post
** https://pikchr.org/home/forumpost/ef8684c6955a411a
*/
#ifndef PIKCHR_TOKEN_LIMIT
# define PIKCHR_TOKEN_LIMIT 100000
#endif
/* Tag intentionally unused parameters with this macro to prevent
** compiler warnings with -Wextra */
#define UNUSED_PARAMETER(X) (void)(X)
typedef struct Pik Pik; /* Complete parsing context */
typedef struct PToken PToken; /* A single token */
typedef struct PObj PObj; /* A single diagram object */
typedef struct PList PList; /* A list of diagram objects */
typedef struct PClass PClass; /* Description of statements types */
typedef double PNum; /* Numeric value */
typedef struct PRel PRel; /* Absolute or percentage value */
typedef struct PPoint PPoint; /* A position in 2-D space */
typedef struct PVar PVar; /* script-defined variable */
typedef struct PBox PBox; /* A bounding box */
typedef struct PMacro PMacro; /* A "define" macro */
/* Compass points */
#define CP_N 1
#define CP_NE 2
#define CP_E 3
#define CP_SE 4
#define CP_S 5
#define CP_SW 6
#define CP_W 7
#define CP_NW 8
#define CP_C 9 /* .center or .c */
#define CP_END 10 /* .end */
#define CP_START 11 /* .start */
/* Heading angles corresponding to compass points */
static const PNum pik_hdg_angle[] = {
/* none */ 0.0,
/* N */ 0.0,
/* NE */ 45.0,
/* E */ 90.0,
/* SE */ 135.0,
/* S */ 180.0,
/* SW */ 225.0,
/* W */ 270.0,
/* NW */ 315.0,
/* C */ 0.0,
};
/* Built-in functions */
#define FN_ABS 0
#define FN_COS 1
#define FN_INT 2
#define FN_MAX 3
#define FN_MIN 4
#define FN_SIN 5
#define FN_SQRT 6
/* Text position and style flags. Stored in PToken.eCode so limited
** to 15 bits. */
#define TP_LJUST 0x0001 /* left justify...... */
#define TP_RJUST 0x0002 /* ...Right justify */
#define TP_JMASK 0x0003 /* Mask for justification bits */
#define TP_ABOVE2 0x0004 /* Position text way above PObj.ptAt */
#define TP_ABOVE 0x0008 /* Position text above PObj.ptAt */
#define TP_CENTER 0x0010 /* On the line */
#define TP_BELOW 0x0020 /* Position text below PObj.ptAt */
#define TP_BELOW2 0x0040 /* Position text way below PObj.ptAt */
#define TP_VMASK 0x007c /* Mask for text positioning flags */
#define TP_BIG 0x0100 /* Larger font */
#define TP_SMALL 0x0200 /* Smaller font */
#define TP_XTRA 0x0400 /* Amplify TP_BIG or TP_SMALL */
#define TP_SZMASK 0x0700 /* Font size mask */
#define TP_ITALIC 0x1000 /* Italic font */
#define TP_BOLD 0x2000 /* Bold font */
#define TP_MONO 0x4000 /* Monospace font family */
#define TP_FMASK 0x7000 /* Mask for font style */
#define TP_ALIGN 0x8000 /* Rotate to align with the line */
/* An object to hold a position in 2-D space */
struct PPoint {
PNum x, y; /* X and Y coordinates */
};
static const PPoint cZeroPoint = {0.0,0.0};
/* A bounding box */
struct PBox {
PPoint sw, ne; /* Lower-left and top-right corners */
};
/* An Absolute or a relative distance. The absolute distance
** is stored in rAbs and the relative distance is stored in rRel.
** Usually, one or the other will be 0.0. When using a PRel to
** update an existing value, the computation is usually something
** like this:
**
** value = PRel.rAbs + value*PRel.rRel
**
*/
struct PRel {
PNum rAbs; /* Absolute value */
PNum rRel; /* Value relative to current value */
};
/* A variable created by the ID = EXPR construct of the PIKCHR script
**
** PIKCHR (and PIC) scripts do not use many varaibles, so it is reasonable
** to store them all on a linked list.
*/
struct PVar {
const char *zName; /* Name of the variable */
PNum val; /* Value of the variable */
PVar *pNext; /* Next variable in a list of them all */
};
/* A single token in the parser input stream
*/
struct PToken {
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;
}
/* Extra token types not generated by LEMON but needed by the
** tokenizer
*/
#define T_PARAMETER 253 /* $1, $2, ..., $9 */
#define T_WHITESPACE 254 /* Whitespace or comments */
#define T_ERROR 255 /* Any text that is not a valid token */
/* Directions of movement */
#define DIR_RIGHT 0
#define DIR_DOWN 1
#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 PObj. These bits are
** collected in PObj.mProp and PObj.mCalc to check for constraint
** errors. */
#define A_WIDTH 0x0001
#define A_HEIGHT 0x0002
#define A_RADIUS 0x0004
#define A_THICKNESS 0x0008
#define A_DASHED 0x0010 /* Includes "dotted" */
#define A_FILL 0x0020
#define A_COLOR 0x0040
#define A_ARROW 0x0080
#define A_FROM 0x0100
#define A_CW 0x0200
#define A_AT 0x0400
#define A_TO 0x0800 /* one or more movement attributes */
#define A_FIT 0x1000
/* A single graphics object */
struct PObj {
const PClass *type; /* Object type or class */
PToken errTok; /* Reference token for error messages */
PPoint ptAt; /* Reference point for the object */
PPoint ptEnter, ptExit; /* Entry and exit points */
PList *pSublist; /* Substructure for [...] objects */
char *zName; /* Name assigned to this statement */
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 */
char bAltAutoFit; /* Always send both h and w into xFit() */
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 */
int inDir, outDir; /* Entry and exit directions */
int nPath; /* Number of path points */
PPoint *aPath; /* Array of path points */
PObj *pFrom, *pTo; /* End-point objects of a path */
PBox bbox; /* Bounding box */
};
/* A list of graphics objects */
struct PList {
int n; /* Number of statements in the list */
int nAlloc; /* Allocated slots in a[] */
PObj **a; /* Pointers to individual objects */
};
/* A macro definition */
struct PMacro {
PMacro *pNext; /* Next in the list */
PToken macroName; /* Name of the macro */
PToken macroBody; /* Body of the macro */
int inUse; /* Do not allow recursion */
};
/* Each call to the pikchr() subroutine uses an instance of the following
** object to pass around context to all of its subroutines.
*/
struct Pik {
unsigned nErr; /* Number of errors seen */
unsigned nToken; /* Number of tokens parsed */
PToken sIn; /* Input Pikchr-language text */
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() */
PObj *cur; /* Object under construction */
PObj *lastRef; /* Last object references by name */
PList *list; /* Object list under construction */
PMacro *pMacros; /* List of all defined macros */
PVar *pVar; /* Application-defined variables */
PBox bbox; /* Bounding box around all statements */
/* Cache of layout values. <=0.0 for unknown... */
PNum rScale; /* Multiply to convert inches to pixels */
PNum fontScale; /* Scale fonts by this percent */
PNum charWidth; /* Character width */
PNum charHeight; /* Character height */
PNum wArrow; /* Width of arrowhead at the fat end */
PNum hArrow; /* Ht of arrowhead - dist from tip to fat end */
char bLayoutVars; /* True if cache is valid */
char thenFlag; /* True if "then" seen */
char samePath; /* aTPath copied by "same" */
const char *zClass; /* Class name for the <svg> */
int wSVG, hSVG; /* Width and height of the <svg> */
int fgcolor; /* foreground color value, or -1 for none */
int bgcolor; /* background color value, or -1 for none */
/* Paths for lines are constructed here first, then transferred into
** the PObj 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 */
/* Error contexts */
unsigned int nCtx; /* Number of error contexts */
PToken aCtx[10]; /* Nested error contexts */
};
/* Include PIKCHR_PLAINTEXT_ERRORS among the bits of mFlags on the 3rd
** argument to pikchr() in order to cause error message text to come out
** as text/plain instead of as text/html
*/
#define PIKCHR_PLAINTEXT_ERRORS 0x0001
/* Include PIKCHR_DARK_MODE among the mFlag bits to invert colors.
*/
#define PIKCHR_DARK_MODE 0x0002
/* Include PIKCHR_CURRENTCOLOR_FOR_BLACK among the bits of mFlags on
** the 3rd argument to pikchr() to have color exactly 0.0 (black)
** emitted as "currentColor" instead of "rgb(0,0,0)".
*/
#define PIKCHR_CURRENTCOLOR_FOR_BLACK 0x0004
/*
** 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*,PObj*); /* Initializer */
void (*xNumProp)(Pik*,PObj*,PToken*); /* Value change notification */
void (*xCheck)(Pik*,PObj*); /* Checks to do after parsing */
PPoint (*xChop)(Pik*,PObj*,PPoint*); /* Chopper */
PPoint (*xOffset)(Pik*,PObj*,int); /* Offset from .c to edge point */
void (*xFit)(Pik*,PObj*,PNum w,PNum h); /* Size to fit text */
void (*xRender)(Pik*,PObj*); /* Render */
};
/* Forward declarations */
static void pik_append(Pik*, const char*,int);
static void pik_append_text(Pik*,const char*,int,int);
static void pik_append_num(Pik*,const char*,PNum);
static void pik_append_point(Pik*,const char*,PPoint*);
static void pik_append_x(Pik*,const char*,PNum,const char*);
static void pik_append_y(Pik*,const char*,PNum,const char*);
static void pik_append_xy(Pik*,const char*,PNum,PNum);
static void pik_append_dis(Pik*,const char*,PNum,const char*);
static void pik_append_arc(Pik*,PNum,PNum,PNum,PNum);
static void pik_append_clr(Pik*,const char*,PNum,const char*,int);
static void pik_append_style(Pik*,PObj*,int);
static void pik_append_txt(Pik*,PObj*, PBox*);
static void pik_draw_arrowhead(Pik*,PPoint*pFrom,PPoint*pTo,PObj*);
static void pik_chop(PPoint*pFrom,PPoint*pTo,PNum);
static void pik_error(Pik*,PToken*,const char*);
static void pik_elist_free(Pik*,PList*);
static void pik_elem_free(Pik*,PObj*);
static void pik_render(Pik*,PList*);
static PList *pik_elist_append(Pik*,PList*,PObj*);
static PObj *pik_elem_new(Pik*,PToken*,PToken*,PList*);
static void pik_set_direction(Pik*,int);
static void pik_elem_setname(Pik*,PObj*,PToken*);
static int pik_round(PNum);
static void pik_set_var(Pik*,PToken*,PNum,PToken*);
static PNum pik_value(Pik*,const char*,int,int*);
static int pik_value_int(Pik*,const char*,int,int*);
static PNum pik_lookup_color(Pik*,PToken*);
static PNum pik_get_var(Pik*,PToken*);
static PNum pik_atof(PToken*);
static void pik_after_adding_attributes(Pik*,PObj*);
static void pik_elem_move(PObj*,PNum dx, PNum dy);
static void pik_elist_move(PList*,PNum dx, PNum dy);
static void pik_set_numprop(Pik*,PToken*,PRel*);
static void pik_set_clrprop(Pik*,PToken*,PNum);
static void pik_set_dashed(Pik*,PToken*,PNum*);
static void pik_then(Pik*,PToken*,PObj*);
static void pik_add_direction(Pik*,PToken*,PRel*);
static void pik_move_hdg(Pik*,PRel*,PToken*,PNum,PToken*,PToken*);
static void pik_evenwith(Pik*,PToken*,PPoint*);
static void pik_set_from(Pik*,PObj*,PToken*,PPoint*);
static void pik_add_to(Pik*,PObj*,PToken*,PPoint*);
static void pik_close_path(Pik*,PToken*);
static void pik_set_at(Pik*,PToken*,PPoint*,PToken*);
static short int pik_nth_value(Pik*,PToken*);
static PObj *pik_find_nth(Pik*,PObj*,PToken*);
static PObj *pik_find_byname(Pik*,PObj*,PToken*);
static PPoint pik_place_of_elem(Pik*,PObj*,PToken*);
static int pik_bbox_isempty(PBox*);
static int pik_bbox_contains_point(PBox*,PPoint*);
static void pik_bbox_init(PBox*);
static void pik_bbox_addbox(PBox*,PBox*);
static void pik_bbox_add_xy(PBox*,PNum,PNum);
static void pik_bbox_addellipse(PBox*,PNum x,PNum y,PNum rx,PNum ry);
static void pik_add_txt(Pik*,PToken*,int);
static int pik_text_length(const PToken *pToken, const int isMonospace);
static void pik_size_to_fit(Pik*,PToken*,int);
static int pik_text_position(int,PToken*);
static PNum pik_property_of(PObj*,PToken*);
static PNum pik_func(Pik*,PToken*,PNum,PNum);
static PPoint pik_position_between(PNum x, PPoint p1, PPoint p2);
static PPoint pik_position_at_angle(PNum dist, PNum r, PPoint pt);
static PPoint pik_position_at_hdg(PNum dist, PToken *pD, PPoint pt);
static void pik_same(Pik *p, PObj*, PToken*);
static PPoint pik_nth_vertex(Pik *p, PToken *pNth, PToken *pErr, PObj *pObj);
static PToken pik_next_semantic_token(PToken *pThis);
static void pik_compute_layout_settings(Pik*);
static void pik_behind(Pik*,PObj*);
static PObj *pik_assert(Pik*,PNum,PToken*,PNum);
static PObj *pik_position_assert(Pik*,PPoint*,PToken*,PPoint*);
static PNum pik_dist(PPoint*,PPoint*);
static void pik_add_macro(Pik*,PToken *pId,PToken *pCode);
#line 529 "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
#define T_PLUS 4
#define T_MINUS 5
#define T_STAR 6
#define T_SLASH 7
#define T_PERCENT 8
#define T_UMINUS 9
#define T_EOL 10
#define T_ASSIGN 11
#define T_PLACENAME 12
#define T_COLON 13
#define T_ASSERT 14
#define T_LP 15
#define T_EQ 16
#define T_RP 17
#define T_DEFINE 18
#define T_CODEBLOCK 19
#define T_FILL 20
#define T_COLOR 21
#define T_THICKNESS 22
#define T_PRINT 23
#define T_STRING 24
#define T_COMMA 25
#define T_CLASSNAME 26
#define T_LB 27
#define T_RB 28
#define T_UP 29
#define T_DOWN 30
#define T_LEFT 31
#define T_RIGHT 32
#define T_CLOSE 33
#define T_CHOP 34
#define T_FROM 35
#define T_TO 36
#define T_THEN 37
#define T_HEADING 38
#define T_GO 39
#define T_AT 40
#define T_WITH 41
#define T_SAME 42
#define T_AS 43
#define T_FIT 44
#define T_BEHIND 45
#define T_UNTIL 46
#define T_EVEN 47
#define T_DOT_E 48
#define T_HEIGHT 49
#define T_WIDTH 50
#define T_RADIUS 51
#define T_DIAMETER 52
#define T_DOTTED 53
#define T_DASHED 54
#define T_CW 55
#define T_CCW 56
#define T_LARROW 57
#define T_RARROW 58
#define T_LRARROW 59
#define T_INVIS 60
#define T_THICK 61
#define T_THIN 62
#define T_SOLID 63
#define T_CENTER 64
#define T_LJUST 65
#define T_RJUST 66
#define T_ABOVE 67
#define T_BELOW 68
#define T_ITALIC 69
#define T_BOLD 70
#define T_MONO 71
#define T_ALIGNED 72
#define T_BIG 73
#define T_SMALL 74
#define T_AND 75
#define T_LT 76
#define T_GT 77
#define T_ON 78
#define T_WAY 79
#define T_BETWEEN 80
#define T_THE 81
#define T_NTH 82
#define T_VERTEX 83
#define T_TOP 84
#define T_BOTTOM 85
#define T_START 86
#define T_END 87
#define T_IN 88
#define T_THIS 89
#define T_DOT_U 90
#define T_LAST 91
#define T_NUMBER 92
#define T_FUNC1 93
#define T_FUNC2 94
#define T_DIST 95
#define T_DOT_XY 96
#define T_X 97
#define T_Y 98
#define T_DOT_L 99
#endif
/**************** End token definitions ***************************************/
/* The next sections is a series of control #defines.
** various aspects of the generated parser.
** YYCODETYPE is the data type used to store the integer codes
** that represent terminal and non-terminal symbols.
** "unsigned char" is used if there are fewer than
** 256 symbols. Larger types otherwise.
** YYNOCODE is a number of type YYCODETYPE that is not used for
** any terminal or nonterminal symbol.
** YYFALLBACK If defined, this indicates that one or more tokens
** (also known as: "terminal symbols") have fall-back
** values which should be used if the original symbol
** would not parse. This permits keywords to sometimes
** be used as identifiers, for example.
** YYACTIONTYPE is the data type used for "action codes" - numbers
** that indicate what to do in response to the next
** token.
** pik_parserTOKENTYPE is the data type used for minor type for terminal
** symbols. Background: A "minor type" is a semantic
** value associated with a terminal or non-terminal
** symbols. For example, for an "ID" terminal symbol,
** the minor type might be the name of the identifier.
** Each non-terminal can have a different minor type.
** Terminal symbols all have the same minor type, though.
** This macros defines the minor type for terminal
** symbols.
** YYMINORTYPE is the data type used for all minor types.
** This is typically a union of many types, one of
** which is pik_parserTOKENTYPE. The entry in the union
** for terminal symbols is called "yy0".
** YYSTACKDEPTH is the maximum depth of the parser's stack. If
** zero the stack is dynamically sized using realloc()
** pik_parserARG_SDECL A static variable declaration for the %extra_argument
** pik_parserARG_PDECL A parameter declaration for the %extra_argument
** pik_parserARG_PARAM Code to pass %extra_argument as a subroutine parameter
** pik_parserARG_STORE Code to store %extra_argument into yypParser
** pik_parserARG_FETCH Code to extract %extra_argument from yypParser
** pik_parserCTX_* As pik_parserARG_ except for %extra_context
** YYREALLOC Name of the realloc() function to use
** YYFREE Name of the free() function to use
** YYDYNSTACK True if stack space should be extended on heap
** YYERRORSYMBOL is the code number of the error symbol. If not
** defined, then do no error processing.
** YYNSTATE the combined number of states.
** YYNRULE the number of rules in the grammar
** YYNTOKEN Number of terminal symbols
** YY_MAX_SHIFT Maximum value for shift actions
** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
** YY_ERROR_ACTION The yy_action[] code for syntax error
** YY_ACCEPT_ACTION The yy_action[] code for accept
** YY_NO_ACTION The yy_action[] code for no-op
** YY_MIN_REDUCE Minimum value for reduce actions
** YY_MAX_REDUCE Maximum value for reduce actions
** YY_MIN_DSTRCTR Minimum symbol value that has a destructor
** YY_MAX_DSTRCTR Maximum symbol value that has a destructor
*/
#ifndef INTERFACE
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned char
#define YYNOCODE 136
#define YYACTIONTYPE unsigned short int
#define pik_parserTOKENTYPE PToken
typedef union {
int yyinit;
pik_parserTOKENTYPE yy0;
PNum yy21;
PPoint yy63;
PRel yy72;
PObj* yy162;
short int yy188;
PList* yy235;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#endif
#define pik_parserARG_SDECL
#define pik_parserARG_PDECL
#define pik_parserARG_PARAM
#define pik_parserARG_FETCH
#define pik_parserARG_STORE
#define YYREALLOC realloc
#define YYFREE free
#define YYDYNSTACK 0
#define pik_parserCTX_SDECL Pik *p;
#define pik_parserCTX_PDECL ,Pik *p
#define pik_parserCTX_PARAM ,p
#define pik_parserCTX_FETCH Pik *p=yypParser->p;
#define pik_parserCTX_STORE yypParser->p=p;
#define YYFALLBACK 1
#define YYNSTATE 164
#define YYNRULE 156
#define YYNRULE_WITH_ACTION 116
#define YYNTOKEN 100
#define YY_MAX_SHIFT 163
#define YY_MIN_SHIFTREDUCE 287
#define YY_MAX_SHIFTREDUCE 442
#define YY_ERROR_ACTION 443
#define YY_ACCEPT_ACTION 444
#define YY_NO_ACTION 445
#define YY_MIN_REDUCE 446
#define YY_MAX_REDUCE 601
#define YY_MIN_DSTRCTR 100
#define YY_MAX_DSTRCTR 103
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
/* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
** Applications can choose to define yytestcase() in the %include section
** to a macro that can assist in verifying code coverage. For production
** code the yytestcase() macro should be turned off. But it is useful
** for testing.
*/
#ifndef yytestcase
# define yytestcase(X)
#endif
/* Macro to determine if stack space has the ability to grow using
** heap memory.
*/
#if YYSTACKDEPTH<=0 || YYDYNSTACK
# define YYGROWABLESTACK 1
#else
# define YYGROWABLESTACK 0
#endif
/* Guarantee a minimum number of initial stack slots.
*/
#if YYSTACKDEPTH<=0
# undef YYSTACKDEPTH
# define YYSTACKDEPTH 2 /* Need a minimum stack size */
#endif
/* Next are the tables used to determine what action to take based on the
** current state and lookahead token. These tables are used to implement
** functions that take a state number and lookahead value and return an
** action integer.
**
** Suppose the action integer is N. Then the action is determined as
** follows
**
** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead
** token onto the stack and goto state N.
**
** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
**
** N == YY_ERROR_ACTION A syntax error has occurred.
**
** N == YY_ACCEPT_ACTION The parser accepts its input.
**
** N == YY_NO_ACTION No such action. Denotes unused
** slots in the yy_action[] table.
**
** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
** and YY_MAX_REDUCE
**
** The action table is constructed as a single large table named yy_action[].
** Given state S and lookahead X, the action is computed as either:
**
** (A) N = yy_action[ yy_shift_ofst[S] + X ]
** (B) N = yy_default[S]
**
** The (A) formula is preferred. The B formula is used instead if
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
**
** The formulas above are for computing the action when the lookahead is
** a terminal symbol. If the lookahead is a non-terminal (as occurs after
** a reduce action) then the yy_reduce_ofst[] array is used in place of
** the yy_shift_ofst[] array.
**
** The following are the tables generated in this section:
**
** yy_action[] A single table containing all actions.
** yy_lookahead[] A table containing the lookahead for each entry in
** yy_action. Used to detect hash collisions.
** yy_shift_ofst[] For each state, the offset into yy_action for
** shifting terminals.
** yy_reduce_ofst[] For each state, the offset into yy_action for
** shifting non-terminals after a reduce.
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (1313)
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 575, 495, 161, 119, 25, 452, 29, 74, 129, 148,
/* 10 */ 575, 492, 161, 119, 453, 113, 120, 161, 119, 530,
/* 20 */ 427, 428, 339, 559, 81, 30, 560, 561, 575, 64,
/* 30 */ 63, 62, 61, 322, 323, 9, 8, 33, 149, 32,
/* 40 */ 7, 71, 127, 38, 335, 66, 48, 37, 28, 339,
/* 50 */ 339, 339, 339, 425, 426, 340, 341, 342, 343, 344,
/* 60 */ 345, 346, 347, 348, 474, 528, 161, 119, 577, 77,
/* 70 */ 577, 73, 306, 148, 474, 533, 161, 119, 112, 113,
/* 80 */ 120, 161, 119, 128, 427, 428, 339, 31, 81, 531,
/* 90 */ 161, 119, 474, 35, 330, 378, 158, 322, 323, 9,
/* 100 */ 8, 33, 149, 32, 7, 71, 127, 328, 335, 66,
/* 110 */ 579, 378, 158, 339, 339, 339, 339, 425, 426, 340,
/* 120 */ 341, 342, 343, 344, 345, 346, 347, 348, 394, 435,
/* 130 */ 46, 59, 60, 64, 63, 62, 61, 357, 36, 376,
/* 140 */ 54, 51, 2, 47, 403, 13, 297, 411, 412, 413,
/* 150 */ 414, 80, 162, 308, 79, 133, 310, 126, 441, 440,
/* 160 */ 118, 123, 83, 404, 405, 406, 408, 80, 84, 308,
/* 170 */ 79, 299, 411, 412, 413, 414, 118, 69, 350, 350,
/* 180 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 62,
/* 190 */ 61, 434, 64, 63, 62, 61, 313, 398, 399, 427,
/* 200 */ 428, 339, 380, 157, 64, 63, 62, 61, 122, 106,
/* 210 */ 535, 436, 437, 438, 439, 298, 375, 391, 117, 393,
/* 220 */ 155, 154, 153, 394, 435, 49, 59, 60, 339, 339,
/* 230 */ 339, 339, 425, 426, 376, 3, 4, 2, 64, 63,
/* 240 */ 62, 61, 156, 156, 156, 394, 379, 159, 59, 60,
/* 250 */ 76, 67, 535, 441, 440, 5, 102, 6, 535, 42,
/* 260 */ 131, 535, 69, 107, 301, 302, 303, 394, 305, 15,
/* 270 */ 59, 60, 120, 161, 119, 446, 463, 424, 376, 423,
/* 280 */ 1, 42, 397, 78, 78, 36, 434, 11, 394, 435,
/* 290 */ 356, 59, 60, 12, 152, 139, 432, 14, 16, 376,
/* 300 */ 18, 65, 2, 138, 106, 430, 436, 437, 438, 439,
/* 310 */ 44, 375, 19, 117, 393, 155, 154, 153, 441, 440,
/* 320 */ 142, 140, 64, 63, 62, 61, 106, 20, 68, 376,
/* 330 */ 359, 107, 23, 375, 45, 117, 393, 155, 154, 153,
/* 340 */ 120, 161, 119, 55, 463, 114, 26, 57, 106, 147,
/* 350 */ 146, 434, 569, 58, 392, 375, 43, 117, 393, 155,
/* 360 */ 154, 153, 152, 384, 64, 63, 62, 61, 382, 106,
/* 370 */ 383, 436, 437, 438, 439, 377, 375, 70, 117, 393,
/* 380 */ 155, 154, 153, 160, 39, 22, 21, 445, 142, 140,
/* 390 */ 64, 63, 62, 61, 24, 17, 145, 141, 431, 108,
/* 400 */ 445, 445, 445, 391, 445, 445, 375, 445, 117, 445,
/* 410 */ 445, 55, 74, 445, 148, 445, 445, 147, 146, 124,
/* 420 */ 113, 120, 161, 119, 43, 445, 445, 142, 140, 64,
/* 430 */ 63, 62, 61, 445, 394, 445, 445, 59, 60, 64,
/* 440 */ 63, 62, 61, 149, 445, 376, 445, 445, 42, 445,
/* 450 */ 55, 445, 391, 22, 21, 445, 147, 146, 445, 445,
/* 460 */ 52, 445, 24, 43, 145, 141, 431, 394, 445, 445,
/* 470 */ 59, 60, 64, 63, 62, 61, 445, 445, 376, 132,
/* 480 */ 130, 42, 445, 445, 445, 355, 156, 156, 156, 445,
/* 490 */ 445, 445, 22, 21, 445, 394, 473, 445, 59, 60,
/* 500 */ 445, 24, 445, 145, 141, 431, 376, 445, 107, 42,
/* 510 */ 64, 63, 62, 61, 445, 106, 445, 120, 161, 119,
/* 520 */ 445, 478, 375, 354, 117, 393, 155, 154, 153, 445,
/* 530 */ 394, 143, 473, 59, 60, 64, 63, 62, 61, 152,
/* 540 */ 445, 376, 445, 445, 42, 445, 445, 445, 106, 64,
/* 550 */ 63, 62, 61, 445, 445, 375, 50, 117, 393, 155,
/* 560 */ 154, 153, 445, 394, 144, 445, 59, 60, 445, 445,
/* 570 */ 53, 72, 445, 148, 376, 445, 106, 42, 125, 113,
/* 580 */ 120, 161, 119, 375, 445, 117, 393, 155, 154, 153,
/* 590 */ 394, 445, 445, 59, 60, 445, 445, 445, 445, 445,
/* 600 */ 445, 102, 149, 445, 42, 445, 74, 445, 148, 445,
/* 610 */ 445, 106, 445, 497, 113, 120, 161, 119, 375, 445,
/* 620 */ 117, 393, 155, 154, 153, 394, 445, 445, 59, 60,
/* 630 */ 445, 445, 88, 445, 445, 445, 376, 149, 445, 40,
/* 640 */ 445, 120, 161, 119, 106, 445, 445, 435, 110, 110,
/* 650 */ 445, 375, 445, 117, 393, 155, 154, 153, 394, 445,
/* 660 */ 445, 59, 60, 152, 85, 445, 445, 445, 445, 376,
/* 670 */ 445, 106, 41, 120, 161, 119, 441, 440, 375, 445,
/* 680 */ 117, 393, 155, 154, 153, 448, 454, 29, 445, 445,
/* 690 */ 74, 450, 148, 75, 88, 152, 445, 496, 113, 120,
/* 700 */ 161, 119, 163, 120, 161, 119, 106, 27, 445, 434,
/* 710 */ 111, 111, 445, 375, 445, 117, 393, 155, 154, 153,
/* 720 */ 445, 149, 445, 445, 445, 152, 74, 445, 148, 436,
/* 730 */ 437, 438, 439, 490, 113, 120, 161, 119, 445, 106,
/* 740 */ 121, 447, 454, 29, 445, 445, 375, 450, 117, 393,
/* 750 */ 155, 154, 153, 445, 445, 445, 445, 149, 163, 74,
/* 760 */ 445, 148, 444, 27, 445, 445, 484, 113, 120, 161,
/* 770 */ 119, 445, 445, 445, 74, 445, 148, 445, 445, 445,
/* 780 */ 445, 483, 113, 120, 161, 119, 74, 445, 148, 86,
/* 790 */ 149, 445, 445, 480, 113, 120, 161, 119, 120, 161,
/* 800 */ 119, 445, 74, 445, 148, 149, 445, 445, 445, 134,
/* 810 */ 113, 120, 161, 119, 74, 445, 148, 149, 445, 445,
/* 820 */ 152, 517, 113, 120, 161, 119, 88, 64, 63, 62,
/* 830 */ 61, 445, 445, 149, 445, 120, 161, 119, 445, 74,
/* 840 */ 396, 148, 475, 445, 445, 149, 137, 113, 120, 161,
/* 850 */ 119, 74, 445, 148, 445, 445, 445, 152, 525, 113,
/* 860 */ 120, 161, 119, 445, 74, 445, 148, 445, 445, 445,
/* 870 */ 149, 527, 113, 120, 161, 119, 445, 445, 445, 74,
/* 880 */ 445, 148, 149, 445, 445, 445, 524, 113, 120, 161,
/* 890 */ 119, 74, 445, 148, 98, 149, 445, 445, 526, 113,
/* 900 */ 120, 161, 119, 120, 161, 119, 445, 74, 445, 148,
/* 910 */ 149, 445, 445, 445, 523, 113, 120, 161, 119, 74,
/* 920 */ 445, 148, 149, 445, 445, 152, 522, 113, 120, 161,
/* 930 */ 119, 89, 64, 63, 62, 61, 445, 445, 149, 445,
/* 940 */ 120, 161, 119, 445, 74, 395, 148, 445, 445, 445,
/* 950 */ 149, 521, 113, 120, 161, 119, 74, 445, 148, 445,
/* 960 */ 445, 445, 152, 520, 113, 120, 161, 119, 445, 74,
/* 970 */ 445, 148, 445, 445, 445, 149, 519, 113, 120, 161,
/* 980 */ 119, 445, 445, 445, 74, 445, 148, 149, 445, 445,
/* 990 */ 445, 150, 113, 120, 161, 119, 74, 445, 148, 90,
/* 1000 */ 149, 445, 445, 151, 113, 120, 161, 119, 120, 161,
/* 1010 */ 119, 445, 74, 445, 148, 149, 445, 435, 445, 136,
/* 1020 */ 113, 120, 161, 119, 74, 445, 148, 149, 445, 445,
/* 1030 */ 152, 135, 113, 120, 161, 119, 64, 63, 62, 61,
/* 1040 */ 445, 445, 445, 149, 445, 445, 441, 440, 445, 88,
/* 1050 */ 445, 445, 445, 445, 445, 149, 445, 56, 120, 161,
/* 1060 */ 119, 88, 445, 445, 10, 479, 479, 445, 445, 445,
/* 1070 */ 120, 161, 119, 445, 445, 445, 445, 82, 445, 434,
/* 1080 */ 152, 445, 445, 445, 466, 445, 34, 109, 447, 454,
/* 1090 */ 29, 445, 152, 445, 450, 445, 445, 445, 107, 436,
/* 1100 */ 437, 438, 439, 87, 445, 163, 445, 120, 161, 119,
/* 1110 */ 27, 451, 120, 161, 119, 99, 445, 64, 63, 62,
/* 1120 */ 61, 445, 100, 445, 120, 161, 119, 101, 445, 152,
/* 1130 */ 391, 120, 161, 119, 152, 445, 120, 161, 119, 91,
/* 1140 */ 445, 445, 445, 445, 445, 445, 152, 445, 120, 161,
/* 1150 */ 119, 103, 445, 152, 92, 445, 445, 445, 152, 445,
/* 1160 */ 120, 161, 119, 120, 161, 119, 93, 445, 445, 104,
/* 1170 */ 152, 445, 445, 445, 445, 120, 161, 119, 120, 161,
/* 1180 */ 119, 445, 152, 445, 94, 152, 445, 445, 445, 445,
/* 1190 */ 445, 445, 105, 120, 161, 119, 445, 152, 445, 95,
/* 1200 */ 152, 120, 161, 119, 445, 445, 445, 96, 120, 161,
/* 1210 */ 119, 445, 445, 445, 445, 152, 120, 161, 119, 445,
/* 1220 */ 445, 445, 445, 152, 445, 445, 445, 445, 445, 445,
/* 1230 */ 152, 97, 445, 445, 549, 445, 445, 548, 152, 445,
/* 1240 */ 120, 161, 119, 120, 161, 119, 120, 161, 119, 445,
/* 1250 */ 445, 445, 445, 445, 445, 445, 445, 445, 445, 445,
/* 1260 */ 445, 445, 152, 547, 445, 152, 546, 445, 152, 115,
/* 1270 */ 445, 445, 120, 161, 119, 120, 161, 119, 120, 161,
/* 1280 */ 119, 116, 445, 445, 445, 445, 445, 445, 445, 445,
/* 1290 */ 120, 161, 119, 445, 152, 445, 445, 152, 445, 445,
/* 1300 */ 152, 445, 445, 445, 445, 445, 445, 445, 445, 445,
/* 1310 */ 445, 445, 152,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 0, 113, 114, 115, 134, 102, 103, 104, 106, 106,
/* 10 */ 10, 113, 114, 115, 111, 112, 113, 114, 115, 106,
/* 20 */ 20, 21, 22, 105, 24, 126, 108, 109, 28, 4,
/* 30 */ 5, 6, 7, 33, 34, 35, 36, 37, 135, 39,
/* 40 */ 40, 41, 42, 105, 44, 45, 108, 109, 107, 49,
/* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
/* 60 */ 60, 61, 62, 63, 0, 113, 114, 115, 130, 131,
/* 70 */ 132, 104, 25, 106, 10, 113, 114, 115, 111, 112,
/* 80 */ 113, 114, 115, 106, 20, 21, 22, 128, 24, 113,
/* 90 */ 114, 115, 28, 129, 2, 26, 27, 33, 34, 35,
/* 100 */ 36, 37, 135, 39, 40, 41, 42, 2, 44, 45,
/* 110 */ 133, 26, 27, 49, 50, 51, 52, 53, 54, 55,
/* 120 */ 56, 57, 58, 59, 60, 61, 62, 63, 1, 2,
/* 130 */ 38, 4, 5, 4, 5, 6, 7, 17, 10, 12,
/* 140 */ 4, 5, 15, 38, 1, 25, 17, 29, 30, 31,
/* 150 */ 32, 24, 83, 26, 27, 12, 28, 14, 31, 32,
/* 160 */ 91, 18, 116, 20, 21, 22, 23, 24, 116, 26,
/* 170 */ 27, 19, 29, 30, 31, 32, 91, 3, 64, 65,
/* 180 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 6,
/* 190 */ 7, 64, 4, 5, 6, 7, 8, 97, 98, 20,
/* 200 */ 21, 22, 26, 27, 4, 5, 6, 7, 1, 82,
/* 210 */ 48, 84, 85, 86, 87, 17, 89, 17, 91, 92,
/* 220 */ 93, 94, 95, 1, 2, 25, 4, 5, 49, 50,
/* 230 */ 51, 52, 53, 54, 12, 16, 15, 15, 4, 5,
/* 240 */ 6, 7, 20, 21, 22, 1, 26, 27, 4, 5,
/* 250 */ 48, 43, 90, 31, 32, 40, 12, 40, 96, 15,
/* 260 */ 47, 99, 88, 104, 20, 21, 22, 1, 24, 35,
/* 270 */ 4, 5, 113, 114, 115, 0, 117, 41, 12, 41,
/* 280 */ 13, 15, 17, 124, 125, 10, 64, 25, 1, 2,
/* 290 */ 17, 4, 5, 75, 135, 81, 80, 3, 3, 12,
/* 300 */ 3, 99, 15, 79, 82, 80, 84, 85, 86, 87,
/* 310 */ 38, 89, 3, 91, 92, 93, 94, 95, 31, 32,
/* 320 */ 2, 3, 4, 5, 6, 7, 82, 3, 3, 12,
/* 330 */ 77, 104, 25, 89, 16, 91, 92, 93, 94, 95,
/* 340 */ 113, 114, 115, 25, 117, 96, 15, 15, 82, 31,
/* 350 */ 32, 64, 125, 15, 17, 89, 38, 91, 92, 93,
/* 360 */ 94, 95, 135, 28, 4, 5, 6, 7, 28, 82,
/* 370 */ 28, 84, 85, 86, 87, 12, 89, 3, 91, 92,
/* 380 */ 93, 94, 95, 90, 11, 67, 68, 136, 2, 3,
/* 390 */ 4, 5, 6, 7, 76, 35, 78, 79, 80, 82,
/* 400 */ 136, 136, 136, 17, 136, 136, 89, 136, 91, 136,
/* 410 */ 136, 25, 104, 136, 106, 136, 136, 31, 32, 111,
/* 420 */ 112, 113, 114, 115, 38, 136, 136, 2, 3, 4,
/* 430 */ 5, 6, 7, 136, 1, 136, 136, 4, 5, 4,
/* 440 */ 5, 6, 7, 135, 136, 12, 136, 136, 15, 136,
/* 450 */ 25, 136, 17, 67, 68, 136, 31, 32, 136, 136,
/* 460 */ 25, 136, 76, 38, 78, 79, 80, 1, 136, 136,
/* 470 */ 4, 5, 4, 5, 6, 7, 136, 136, 12, 46,
/* 480 */ 47, 15, 136, 136, 136, 17, 20, 21, 22, 136,
/* 490 */ 136, 136, 67, 68, 136, 1, 2, 136, 4, 5,
/* 500 */ 136, 76, 136, 78, 79, 80, 12, 136, 104, 15,
/* 510 */ 4, 5, 6, 7, 136, 82, 136, 113, 114, 115,
/* 520 */ 136, 117, 89, 17, 91, 92, 93, 94, 95, 136,
/* 530 */ 1, 2, 38, 4, 5, 4, 5, 6, 7, 135,
/* 540 */ 136, 12, 136, 136, 15, 136, 136, 136, 82, 4,
/* 550 */ 5, 6, 7, 136, 136, 89, 25, 91, 92, 93,
/* 560 */ 94, 95, 136, 1, 2, 136, 4, 5, 136, 136,
/* 570 */ 25, 104, 136, 106, 12, 136, 82, 15, 111, 112,
/* 580 */ 113, 114, 115, 89, 136, 91, 92, 93, 94, 95,
/* 590 */ 1, 136, 136, 4, 5, 136, 136, 136, 136, 136,
/* 600 */ 136, 12, 135, 136, 15, 136, 104, 136, 106, 136,
/* 610 */ 136, 82, 136, 111, 112, 113, 114, 115, 89, 136,
/* 620 */ 91, 92, 93, 94, 95, 1, 136, 136, 4, 5,
/* 630 */ 136, 136, 104, 136, 136, 136, 12, 135, 136, 15,
/* 640 */ 136, 113, 114, 115, 82, 136, 136, 2, 120, 121,
/* 650 */ 136, 89, 136, 91, 92, 93, 94, 95, 1, 136,
/* 660 */ 136, 4, 5, 135, 104, 136, 136, 136, 136, 12,
/* 670 */ 136, 82, 15, 113, 114, 115, 31, 32, 89, 136,