0000: 2f 2a 20 44 72 69 76 65 72 20 74 65 6d 70 6c 61 /* Driver templa
0010: 74 65 20 66 6f 72 20 74 68 65 20 4c 45 4d 4f 4e te for the LEMON
0020: 20 70 61 72 73 65 72 20 67 65 6e 65 72 61 74 6f parser generato
0030: 72 2e 0a 2a 2a 20 54 68 65 20 61 75 74 68 6f 72 r..** The author
0040: 20 64 69 73 63 6c 61 69 6d 73 20 63 6f 70 79 72 disclaims copyr
0050: 69 67 68 74 20 74 6f 20 74 68 69 73 20 73 6f 75 ight to this sou
0060: 72 63 65 20 63 6f 64 65 2e 0a 2a 2a 0a 2a 2a 20 rce code..**.**
0070: 54 68 69 73 20 76 65 72 73 69 6f 6e 20 6f 66 20 This version of
0080: 22 6c 65 6d 70 61 72 2e 63 22 20 69 73 20 6d 6f "lempar.c" is mo
0090: 64 69 66 69 65 64 2c 20 73 6c 69 67 68 74 6c 79 dified, slightly
00a0: 2c 20 66 6f 72 20 75 73 65 20 62 79 20 53 51 4c , for use by SQL
00b0: 69 74 65 2e 0a 2a 2a 20 54 68 65 20 6f 6e 6c 79 ite..** The only
00c0: 20 6d 6f 64 69 66 69 63 61 74 69 6f 6e 73 20 61 modifications a
00d0: 72 65 20 74 68 65 20 61 64 64 69 74 69 6f 6e 20 re the addition
00e0: 6f 66 20 61 20 63 6f 75 70 6c 65 20 6f 66 20 4e of a couple of N
00f0: 45 56 45 52 28 29 0a 2a 2a 20 6d 61 63 72 6f 73 EVER().** macros
0100: 20 74 6f 20 64 69 73 61 62 6c 65 20 74 65 73 74 to disable test
0110: 73 20 74 68 61 74 20 61 72 65 20 6e 65 65 64 65 s that are neede
0120: 64 20 69 6e 20 74 68 65 20 63 61 73 65 20 6f 66 d in the case of
0130: 20 61 20 67 65 6e 65 72 61 6c 0a 2a 2a 20 4c 41 a general.** LA
0140: 4c 52 28 31 29 20 67 72 61 6d 6d 61 72 20 62 75 LR(1) grammar bu
0150: 74 20 77 68 69 63 68 20 61 72 65 20 61 6c 77 61 t which are alwa
0160: 79 73 20 66 61 6c 73 65 20 69 6e 20 74 68 65 0a ys false in the.
0170: 2a 2a 20 73 70 65 63 69 66 69 63 20 67 72 61 6d ** specific gram
0180: 6d 61 72 20 75 73 65 64 20 62 79 20 53 51 4c 69 mar used by SQLi
0190: 74 65 2e 0a 2a 2f 0a 2f 2a 20 46 69 72 73 74 20 te..*/./* First
01a0: 6f 66 66 2c 20 63 6f 64 65 20 69 73 20 69 6e 63 off, code is inc
01b0: 6c 75 64 65 64 20 74 68 61 74 20 66 6f 6c 6c 6f luded that follo
01c0: 77 73 20 74 68 65 20 22 69 6e 63 6c 75 64 65 22 ws the "include"
01d0: 20 64 65 63 6c 61 72 61 74 69 6f 6e 0a 2a 2a 20 declaration.**
01e0: 69 6e 20 74 68 65 20 69 6e 70 75 74 20 67 72 61 in the input gra
01f0: 6d 6d 61 72 20 66 69 6c 65 2e 20 2a 2f 0a 23 69 mmar file. */.#i
0200: 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e 68 3e nclude <stdio.h>
0210: 0a 25 25 0a 2f 2a 20 4e 65 78 74 20 69 73 20 61 .%%./* Next is a
0220: 6c 6c 20 74 6f 6b 65 6e 20 76 61 6c 75 65 73 2c ll token values,
0230: 20 69 6e 20 61 20 66 6f 72 6d 20 73 75 69 74 61 in a form suita
0240: 62 6c 65 20 66 6f 72 20 75 73 65 20 62 79 20 6d ble for use by m
0250: 61 6b 65 68 65 61 64 65 72 73 2e 0a 2a 2a 20 54 akeheaders..** T
0260: 68 69 73 20 73 65 63 74 69 6f 6e 20 77 69 6c 6c his section will
0270: 20 62 65 20 6e 75 6c 6c 20 75 6e 6c 65 73 73 20 be null unless
0280: 6c 65 6d 6f 6e 20 69 73 20 72 75 6e 20 77 69 74 lemon is run wit
0290: 68 20 74 68 65 20 2d 6d 20 73 77 69 74 63 68 2e h the -m switch.
02a0: 0a 2a 2f 0a 2f 2a 20 0a 2a 2a 20 54 68 65 73 65 .*/./* .** These
02b0: 20 63 6f 6e 73 74 61 6e 74 73 20 28 61 6c 6c 20 constants (all
02c0: 67 65 6e 65 72 61 74 65 64 20 61 75 74 6f 6d 61 generated automa
02d0: 74 69 63 61 6c 6c 79 20 62 79 20 74 68 65 20 70 tically by the p
02e0: 61 72 73 65 72 20 67 65 6e 65 72 61 74 6f 72 29 arser generator)
02f0: 0a 2a 2a 20 73 70 65 63 69 66 79 20 74 68 65 20 .** specify the
0300: 76 61 72 69 6f 75 73 20 6b 69 6e 64 73 20 6f 66 various kinds of
0310: 20 74 6f 6b 65 6e 73 20 28 74 65 72 6d 69 6e 61 tokens (termina
0320: 6c 73 29 20 74 68 61 74 20 74 68 65 20 70 61 72 ls) that the par
0330: 73 65 72 0a 2a 2a 20 75 6e 64 65 72 73 74 61 6e ser.** understan
0340: 64 73 2e 20 0a 2a 2a 0a 2a 2a 20 45 61 63 68 20 ds. .**.** Each
0350: 73 79 6d 62 6f 6c 20 68 65 72 65 20 69 73 20 61 symbol here is a
0360: 20 74 65 72 6d 69 6e 61 6c 20 73 79 6d 62 6f 6c terminal symbol
0370: 20 69 6e 20 74 68 65 20 67 72 61 6d 6d 61 72 2e in the grammar.
0380: 0a 2a 2f 0a 25 25 0a 2f 2a 20 4d 61 6b 65 20 73 .*/.%%./* Make s
0390: 75 72 65 20 74 68 65 20 49 4e 54 45 52 46 41 43 ure the INTERFAC
03a0: 45 20 6d 61 63 72 6f 20 69 73 20 64 65 66 69 6e E macro is defin
03b0: 65 64 2e 0a 2a 2f 0a 23 69 66 6e 64 65 66 20 49 ed..*/.#ifndef I
03c0: 4e 54 45 52 46 41 43 45 0a 23 20 64 65 66 69 6e NTERFACE.# defin
03d0: 65 20 49 4e 54 45 52 46 41 43 45 20 31 0a 23 65 e INTERFACE 1.#e
03e0: 6e 64 69 66 0a 2f 2a 20 54 68 65 20 6e 65 78 74 ndif./* The next
03f0: 20 74 68 69 6e 67 20 69 6e 63 6c 75 64 65 64 20 thing included
0400: 69 73 20 73 65 72 69 65 73 20 6f 66 20 64 65 66 is series of def
0410: 69 6e 65 73 20 77 68 69 63 68 20 63 6f 6e 74 72 ines which contr
0420: 6f 6c 0a 2a 2a 20 76 61 72 69 6f 75 73 20 61 73 ol.** various as
0430: 70 65 63 74 73 20 6f 66 20 74 68 65 20 67 65 6e pects of the gen
0440: 65 72 61 74 65 64 20 70 61 72 73 65 72 2e 0a 2a erated parser..*
0450: 2a 20 20 20 20 59 59 43 4f 44 45 54 59 50 45 20 * YYCODETYPE
0460: 20 20 20 20 20 20 20 20 69 73 20 74 68 65 20 64 is the d
0470: 61 74 61 20 74 79 70 65 20 75 73 65 64 20 66 6f ata type used fo
0480: 72 20 73 74 6f 72 69 6e 67 20 74 65 72 6d 69 6e r storing termin
0490: 61 6c 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 20 al.**
04a0: 20 20 20 20 20 20 20 20 20 20 20 20 61 6e 64 20 and
04b0: 6e 6f 6e 74 65 72 6d 69 6e 61 6c 20 6e 75 6d 62 nonterminal numb
04c0: 65 72 73 2e 20 20 22 75 6e 73 69 67 6e 65 64 20 ers. "unsigned
04d0: 63 68 61 72 22 20 69 73 0a 2a 2a 20 20 20 20 20 char" is.**
04e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
04f0: 20 20 75 73 65 64 20 69 66 20 74 68 65 72 65 20 used if there
0500: 61 72 65 20 66 65 77 65 72 20 74 68 61 6e 20 32 are fewer than 2
0510: 35 30 20 74 65 72 6d 69 6e 61 6c 73 0a 2a 2a 20 50 terminals.**
0520: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0530: 20 20 20 20 20 20 61 6e 64 20 6e 6f 6e 74 65 72 and nonter
0540: 6d 69 6e 61 6c 73 2e 20 20 22 69 6e 74 22 20 69 minals. "int" i
0550: 73 20 75 73 65 64 20 6f 74 68 65 72 77 69 73 65 s used otherwise
0560: 2e 0a 2a 2a 20 20 20 20 59 59 4e 4f 43 4f 44 45 ..** YYNOCODE
0570: 20 20 20 20 20 20 20 20 20 20 20 69 73 20 61 20 is a
0580: 6e 75 6d 62 65 72 20 6f 66 20 74 79 70 65 20 59 number of type Y
0590: 59 43 4f 44 45 54 59 50 45 20 77 68 69 63 68 20 YCODETYPE which
05a0: 63 6f 72 72 65 73 70 6f 6e 64 73 0a 2a 2a 20 20 corresponds.**
05b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
05c0: 20 20 20 20 20 74 6f 20 6e 6f 20 6c 65 67 61 6c to no legal
05d0: 20 74 65 72 6d 69 6e 61 6c 20 6f 72 20 6e 6f 6e terminal or non
05e0: 74 65 72 6d 69 6e 61 6c 20 6e 75 6d 62 65 72 2e terminal number.
05f0: 20 20 54 68 69 73 0a 2a 2a 20 20 20 20 20 20 20 This.**
0600: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0610: 6e 75 6d 62 65 72 20 69 73 20 75 73 65 64 20 74 number is used t
0620: 6f 20 66 69 6c 6c 20 69 6e 20 65 6d 70 74 79 20 o fill in empty
0630: 73 6c 6f 74 73 20 6f 66 20 74 68 65 20 68 61 73 slots of the has
0640: 68 20 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 20 h .**
0650: 20 20 20 20 20 20 20 20 20 20 20 20 74 61 62 6c tabl
0660: 65 2e 0a 2a 2a 20 20 20 20 59 59 46 41 4c 4c 42 e..** YYFALLB
0670: 41 43 4b 20 20 20 20 20 20 20 20 20 49 66 20 64 ACK If d
0680: 65 66 69 6e 65 64 2c 20 74 68 69 73 20 69 6e 64 efined, this ind
0690: 69 63 61 74 65 73 20 74 68 61 74 20 6f 6e 65 20 icates that one
06a0: 6f 72 20 6d 6f 72 65 20 74 6f 6b 65 6e 73 0a 2a or more tokens.*
06b0: 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 *
06c0: 20 20 20 20 20 20 20 20 68 61 76 65 20 66 61 6c have fal
06d0: 6c 2d 62 61 63 6b 20 76 61 6c 75 65 73 20 77 68 l-back values wh
06e0: 69 63 68 20 73 68 6f 75 6c 64 20 62 65 20 75 73 ich should be us
06f0: 65 64 20 69 66 20 74 68 65 0a 2a 2a 20 20 20 20 ed if the.**
0700: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0710: 20 20 20 6f 72 69 67 69 6e 61 6c 20 76 61 6c 75 original valu
0720: 65 20 6f 66 20 74 68 65 20 74 6f 6b 65 6e 20 77 e of the token w
0730: 69 6c 6c 20 6e 6f 74 20 70 61 72 73 65 2e 0a 2a ill not parse..*
0740: 2a 20 20 20 20 59 59 41 43 54 49 4f 4e 54 59 50 * YYACTIONTYP
0750: 45 20 20 20 20 20 20 20 69 73 20 74 68 65 20 64 E is the d
0760: 61 74 61 20 74 79 70 65 20 75 73 65 64 20 66 6f ata type used fo
0770: 72 20 73 74 6f 72 69 6e 67 20 74 65 72 6d 69 6e r storing termin
0780: 61 6c 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 20 al.**
0790: 20 20 20 20 20 20 20 20 20 20 20 20 61 6e 64 20 and
07a0: 6e 6f 6e 74 65 72 6d 69 6e 61 6c 20 6e 75 6d 62 nonterminal numb
07b0: 65 72 73 2e 20 20 22 75 6e 73 69 67 6e 65 64 20 ers. "unsigned
07c0: 63 68 61 72 22 20 69 73 0a 2a 2a 20 20 20 20 20 char" is.**
07d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
07e0: 20 20 75 73 65 64 20 69 66 20 74 68 65 72 65 20 used if there
07f0: 61 72 65 20 66 65 77 65 72 20 74 68 61 6e 20 32 are fewer than 2
0800: 35 30 20 72 75 6c 65 73 20 61 6e 64 0a 2a 2a 20 50 rules and.**
0810: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0820: 20 20 20 20 20 20 73 74 61 74 65 73 20 63 6f 6d states com
0830: 62 69 6e 65 64 2e 20 20 22 69 6e 74 22 20 69 73 bined. "int" is
0840: 20 75 73 65 64 20 6f 74 68 65 72 77 69 73 65 2e used otherwise.
0850: 0a 2a 2a 20 20 20 20 50 61 72 73 65 54 4f 4b 45 .** ParseTOKE
0860: 4e 54 59 50 45 20 20 20 20 20 69 73 20 74 68 65 NTYPE is the
0870: 20 64 61 74 61 20 74 79 70 65 20 75 73 65 64 20 data type used
0880: 66 6f 72 20 6d 69 6e 6f 72 20 74 6f 6b 65 6e 73 for minor tokens
0890: 20 67 69 76 65 6e 20 0a 2a 2a 20 20 20 20 20 20 given .**
08a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
08b0: 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74 68 65 directly to the
08c0: 20 70 61 72 73 65 72 20 66 72 6f 6d 20 74 68 65 parser from the
08d0: 20 74 6f 6b 65 6e 69 7a 65 72 2e 0a 2a 2a 20 20 tokenizer..**
08e0: 20 20 59 59 4d 49 4e 4f 52 54 59 50 45 20 20 20 YYMINORTYPE
08f0: 20 20 20 20 20 69 73 20 74 68 65 20 64 61 74 61 is the data
0900: 20 74 79 70 65 20 75 73 65 64 20 66 6f 72 20 61 type used for a
0910: 6c 6c 20 6d 69 6e 6f 72 20 74 6f 6b 65 6e 73 2e ll minor tokens.
0920: 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 .**
0930: 20 20 20 20 20 20 20 20 20 20 54 68 69 73 20 69 This i
0940: 73 20 74 79 70 69 63 61 6c 6c 79 20 61 20 75 6e s typically a un
0950: 69 6f 6e 20 6f 66 20 6d 61 6e 79 20 74 79 70 65 ion of many type
0960: 73 2c 20 6f 6e 65 20 6f 66 0a 2a 2a 20 20 20 20 s, one of.**
0970: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0980: 20 20 20 77 68 69 63 68 20 69 73 20 50 61 72 73 which is Pars
0990: 65 54 4f 4b 45 4e 54 59 50 45 2e 20 20 54 68 65 eTOKENTYPE. The
09a0: 20 65 6e 74 72 79 20 69 6e 20 74 68 65 20 75 6e entry in the un
09b0: 69 6f 6e 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 ion.**
09c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 for
09d0: 20 62 61 73 65 20 74 6f 6b 65 6e 73 20 69 73 20 base tokens is
09e0: 63 61 6c 6c 65 64 20 22 79 79 30 22 2e 0a 2a 2a called "yy0"..**
09f0: 20 20 20 20 59 59 53 54 41 43 4b 44 45 50 54 48 YYSTACKDEPTH
0a00: 20 20 20 20 20 20 20 69 73 20 74 68 65 20 6d 61 is the ma
0a10: 78 69 6d 75 6d 20 64 65 70 74 68 20 6f 66 20 74 ximum depth of t
0a20: 68 65 20 70 61 72 73 65 72 27 73 20 73 74 61 63 he parser's stac
0a30: 6b 2e 20 20 49 66 0a 2a 2a 20 20 20 20 20 20 20 k. If.**
0a40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0a50: 7a 65 72 6f 20 74 68 65 20 73 74 61 63 6b 20 69 zero the stack i
0a60: 73 20 64 79 6e 61 6d 69 63 61 6c 6c 79 20 73 69 s dynamically si
0a70: 7a 65 64 20 75 73 69 6e 67 20 72 65 61 6c 6c 6f zed using reallo
0a80: 63 28 29 0a 2a 2a 20 20 20 20 50 61 72 73 65 41 c().** ParseA
0a90: 52 47 5f 53 44 45 43 4c 20 20 20 20 20 41 20 73 RG_SDECL A s
0aa0: 74 61 74 69 63 20 76 61 72 69 61 62 6c 65 20 64 tatic variable d
0ab0: 65 63 6c 61 72 61 74 69 6f 6e 20 66 6f 72 20 74 eclaration for t
0ac0: 68 65 20 25 65 78 74 72 61 5f 61 72 67 75 6d 65 he %extra_argume
0ad0: 6e 74 0a 2a 2a 20 20 20 20 50 61 72 73 65 41 52 nt.** ParseAR
0ae0: 47 5f 50 44 45 43 4c 20 20 20 20 20 41 20 70 61 G_PDECL A pa
0af0: 72 61 6d 65 74 65 72 20 64 65 63 6c 61 72 61 74 rameter declarat
0b00: 69 6f 6e 20 66 6f 72 20 74 68 65 20 25 65 78 74 ion for the %ext
0b10: 72 61 5f 61 72 67 75 6d 65 6e 74 0a 2a 2a 20 20 ra_argument.**
0b20: 20 20 50 61 72 73 65 41 52 47 5f 53 54 4f 52 45 ParseARG_STORE
0b30: 20 20 20 20 20 43 6f 64 65 20 74 6f 20 73 74 6f Code to sto
0b40: 72 65 20 25 65 78 74 72 61 5f 61 72 67 75 6d 65 re %extra_argume
0b50: 6e 74 20 69 6e 74 6f 20 79 79 70 50 61 72 73 65 nt into yypParse
0b60: 72 0a 2a 2a 20 20 20 20 50 61 72 73 65 41 52 47 r.** ParseARG
0b70: 5f 46 45 54 43 48 20 20 20 20 20 43 6f 64 65 20 _FETCH Code
0b80: 74 6f 20 65 78 74 72 61 63 74 20 25 65 78 74 72 to extract %extr
0b90: 61 5f 61 72 67 75 6d 65 6e 74 20 66 72 6f 6d 20 a_argument from
0ba0: 79 79 70 50 61 72 73 65 72 0a 2a 2a 20 20 20 20 yypParser.**
0bb0: 59 59 4e 53 54 41 54 45 20 20 20 20 20 20 20 20 YYNSTATE
0bc0: 20 20 20 74 68 65 20 63 6f 6d 62 69 6e 65 64 20 the combined
0bd0: 6e 75 6d 62 65 72 20 6f 66 20 73 74 61 74 65 73 number of states
0be0: 2e 0a 2a 2a 20 20 20 20 59 59 4e 52 55 4c 45 20 ..** YYNRULE
0bf0: 20 20 20 20 20 20 20 20 20 20 20 74 68 65 20 6e the n
0c00: 75 6d 62 65 72 20 6f 66 20 72 75 6c 65 73 20 69 umber of rules i
0c10: 6e 20 74 68 65 20 67 72 61 6d 6d 61 72 0a 2a 2a n the grammar.**
0c20: 20 20 20 20 59 59 45 52 52 4f 52 53 59 4d 42 4f YYERRORSYMBO
0c30: 4c 20 20 20 20 20 20 69 73 20 74 68 65 20 63 6f L is the co
0c40: 64 65 20 6e 75 6d 62 65 72 20 6f 66 20 74 68 65 de number of the
0c50: 20 65 72 72 6f 72 20 73 79 6d 62 6f 6c 2e 20 20 error symbol.
0c60: 49 66 20 6e 6f 74 0a 2a 2a 20 20 20 20 20 20 20 If not.**
0c70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0c80: 64 65 66 69 6e 65 64 2c 20 74 68 65 6e 20 64 6f defined, then do
0c90: 20 6e 6f 20 65 72 72 6f 72 20 70 72 6f 63 65 73 no error proces
0ca0: 73 69 6e 67 2e 0a 2a 2f 0a 25 25 0a 23 64 65 66 sing..*/.%%.#def
0cb0: 69 6e 65 20 59 59 5f 4e 4f 5f 41 43 54 49 4f 4e ine YY_NO_ACTION
0cc0: 20 20 20 20 20 20 28 59 59 4e 53 54 41 54 45 2b (YYNSTATE+
0cd0: 59 59 4e 52 55 4c 45 2b 32 29 0a 23 64 65 66 69 YYNRULE+2).#defi
0ce0: 6e 65 20 59 59 5f 41 43 43 45 50 54 5f 41 43 54 ne YY_ACCEPT_ACT
0cf0: 49 4f 4e 20 20 28 59 59 4e 53 54 41 54 45 2b 59 ION (YYNSTATE+Y
0d00: 59 4e 52 55 4c 45 2b 31 29 0a 23 64 65 66 69 6e YNRULE+1).#defin
0d10: 65 20 59 59 5f 45 52 52 4f 52 5f 41 43 54 49 4f e YY_ERROR_ACTIO
0d20: 4e 20 20 20 28 59 59 4e 53 54 41 54 45 2b 59 59 N (YYNSTATE+YY
0d30: 4e 52 55 4c 45 29 0a 0a 2f 2a 20 54 68 65 20 79 NRULE)../* The y
0d40: 79 7a 65 72 6f 6d 69 6e 6f 72 20 63 6f 6e 73 74 yzerominor const
0d50: 61 6e 74 20 69 73 20 75 73 65 64 20 74 6f 20 69 ant is used to i
0d60: 6e 69 74 69 61 6c 69 7a 65 20 69 6e 73 74 61 6e nitialize instan
0d70: 63 65 73 20 6f 66 0a 2a 2a 20 59 59 4d 49 4e 4f ces of.** YYMINO
0d80: 52 54 59 50 45 20 6f 62 6a 65 63 74 73 20 74 6f RTYPE objects to
0d90: 20 7a 65 72 6f 2e 20 2a 2f 0a 73 74 61 74 69 63 zero. */.static
0da0: 20 63 6f 6e 73 74 20 59 59 4d 49 4e 4f 52 54 59 const YYMINORTY
0db0: 50 45 20 79 79 7a 65 72 6f 6d 69 6e 6f 72 20 3d PE yyzerominor =
0dc0: 20 7b 20 30 20 7d 3b 0a 0a 2f 2a 20 44 65 66 69 { 0 };../* Defi
0dd0: 6e 65 20 74 68 65 20 79 79 74 65 73 74 63 61 73 ne the yytestcas
0de0: 65 28 29 20 6d 61 63 72 6f 20 74 6f 20 62 65 20 e() macro to be
0df0: 61 20 6e 6f 2d 6f 70 20 69 66 20 69 73 20 6e 6f a no-op if is no
0e00: 74 20 61 6c 72 65 61 64 79 20 64 65 66 69 6e 65 t already define
0e10: 64 0a 2a 2a 20 6f 74 68 65 72 77 69 73 65 2e 0a d.** otherwise..
0e20: 2a 2a 0a 2a 2a 20 41 70 70 6c 69 63 61 74 69 6f **.** Applicatio
0e30: 6e 73 20 63 61 6e 20 63 68 6f 6f 73 65 20 74 6f ns can choose to
0e40: 20 64 65 66 69 6e 65 20 79 79 74 65 73 74 63 61 define yytestca
0e50: 73 65 28 29 20 69 6e 20 74 68 65 20 25 69 6e 63 se() in the %inc
0e60: 6c 75 64 65 20 73 65 63 74 69 6f 6e 0a 2a 2a 20 lude section.**
0e70: 74 6f 20 61 20 6d 61 63 72 6f 20 74 68 61 74 20 to a macro that
0e80: 63 61 6e 20 61 73 73 69 73 74 20 69 6e 20 76 65 can assist in ve
0e90: 72 69 66 79 69 6e 67 20 63 6f 64 65 20 63 6f 76 rifying code cov
0ea0: 65 72 61 67 65 2e 20 20 46 6f 72 20 70 72 6f 64 erage. For prod
0eb0: 75 63 74 69 6f 6e 0a 2a 2a 20 63 6f 64 65 20 74 uction.** code t
0ec0: 68 65 20 79 79 74 65 73 74 63 61 73 65 28 29 20 he yytestcase()
0ed0: 6d 61 63 72 6f 20 73 68 6f 75 6c 64 20 62 65 20 macro should be
0ee0: 74 75 72 6e 65 64 20 6f 66 66 2e 20 20 42 75 74 turned off. But
0ef0: 20 69 74 20 69 73 20 75 73 65 66 75 6c 0a 2a 2a it is useful.**
0f00: 20 66 6f 72 20 74 65 73 74 69 6e 67 2e 0a 2a 2f for testing..*/
0f10: 0a 23 69 66 6e 64 65 66 20 79 79 74 65 73 74 63 .#ifndef yytestc
0f20: 61 73 65 0a 23 20 64 65 66 69 6e 65 20 79 79 74 ase.# define yyt
0f30: 65 73 74 63 61 73 65 28 58 29 0a 23 65 6e 64 69 estcase(X).#endi
0f40: 66 0a 0a 0a 2f 2a 20 4e 65 78 74 20 61 72 65 20 f.../* Next are
0f50: 74 68 65 20 74 61 62 6c 65 73 20 75 73 65 64 20 the tables used
0f60: 74 6f 20 64 65 74 65 72 6d 69 6e 65 20 77 68 61 to determine wha
0f70: 74 20 61 63 74 69 6f 6e 20 74 6f 20 74 61 6b 65 t action to take
0f80: 20 62 61 73 65 64 20 6f 6e 20 74 68 65 0a 2a 2a based on the.**
0f90: 20 63 75 72 72 65 6e 74 20 73 74 61 74 65 20 61 current state a
0fa0: 6e 64 20 6c 6f 6f 6b 61 68 65 61 64 20 74 6f 6b nd lookahead tok
0fb0: 65 6e 2e 20 20 54 68 65 73 65 20 74 61 62 6c 65 en. These table
0fc0: 73 20 61 72 65 20 75 73 65 64 20 74 6f 20 69 6d s are used to im
0fd0: 70 6c 65 6d 65 6e 74 0a 2a 2a 20 66 75 6e 63 74 plement.** funct
0fe0: 69 6f 6e 73 20 74 68 61 74 20 74 61 6b 65 20 61 ions that take a
0ff0: 20 73 74 61 74 65 20 6e 75 6d 62 65 72 20 61 6e state number an
1000: 64 20 6c 6f 6f 6b 61 68 65 61 64 20 76 61 6c 75 d lookahead valu
1010: 65 20 61 6e 64 20 72 65 74 75 72 6e 20 61 6e 0a e and return an.
1020: 2a 2a 20 61 63 74 69 6f 6e 20 69 6e 74 65 67 65 ** action intege
1030: 72 2e 20 20 0a 2a 2a 0a 2a 2a 20 53 75 70 70 6f r. .**.** Suppo
1040: 73 65 20 74 68 65 20 61 63 74 69 6f 6e 20 69 6e se the action in
1050: 74 65 67 65 72 20 69 73 20 4e 2e 20 20 54 68 65 teger is N. The
1060: 6e 20 74 68 65 20 61 63 74 69 6f 6e 20 69 73 20 n the action is
1070: 64 65 74 65 72 6d 69 6e 65 64 20 61 73 0a 2a 2a determined as.**
1080: 20 66 6f 6c 6c 6f 77 73 0a 2a 2a 0a 2a 2a 20 20 follows.**.**
1090: 20 30 20 3c 3d 20 4e 20 3c 20 59 59 4e 53 54 41 0 <= N < YYNSTA
10a0: 54 45 20 20 20 20 20 20 20 20 20 20 20 20 20 20 TE
10b0: 20 20 20 20 53 68 69 66 74 20 4e 2e 20 20 54 68 Shift N. Th
10c0: 61 74 20 69 73 2c 20 70 75 73 68 20 74 68 65 20 at is, push the
10d0: 6c 6f 6f 6b 61 68 65 61 64 0a 2a 2a 20 20 20 20 lookahead.**
10e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
10f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1100: 20 20 74 6f 6b 65 6e 20 6f 6e 74 6f 20 74 68 65 token onto the
1110: 20 73 74 61 63 6b 20 61 6e 64 20 67 6f 74 6f 20 stack and goto
1120: 73 74 61 74 65 20 4e 2e 0a 2a 2a 0a 2a 2a 20 20 state N..**.**
1130: 20 59 59 4e 53 54 41 54 45 20 3c 3d 20 4e 20 3c YYNSTATE <= N <
1140: 20 59 59 4e 53 54 41 54 45 2b 59 59 4e 52 55 4c YYNSTATE+YYNRUL
1150: 45 20 20 20 52 65 64 75 63 65 20 62 79 20 72 75 E Reduce by ru
1160: 6c 65 20 4e 2d 59 59 4e 53 54 41 54 45 2e 0a 2a le N-YYNSTATE..*
1170: 2a 0a 2a 2a 20 20 20 4e 20 3d 3d 20 59 59 4e 53 *.** N == YYNS
1180: 54 41 54 45 2b 59 59 4e 52 55 4c 45 20 20 20 20 TATE+YYNRULE
1190: 20 20 20 20 20 20 20 20 20 20 41 20 73 79 6e 74 A synt
11a0: 61 78 20 65 72 72 6f 72 20 68 61 73 20 6f 63 63 ax error has occ
11b0: 75 72 72 65 64 2e 0a 2a 2a 0a 2a 2a 20 20 20 4e urred..**.** N
11c0: 20 3d 3d 20 59 59 4e 53 54 41 54 45 2b 59 59 4e == YYNSTATE+YYN
11d0: 52 55 4c 45 2b 31 20 20 20 20 20 20 20 20 20 20 RULE+1
11e0: 20 20 54 68 65 20 70 61 72 73 65 72 20 61 63 63 The parser acc
11f0: 65 70 74 73 20 69 74 73 20 69 6e 70 75 74 2e 0a epts its input..
1200: 2a 2a 0a 2a 2a 20 20 20 4e 20 3d 3d 20 59 59 4e **.** N == YYN
1210: 53 54 41 54 45 2b 59 59 4e 52 55 4c 45 2b 32 20 STATE+YYNRULE+2
1220: 20 20 20 20 20 20 20 20 20 20 20 4e 6f 20 73 75 No su
1230: 63 68 20 61 63 74 69 6f 6e 2e 20 20 44 65 6e 6f ch action. Deno
1240: 74 65 73 20 75 6e 75 73 65 64 0a 2a 2a 20 20 20 tes unused.**
1250: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1260: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1270: 20 20 20 73 6c 6f 74 73 20 69 6e 20 74 68 65 20 slots in the
1280: 79 79 5f 61 63 74 69 6f 6e 5b 5d 20 74 61 62 6c yy_action[] tabl
1290: 65 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 61 63 74 e..**.** The act
12a0: 69 6f 6e 20 74 61 62 6c 65 20 69 73 20 63 6f 6e ion table is con
12b0: 73 74 72 75 63 74 65 64 20 61 73 20 61 20 73 69 structed as a si
12c0: 6e 67 6c 65 20 6c 61 72 67 65 20 74 61 62 6c 65 ngle large table
12d0: 20 6e 61 6d 65 64 20 79 79 5f 61 63 74 69 6f 6e named yy_action
12e0: 5b 5d 2e 0a 2a 2a 20 47 69 76 65 6e 20 73 74 61 []..** Given sta
12f0: 74 65 20 53 20 61 6e 64 20 6c 6f 6f 6b 61 68 65 te S and lookahe
1300: 61 64 20 58 2c 20 74 68 65 20 61 63 74 69 6f 6e ad X, the action
1310: 20 69 73 20 63 6f 6d 70 75 74 65 64 20 61 73 0a is computed as.
1320: 2a 2a 0a 2a 2a 20 20 20 20 20 20 79 79 5f 61 63 **.** yy_ac
1330: 74 69 6f 6e 5b 20 79 79 5f 73 68 69 66 74 5f 6f tion[ yy_shift_o
1340: 66 73 74 5b 53 5d 20 2b 20 58 20 5d 0a 2a 2a 0a fst[S] + X ].**.
1350: 2a 2a 20 49 66 20 74 68 65 20 69 6e 64 65 78 20 ** If the index
1360: 76 61 6c 75 65 20 79 79 5f 73 68 69 66 74 5f 6f value yy_shift_o
1370: 66 73 74 5b 53 5d 2b 58 20 69 73 20 6f 75 74 20 fst[S]+X is out
1380: 6f 66 20 72 61 6e 67 65 20 6f 72 20 69 66 20 74 of range or if t
1390: 68 65 20 76 61 6c 75 65 0a 2a 2a 20 79 79 5f 6c he value.** yy_l
13a0: 6f 6f 6b 61 68 65 61 64 5b 79 79 5f 73 68 69 66 ookahead[yy_shif
13b0: 74 5f 6f 66 73 74 5b 53 5d 2b 58 5d 20 69 73 20 t_ofst[S]+X] is
13c0: 6e 6f 74 20 65 71 75 61 6c 20 74 6f 20 58 20 6f not equal to X o
13d0: 72 20 69 66 20 79 79 5f 73 68 69 66 74 5f 6f 66 r if yy_shift_of
13e0: 73 74 5b 53 5d 0a 2a 2a 20 69 73 20 65 71 75 61 st[S].** is equa
13f0: 6c 20 74 6f 20 59 59 5f 53 48 49 46 54 5f 55 53 l to YY_SHIFT_US
1400: 45 5f 44 46 4c 54 2c 20 69 74 20 6d 65 61 6e 73 E_DFLT, it means
1410: 20 74 68 61 74 20 74 68 65 20 61 63 74 69 6f 6e that the action
1420: 20 69 73 20 6e 6f 74 20 69 6e 20 74 68 65 20 74 is not in the t
1430: 61 62 6c 65 0a 2a 2a 20 61 6e 64 20 74 68 61 74 able.** and that
1440: 20 79 79 5f 64 65 66 61 75 6c 74 5b 53 5d 20 73 yy_default[S] s
1450: 68 6f 75 6c 64 20 62 65 20 75 73 65 64 20 69 6e hould be used in
1460: 73 74 65 61 64 2e 20 20 0a 2a 2a 0a 2a 2a 20 54 stead. .**.** T
1470: 68 65 20 66 6f 72 6d 75 6c 61 20 61 62 6f 76 65 he formula above
1480: 20 69 73 20 66 6f 72 20 63 6f 6d 70 75 74 69 6e is for computin
1490: 67 20 74 68 65 20 61 63 74 69 6f 6e 20 77 68 65 g the action whe
14a0: 6e 20 74 68 65 20 6c 6f 6f 6b 61 68 65 61 64 20 n the lookahead
14b0: 69 73 0a 2a 2a 20 61 20 74 65 72 6d 69 6e 61 6c is.** a terminal
14c0: 20 73 79 6d 62 6f 6c 2e 20 20 49 66 20 74 68 65 symbol. If the
14d0: 20 6c 6f 6f 6b 61 68 65 61 64 20 69 73 20 61 20 lookahead is a
14e0: 6e 6f 6e 2d 74 65 72 6d 69 6e 61 6c 20 28 61 73 non-terminal (as
14f0: 20 6f 63 63 75 72 73 20 61 66 74 65 72 0a 2a 2a occurs after.**
1500: 20 61 20 72 65 64 75 63 65 20 61 63 74 69 6f 6e a reduce action
1510: 29 20 74 68 65 6e 20 74 68 65 20 79 79 5f 72 65 ) then the yy_re
1520: 64 75 63 65 5f 6f 66 73 74 5b 5d 20 61 72 72 61 duce_ofst[] arra
1530: 79 20 69 73 20 75 73 65 64 20 69 6e 20 70 6c 61 y is used in pla
1540: 63 65 20 6f 66 0a 2a 2a 20 74 68 65 20 79 79 5f ce of.** the yy_
1550: 73 68 69 66 74 5f 6f 66 73 74 5b 5d 20 61 72 72 shift_ofst[] arr
1560: 61 79 20 61 6e 64 20 59 59 5f 52 45 44 55 43 45 ay and YY_REDUCE
1570: 5f 55 53 45 5f 44 46 4c 54 20 69 73 20 75 73 65 _USE_DFLT is use
1580: 64 20 69 6e 20 70 6c 61 63 65 20 6f 66 0a 2a 2a d in place of.**
1590: 20 59 59 5f 53 48 49 46 54 5f 55 53 45 5f 44 46 YY_SHIFT_USE_DF
15a0: 4c 54 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 66 6f LT..**.** The fo
15b0: 6c 6c 6f 77 69 6e 67 20 61 72 65 20 74 68 65 20 llowing are the
15c0: 74 61 62 6c 65 73 20 67 65 6e 65 72 61 74 65 64 tables generated
15d0: 20 69 6e 20 74 68 69 73 20 73 65 63 74 69 6f 6e in this section
15e0: 3a 0a 2a 2a 0a 2a 2a 20 20 79 79 5f 61 63 74 69 :.**.** yy_acti
15f0: 6f 6e 5b 5d 20 20 20 20 20 20 20 20 41 20 73 69 on[] A si
1600: 6e 67 6c 65 20 74 61 62 6c 65 20 63 6f 6e 74 61 ngle table conta
1610: 69 6e 69 6e 67 20 61 6c 6c 20 61 63 74 69 6f 6e ining all action
1620: 73 2e 0a 2a 2a 20 20 79 79 5f 6c 6f 6f 6b 61 68 s..** yy_lookah
1630: 65 61 64 5b 5d 20 20 20 20 20 41 20 74 61 62 6c ead[] A tabl
1640: 65 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 e containing the
1650: 20 6c 6f 6f 6b 61 68 65 61 64 20 66 6f 72 20 65 lookahead for e
1660: 61 63 68 20 65 6e 74 72 79 20 69 6e 0a 2a 2a 20 ach entry in.**
1670: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1680: 20 20 20 20 79 79 5f 61 63 74 69 6f 6e 2e 20 20 yy_action.
1690: 55 73 65 64 20 74 6f 20 64 65 74 65 63 74 20 68 Used to detect h
16a0: 61 73 68 20 63 6f 6c 6c 69 73 69 6f 6e 73 2e 0a ash collisions..
16b0: 2a 2a 20 20 79 79 5f 73 68 69 66 74 5f 6f 66 73 ** yy_shift_ofs
16c0: 74 5b 5d 20 20 20 20 46 6f 72 20 65 61 63 68 20 t[] For each
16d0: 73 74 61 74 65 2c 20 74 68 65 20 6f 66 66 73 65 state, the offse
16e0: 74 20 69 6e 74 6f 20 79 79 5f 61 63 74 69 6f 6e t into yy_action
16f0: 20 66 6f 72 0a 2a 2a 20 20 20 20 20 20 20 20 20 for.**
1700: 20 20 20 20 20 20 20 20 20 20 20 20 73 68 69 66 shif
1710: 74 69 6e 67 20 74 65 72 6d 69 6e 61 6c 73 2e 0a ting terminals..
1720: 2a 2a 20 20 79 79 5f 72 65 64 75 63 65 5f 6f 66 ** yy_reduce_of
1730: 73 74 5b 5d 20 20 20 46 6f 72 20 65 61 63 68 20 st[] For each
1740: 73 74 61 74 65 2c 20 74 68 65 20 6f 66 66 73 65 state, the offse
1750: 74 20 69 6e 74 6f 20 79 79 5f 61 63 74 69 6f 6e t into yy_action
1760: 20 66 6f 72 0a 2a 2a 20 20 20 20 20 20 20 20 20 for.**
1770: 20 20 20 20 20 20 20 20 20 20 20 20 73 68 69 66 shif
1780: 74 69 6e 67 20 6e 6f 6e 2d 74 65 72 6d 69 6e 61 ting non-termina
1790: 6c 73 20 61 66 74 65 72 20 61 20 72 65 64 75 63 ls after a reduc
17a0: 65 2e 0a 2a 2a 20 20 79 79 5f 64 65 66 61 75 6c e..** yy_defaul
17b0: 74 5b 5d 20 20 20 20 20 20 20 44 65 66 61 75 6c t[] Defaul
17c0: 74 20 61 63 74 69 6f 6e 20 66 6f 72 20 65 61 63 t action for eac
17d0: 68 20 73 74 61 74 65 2e 0a 2a 2f 0a 25 25 0a 0a h state..*/.%%..
17e0: 2f 2a 20 54 68 65 20 6e 65 78 74 20 74 61 62 6c /* The next tabl
17f0: 65 20 6d 61 70 73 20 74 6f 6b 65 6e 73 20 69 6e e maps tokens in
1800: 74 6f 20 66 61 6c 6c 62 61 63 6b 20 74 6f 6b 65 to fallback toke
1810: 6e 73 2e 20 20 49 66 20 61 20 63 6f 6e 73 74 72 ns. If a constr
1820: 75 63 74 0a 2a 2a 20 6c 69 6b 65 20 74 68 65 20 uct.** like the
1830: 66 6f 6c 6c 6f 77 69 6e 67 3a 0a 2a 2a 20 0a 2a following:.** .*
1840: 2a 20 20 20 20 20 20 25 66 61 6c 6c 62 61 63 6b * %fallback
1850: 20 49 44 20 58 20 59 20 5a 2e 0a 2a 2a 0a 2a 2a ID X Y Z..**.**
1860: 20 61 70 70 65 61 72 73 20 69 6e 20 74 68 65 20 appears in the
1870: 67 72 61 6d 6d 61 72 2c 20 74 68 65 6e 20 49 44 grammar, then ID
1880: 20 62 65 63 6f 6d 65 73 20 61 20 66 61 6c 6c 62 becomes a fallb
1890: 61 63 6b 20 74 6f 6b 65 6e 20 66 6f 72 20 58 2c ack token for X,
18a0: 20 59 2c 0a 2a 2a 20 61 6e 64 20 5a 2e 20 20 57 Y,.** and Z. W
18b0: 68 65 6e 65 76 65 72 20 6f 6e 65 20 6f 66 20 74 henever one of t
18c0: 68 65 20 74 6f 6b 65 6e 73 20 58 2c 20 59 2c 20 he tokens X, Y,
18d0: 6f 72 20 5a 20 69 73 20 69 6e 70 75 74 20 74 6f or Z is input to
18e0: 20 74 68 65 20 70 61 72 73 65 72 0a 2a 2a 20 62 the parser.** b
18f0: 75 74 20 69 74 20 64 6f 65 73 20 6e 6f 74 20 70 ut it does not p
1900: 61 72 73 65 2c 20 74 68 65 20 74 79 70 65 20 6f arse, the type o
1910: 66 20 74 68 65 20 74 6f 6b 65 6e 20 69 73 20 63 f the token is c
1920: 68 61 6e 67 65 64 20 74 6f 20 49 44 20 61 6e 64 hanged to ID and
1930: 0a 2a 2a 20 74 68 65 20 70 61 72 73 65 20 69 73 .** the parse is
1940: 20 72 65 74 72 69 65 64 20 62 65 66 6f 72 65 20 retried before
1950: 61 6e 20 65 72 72 6f 72 20 69 73 20 74 68 72 6f an error is thro
1960: 77 6e 2e 0a 2a 2f 0a 23 69 66 64 65 66 20 59 59 wn..*/.#ifdef YY
1970: 46 41 4c 4c 42 41 43 4b 0a 73 74 61 74 69 63 20 FALLBACK.static
1980: 63 6f 6e 73 74 20 59 59 43 4f 44 45 54 59 50 45 const YYCODETYPE
1990: 20 79 79 46 61 6c 6c 62 61 63 6b 5b 5d 20 3d 20 yyFallback[] =
19a0: 7b 0a 25 25 0a 7d 3b 0a 23 65 6e 64 69 66 20 2f {.%%.};.#endif /
19b0: 2a 20 59 59 46 41 4c 4c 42 41 43 4b 20 2a 2f 0a * YYFALLBACK */.
19c0: 0a 2f 2a 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e ./* The followin
19d0: 67 20 73 74 72 75 63 74 75 72 65 20 72 65 70 72 g structure repr
19e0: 65 73 65 6e 74 73 20 61 20 73 69 6e 67 6c 65 20 esents a single
19f0: 65 6c 65 6d 65 6e 74 20 6f 66 20 74 68 65 0a 2a element of the.*
1a00: 2a 20 70 61 72 73 65 72 27 73 20 73 74 61 63 6b * parser's stack
1a10: 2e 20 20 49 6e 66 6f 72 6d 61 74 69 6f 6e 20 73 . Information s
1a20: 74 6f 72 65 64 20 69 6e 63 6c 75 64 65 73 3a 0a tored includes:.
1a30: 2a 2a 0a 2a 2a 20 20 20 2b 20 20 54 68 65 20 73 **.** + The s
1a40: 74 61 74 65 20 6e 75 6d 62 65 72 20 66 6f 72 20 tate number for
1a50: 74 68 65 20 70 61 72 73 65 72 20 61 74 20 74 68 the parser at th
1a60: 69 73 20 6c 65 76 65 6c 20 6f 66 20 74 68 65 20 is level of the
1a70: 73 74 61 63 6b 2e 0a 2a 2a 0a 2a 2a 20 20 20 2b stack..**.** +
1a80: 20 20 54 68 65 20 76 61 6c 75 65 20 6f 66 20 74 The value of t
1a90: 68 65 20 74 6f 6b 65 6e 20 73 74 6f 72 65 64 20 he token stored
1aa0: 61 74 20 74 68 69 73 20 6c 65 76 65 6c 20 6f 66 at this level of
1ab0: 20 74 68 65 20 73 74 61 63 6b 2e 0a 2a 2a 20 20 the stack..**
1ac0: 20 20 20 20 28 49 6e 20 6f 74 68 65 72 20 77 6f (In other wo
1ad0: 72 64 73 2c 20 74 68 65 20 22 6d 61 6a 6f 72 22 rds, the "major"
1ae0: 20 74 6f 6b 65 6e 2e 29 0a 2a 2a 0a 2a 2a 20 20 token.).**.**
1af0: 20 2b 20 20 54 68 65 20 73 65 6d 61 6e 74 69 63 + The semantic
1b00: 20 76 61 6c 75 65 20 73 74 6f 72 65 64 20 61 74 value stored at
1b10: 20 74 68 69 73 20 6c 65 76 65 6c 20 6f 66 20 74 this level of t
1b20: 68 65 20 73 74 61 63 6b 2e 20 20 54 68 69 73 20 he stack. This
1b30: 69 73 0a 2a 2a 20 20 20 20 20 20 74 68 65 20 69 is.** the i
1b40: 6e 66 6f 72 6d 61 74 69 6f 6e 20 75 73 65 64 20 nformation used
1b50: 62 79 20 74 68 65 20 61 63 74 69 6f 6e 20 72 6f by the action ro
1b60: 75 74 69 6e 65 73 20 69 6e 20 74 68 65 20 67 72 utines in the gr
1b70: 61 6d 6d 61 72 2e 0a 2a 2a 20 20 20 20 20 20 49 ammar..** I
1b80: 74 20 69 73 20 73 6f 6d 65 74 69 6d 65 73 20 63 t is sometimes c
1b90: 61 6c 6c 65 64 20 74 68 65 20 22 6d 69 6e 6f 72 alled the "minor
1ba0: 22 20 74 6f 6b 65 6e 2e 0a 2a 2f 0a 73 74 72 75 " token..*/.stru
1bb0: 63 74 20 79 79 53 74 61 63 6b 45 6e 74 72 79 20 ct yyStackEntry
1bc0: 7b 0a 20 20 59 59 41 43 54 49 4f 4e 54 59 50 45 {. YYACTIONTYPE
1bd0: 20 73 74 61 74 65 6e 6f 3b 20 20 2f 2a 20 54 68 stateno; /* Th
1be0: 65 20 73 74 61 74 65 2d 6e 75 6d 62 65 72 20 2a e state-number *
1bf0: 2f 0a 20 20 59 59 43 4f 44 45 54 59 50 45 20 6d /. YYCODETYPE m
1c00: 61 6a 6f 72 3b 20 20 20 20 20 20 2f 2a 20 54 68 ajor; /* Th
1c10: 65 20 6d 61 6a 6f 72 20 74 6f 6b 65 6e 20 76 61 e major token va
1c20: 6c 75 65 2e 20 20 54 68 69 73 20 69 73 20 74 68 lue. This is th
1c30: 65 20 63 6f 64 65 0a 20 20 20 20 20 20 20 20 20 e code.
1c40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1c50: 2a 2a 20 6e 75 6d 62 65 72 20 66 6f 72 20 74 68 ** number for th
1c60: 65 20 74 6f 6b 65 6e 20 61 74 20 74 68 69 73 20 e token at this
1c70: 73 74 61 63 6b 20 6c 65 76 65 6c 20 2a 2f 0a 20 stack level */.
1c80: 20 59 59 4d 49 4e 4f 52 54 59 50 45 20 6d 69 6e YYMINORTYPE min
1c90: 6f 72 3b 20 20 20 20 20 2f 2a 20 54 68 65 20 75 or; /* The u
1ca0: 73 65 72 2d 73 75 70 70 6c 69 65 64 20 6d 69 6e ser-supplied min
1cb0: 6f 72 20 74 6f 6b 65 6e 20 76 61 6c 75 65 2e 20 or token value.
1cc0: 20 54 68 69 73 0a 20 20 20 20 20 20 20 20 20 20 This.
1cd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a *
1ce0: 2a 20 69 73 20 74 68 65 20 76 61 6c 75 65 20 6f * is the value o
1cf0: 66 20 74 68 65 20 74 6f 6b 65 6e 20 20 2a 2f 0a f the token */.
1d00: 7d 3b 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 };.typedef struc
1d10: 74 20 79 79 53 74 61 63 6b 45 6e 74 72 79 20 79 t yyStackEntry y
1d20: 79 53 74 61 63 6b 45 6e 74 72 79 3b 0a 0a 2f 2a yStackEntry;../*
1d30: 20 54 68 65 20 73 74 61 74 65 20 6f 66 20 74 68 The state of th
1d40: 65 20 70 61 72 73 65 72 20 69 73 20 63 6f 6d 70 e parser is comp
1d50: 6c 65 74 65 6c 79 20 63 6f 6e 74 61 69 6e 65 64 letely contained
1d60: 20 69 6e 20 61 6e 20 69 6e 73 74 61 6e 63 65 20 in an instance
1d70: 6f 66 0a 2a 2a 20 74 68 65 20 66 6f 6c 6c 6f 77 of.** the follow
1d80: 69 6e 67 20 73 74 72 75 63 74 75 72 65 20 2a 2f ing structure */
1d90: 0a 73 74 72 75 63 74 20 79 79 50 61 72 73 65 72 .struct yyParser
1da0: 20 7b 0a 20 20 69 6e 74 20 79 79 69 64 78 3b 20 {. int yyidx;
1db0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1dc0: 20 20 20 2f 2a 20 49 6e 64 65 78 20 6f 66 20 74 /* Index of t
1dd0: 6f 70 20 65 6c 65 6d 65 6e 74 20 69 6e 20 73 74 op element in st
1de0: 61 63 6b 20 2a 2f 0a 23 69 66 64 65 66 20 59 59 ack */.#ifdef YY
1df0: 54 52 41 43 4b 4d 41 58 53 54 41 43 4b 44 45 50 TRACKMAXSTACKDEP
1e00: 54 48 0a 20 20 69 6e 74 20 79 79 69 64 78 4d 61 TH. int yyidxMa
1e10: 78 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 x;
1e20: 20 20 20 2f 2a 20 4d 61 78 69 6d 75 6d 20 76 61 /* Maximum va
1e30: 6c 75 65 20 6f 66 20 79 79 69 64 78 20 2a 2f 0a lue of yyidx */.
1e40: 23 65 6e 64 69 66 0a 20 20 69 6e 74 20 79 79 65 #endif. int yye
1e50: 72 72 63 6e 74 3b 20 20 20 20 20 20 20 20 20 20 rrcnt;
1e60: 20 20 20 20 20 20 20 2f 2a 20 53 68 69 66 74 73 /* Shifts
1e70: 20 6c 65 66 74 20 62 65 66 6f 72 65 20 6f 75 74 left before out
1e80: 20 6f 66 20 74 68 65 20 65 72 72 6f 72 20 2a 2f of the error */
1e90: 0a 20 20 50 61 72 73 65 41 52 47 5f 53 44 45 43 . ParseARG_SDEC
1ea0: 4c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 L
1eb0: 20 2f 2a 20 41 20 70 6c 61 63 65 20 74 6f 20 68 /* A place to h
1ec0: 6f 6c 64 20 25 65 78 74 72 61 5f 61 72 67 75 6d old %extra_argum
1ed0: 65 6e 74 20 2a 2f 0a 23 69 66 20 59 59 53 54 41 ent */.#if YYSTA
1ee0: 43 4b 44 45 50 54 48 3c 3d 30 0a 20 20 69 6e 74 CKDEPTH<=0. int
1ef0: 20 79 79 73 74 6b 73 7a 3b 20 20 20 20 20 20 20 yystksz;
1f00: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 43 75 /* Cu
1f10: 72 72 65 6e 74 20 73 69 64 65 20 6f 66 20 74 68 rrent side of th
1f20: 65 20 73 74 61 63 6b 20 2a 2f 0a 20 20 79 79 53 e stack */. yyS
1f30: 74 61 63 6b 45 6e 74 72 79 20 2a 79 79 73 74 61 tackEntry *yysta
1f40: 63 6b 3b 20 20 20 20 20 20 20 20 2f 2a 20 54 68 ck; /* Th
1f50: 65 20 70 61 72 73 65 72 27 73 20 73 74 61 63 6b e parser's stack
1f60: 20 2a 2f 0a 23 65 6c 73 65 0a 20 20 79 79 53 74 */.#else. yySt
1f70: 61 63 6b 45 6e 74 72 79 20 79 79 73 74 61 63 6b ackEntry yystack
1f80: 5b 59 59 53 54 41 43 4b 44 45 50 54 48 5d 3b 20 [YYSTACKDEPTH];
1f90: 20 2f 2a 20 54 68 65 20 70 61 72 73 65 72 27 73 /* The parser's
1fa0: 20 73 74 61 63 6b 20 2a 2f 0a 23 65 6e 64 69 66 stack */.#endif
1fb0: 0a 7d 3b 0a 74 79 70 65 64 65 66 20 73 74 72 75 .};.typedef stru
1fc0: 63 74 20 79 79 50 61 72 73 65 72 20 79 79 50 61 ct yyParser yyPa
1fd0: 72 73 65 72 3b 0a 0a 23 69 66 6e 64 65 66 20 4e rser;..#ifndef N
1fe0: 44 45 42 55 47 0a 23 69 6e 63 6c 75 64 65 20 3c DEBUG.#include <
1ff0: 73 74 64 69 6f 2e 68 3e 0a 73 74 61 74 69 63 20 stdio.h>.static
2000: 46 49 4c 45 20 2a 79 79 54 72 61 63 65 46 49 4c FILE *yyTraceFIL
2010: 45 20 3d 20 30 3b 0a 73 74 61 74 69 63 20 63 68 E = 0;.static ch
2020: 61 72 20 2a 79 79 54 72 61 63 65 50 72 6f 6d 70 ar *yyTracePromp
2030: 74 20 3d 20 30 3b 0a 23 65 6e 64 69 66 20 2f 2a t = 0;.#endif /*
2040: 20 4e 44 45 42 55 47 20 2a 2f 0a 0a 23 69 66 6e NDEBUG */..#ifn
2050: 64 65 66 20 4e 44 45 42 55 47 0a 2f 2a 20 0a 2a def NDEBUG./* .*
2060: 2a 20 54 75 72 6e 20 70 61 72 73 65 72 20 74 72 * Turn parser tr
2070: 61 63 69 6e 67 20 6f 6e 20 62 79 20 67 69 76 69 acing on by givi
2080: 6e 67 20 61 20 73 74 72 65 61 6d 20 74 6f 20 77 ng a stream to w
2090: 68 69 63 68 20 74 6f 20 77 72 69 74 65 20 74 68 hich to write th
20a0: 65 20 74 72 61 63 65 0a 2a 2a 20 61 6e 64 20 61 e trace.** and a
20b0: 20 70 72 6f 6d 70 74 20 74 6f 20 70 72 65 66 61 prompt to prefa
20c0: 63 65 20 65 61 63 68 20 74 72 61 63 65 20 6d 65 ce each trace me
20d0: 73 73 61 67 65 2e 20 20 54 72 61 63 69 6e 67 20 ssage. Tracing
20e0: 69 73 20 74 75 72 6e 65 64 20 6f 66 66 0a 2a 2a is turned off.**
20f0: 20 62 79 20 6d 61 6b 69 6e 67 20 65 69 74 68 65 by making eithe
2100: 72 20 61 72 67 75 6d 65 6e 74 20 4e 55 4c 4c 20 r argument NULL
2110: 0a 2a 2a 0a 2a 2a 20 49 6e 70 75 74 73 3a 0a 2a .**.** Inputs:.*
2120: 2a 20 3c 75 6c 3e 0a 2a 2a 20 3c 6c 69 3e 20 41 * <ul>.** <li> A
2130: 20 46 49 4c 45 2a 20 74 6f 20 77 68 69 63 68 20 FILE* to which
2140: 74 72 61 63 65 20 6f 75 74 70 75 74 20 73 68 6f trace output sho
2150: 75 6c 64 20 62 65 20 77 72 69 74 74 65 6e 2e 0a uld be written..
2160: 2a 2a 20 20 20 20 20 20 49 66 20 4e 55 4c 4c 2c ** If NULL,
2170: 20 74 68 65 6e 20 74 72 61 63 69 6e 67 20 69 73 then tracing is
2180: 20 74 75 72 6e 65 64 20 6f 66 66 2e 0a 2a 2a 20 turned off..**
2190: 3c 6c 69 3e 20 41 20 70 72 65 66 69 78 20 73 74 <li> A prefix st
21a0: 72 69 6e 67 20 77 72 69 74 74 65 6e 20 61 74 20 ring written at
21b0: 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 the beginning of
21c0: 20 65 76 65 72 79 0a 2a 2a 20 20 20 20 20 20 6c every.** l
21d0: 69 6e 65 20 6f 66 20 74 72 61 63 65 20 6f 75 74 ine of trace out
21e0: 70 75 74 2e 20 20 49 66 20 4e 55 4c 4c 2c 20 74 put. If NULL, t
21f0: 68 65 6e 20 74 72 61 63 69 6e 67 20 69 73 0a 2a hen tracing is.*
2200: 2a 20 20 20 20 20 20 74 75 72 6e 65 64 20 6f 66 * turned of
2210: 66 2e 0a 2a 2a 20 3c 2f 75 6c 3e 0a 2a 2a 0a 2a f..** </ul>.**.*
2220: 2a 20 4f 75 74 70 75 74 73 3a 0a 2a 2a 20 4e 6f * Outputs:.** No
2230: 6e 65 2e 0a 2a 2f 0a 76 6f 69 64 20 50 61 72 73 ne..*/.void Pars
2240: 65 54 72 61 63 65 28 46 49 4c 45 20 2a 54 72 61 eTrace(FILE *Tra
2250: 63 65 46 49 4c 45 2c 20 63 68 61 72 20 2a 7a 54 ceFILE, char *zT
2260: 72 61 63 65 50 72 6f 6d 70 74 29 7b 0a 20 20 79 racePrompt){. y
2270: 79 54 72 61 63 65 46 49 4c 45 20 3d 20 54 72 61 yTraceFILE = Tra
2280: 63 65 46 49 4c 45 3b 0a 20 20 79 79 54 72 61 63 ceFILE;. yyTrac
2290: 65 50 72 6f 6d 70 74 20 3d 20 7a 54 72 61 63 65 ePrompt = zTrace
22a0: 50 72 6f 6d 70 74 3b 0a 20 20 69 66 28 20 79 79 Prompt;. if( yy
22b0: 54 72 61 63 65 46 49 4c 45 3d 3d 30 20 29 20 79 TraceFILE==0 ) y
22c0: 79 54 72 61 63 65 50 72 6f 6d 70 74 20 3d 20 30 yTracePrompt = 0
22d0: 3b 0a 20 20 65 6c 73 65 20 69 66 28 20 79 79 54 ;. else if( yyT
22e0: 72 61 63 65 50 72 6f 6d 70 74 3d 3d 30 20 29 20 racePrompt==0 )
22f0: 79 79 54 72 61 63 65 46 49 4c 45 20 3d 20 30 3b yyTraceFILE = 0;
2300: 0a 7d 0a 23 65 6e 64 69 66 20 2f 2a 20 4e 44 45 .}.#endif /* NDE
2310: 42 55 47 20 2a 2f 0a 0a 23 69 66 6e 64 65 66 20 BUG */..#ifndef
2320: 4e 44 45 42 55 47 0a 2f 2a 20 46 6f 72 20 74 72 NDEBUG./* For tr
2330: 61 63 69 6e 67 20 73 68 69 66 74 73 2c 20 74 68 acing shifts, th
2340: 65 20 6e 61 6d 65 73 20 6f 66 20 61 6c 6c 20 74 e names of all t
2350: 65 72 6d 69 6e 61 6c 73 20 61 6e 64 20 6e 6f 6e erminals and non
2360: 74 65 72 6d 69 6e 61 6c 73 0a 2a 2a 20 61 72 65 terminals.** are
2370: 20 72 65 71 75 69 72 65 64 2e 20 20 54 68 65 20 required. The
2380: 66 6f 6c 6c 6f 77 69 6e 67 20 74 61 62 6c 65 20 following table
2390: 73 75 70 70 6c 69 65 73 20 74 68 65 73 65 20 6e supplies these n
23a0: 61 6d 65 73 20 2a 2f 0a 73 74 61 74 69 63 20 63 ames */.static c
23b0: 6f 6e 73 74 20 63 68 61 72 20 2a 63 6f 6e 73 74 onst char *const
23c0: 20 79 79 54 6f 6b 65 6e 4e 61 6d 65 5b 5d 20 3d yyTokenName[] =
23d0: 20 7b 20 0a 25 25 0a 7d 3b 0a 23 65 6e 64 69 66 { .%%.};.#endif
23e0: 20 2f 2a 20 4e 44 45 42 55 47 20 2a 2f 0a 0a 23 /* NDEBUG */..#
23f0: 69 66 6e 64 65 66 20 4e 44 45 42 55 47 0a 2f 2a ifndef NDEBUG./*
2400: 20 46 6f 72 20 74 72 61 63 69 6e 67 20 72 65 64 For tracing red
2410: 75 63 65 20 61 63 74 69 6f 6e 73 2c 20 74 68 65 uce actions, the
2420: 20 6e 61 6d 65 73 20 6f 66 20 61 6c 6c 20 72 75 names of all ru
2430: 6c 65 73 20 61 72 65 20 72 65 71 75 69 72 65 64 les are required
2440: 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 63 6f 6e 73 ..*/.static cons
2450: 74 20 63 68 61 72 20 2a 63 6f 6e 73 74 20 79 79 t char *const yy
2460: 52 75 6c 65 4e 61 6d 65 5b 5d 20 3d 20 7b 0a 25 RuleName[] = {.%
2470: 25 0a 7d 3b 0a 23 65 6e 64 69 66 20 2f 2a 20 4e %.};.#endif /* N
2480: 44 45 42 55 47 20 2a 2f 0a 0a 0a 23 69 66 20 59 DEBUG */...#if Y
2490: 59 53 54 41 43 4b 44 45 50 54 48 3c 3d 30 0a 2f YSTACKDEPTH<=0./
24a0: 2a 0a 2a 2a 20 54 72 79 20 74 6f 20 69 6e 63 72 *.** Try to incr
24b0: 65 61 73 65 20 74 68 65 20 73 69 7a 65 20 6f 66 ease the size of
24c0: 20 74 68 65 20 70 61 72 73 65 72 20 73 74 61 63 the parser stac
24d0: 6b 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 k..*/.static voi
24e0: 64 20 79 79 47 72 6f 77 53 74 61 63 6b 28 79 79 d yyGrowStack(yy
24f0: 50 61 72 73 65 72 20 2a 70 29 7b 0a 20 20 69 6e Parser *p){. in
2500: 74 20 6e 65 77 53 69 7a 65 3b 0a 20 20 79 79 53 t newSize;. yyS
2510: 74 61 63 6b 45 6e 74 72 79 20 2a 70 4e 65 77 3b tackEntry *pNew;
2520: 0a 0a 20 20 6e 65 77 53 69 7a 65 20 3d 20 70 2d .. newSize = p-
2530: 3e 79 79 73 74 6b 73 7a 2a 32 20 2b 20 31 30 30 >yystksz*2 + 100
2540: 3b 0a 20 20 70 4e 65 77 20 3d 20 72 65 61 6c 6c ;. pNew = reall
2550: 6f 63 28 70 2d 3e 79 79 73 74 61 63 6b 2c 20 6e oc(p->yystack, n
2560: 65 77 53 69 7a 65 2a 73 69 7a 65 6f 66 28 70 4e ewSize*sizeof(pN
2570: 65 77 5b 30 5d 29 29 3b 0a 20 20 69 66 28 20 70 ew[0]));. if( p
2580: 4e 65 77 20 29 7b 0a 20 20 20 20 70 2d 3e 79 79 New ){. p->yy
2590: 73 74 61 63 6b 20 3d 20 70 4e 65 77 3b 0a 20 20 stack = pNew;.
25a0: 20 20 70 2d 3e 79 79 73 74 6b 73 7a 20 3d 20 6e p->yystksz = n
25b0: 65 77 53 69 7a 65 3b 0a 23 69 66 6e 64 65 66 20 ewSize;.#ifndef
25c0: 4e 44 45 42 55 47 0a 20 20 20 20 69 66 28 20 79 NDEBUG. if( y
25d0: 79 54 72 61 63 65 46 49 4c 45 20 29 7b 0a 20 20 yTraceFILE ){.
25e0: 20 20 20 20 66 70 72 69 6e 74 66 28 79 79 54 72 fprintf(yyTr
25f0: 61 63 65 46 49 4c 45 2c 22 25 73 53 74 61 63 6b aceFILE,"%sStack
2600: 20 67 72 6f 77 73 20 74 6f 20 25 64 20 65 6e 74 grows to %d ent
2610: 72 69 65 73 21 5c 6e 22 2c 0a 20 20 20 20 20 20 ries!\n",.
2620: 20 20 20 20 20 20 20 20 79 79 54 72 61 63 65 50 yyTraceP
2630: 72 6f 6d 70 74 2c 20 70 2d 3e 79 79 73 74 6b 73 rompt, p->yystks
2640: 7a 29 3b 0a 20 20 20 20 7d 0a 23 65 6e 64 69 66 z);. }.#endif
2650: 0a 20 20 7d 0a 7d 0a 23 65 6e 64 69 66 0a 0a 2f . }.}.#endif../
2660: 2a 20 0a 2a 2a 20 54 68 69 73 20 66 75 6e 63 74 * .** This funct
2670: 69 6f 6e 20 61 6c 6c 6f 63 61 74 65 73 20 61 20 ion allocates a
2680: 6e 65 77 20 70 61 72 73 65 72 2e 0a 2a 2a 20 54 new parser..** T
2690: 68 65 20 6f 6e 6c 79 20 61 72 67 75 6d 65 6e 74 he only argument
26a0: 20 69 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f is a pointer to
26b0: 20 61 20 66 75 6e 63 74 69 6f 6e 20 77 68 69 63 a function whic
26c0: 68 20 77 6f 72 6b 73 20 6c 69 6b 65 0a 2a 2a 20 h works like.**
26d0: 6d 61 6c 6c 6f 63 2e 0a 2a 2a 0a 2a 2a 20 49 6e malloc..**.** In
26e0: 70 75 74 73 3a 0a 2a 2a 20 41 20 70 6f 69 6e 74 puts:.** A point
26f0: 65 72 20 74 6f 20 74 68 65 20 66 75 6e 63 74 69 er to the functi
2700: 6f 6e 20 75 73 65 64 20 74 6f 20 61 6c 6c 6f 63 on used to alloc
2710: 61 74 65 20 6d 65 6d 6f 72 79 2e 0a 2a 2a 0a 2a ate memory..**.*
2720: 2a 20 4f 75 74 70 75 74 73 3a 0a 2a 2a 20 41 20 * Outputs:.** A
2730: 70 6f 69 6e 74 65 72 20 74 6f 20 61 20 70 61 72 pointer to a par
2740: 73 65 72 2e 20 20 54 68 69 73 20 70 6f 69 6e 74 ser. This point
2750: 65 72 20 69 73 20 75 73 65 64 20 69 6e 20 73 75 er is used in su
2760: 62 73 65 71 75 65 6e 74 20 63 61 6c 6c 73 0a 2a bsequent calls.*
2770: 2a 20 74 6f 20 50 61 72 73 65 20 61 6e 64 20 50 * to Parse and P
2780: 61 72 73 65 46 72 65 65 2e 0a 2a 2f 0a 76 6f 69 arseFree..*/.voi
2790: 64 20 2a 50 61 72 73 65 41 6c 6c 6f 63 28 76 6f d *ParseAlloc(vo
27a0: 69 64 20 2a 28 2a 6d 61 6c 6c 6f 63 50 72 6f 63 id *(*mallocProc
27b0: 29 28 75 36 34 29 29 7b 0a 20 20 79 79 50 61 72 )(u64)){. yyPar
27c0: 73 65 72 20 2a 70 50 61 72 73 65 72 3b 0a 20 20 ser *pParser;.
27d0: 70 50 61 72 73 65 72 20 3d 20 28 79 79 50 61 72 pParser = (yyPar
27e0: 73 65 72 2a 29 28 2a 6d 61 6c 6c 6f 63 50 72 6f ser*)(*mallocPro
27f0: 63 29 28 20 28 75 36 34 29 73 69 7a 65 6f 66 28 c)( (u64)sizeof(
2800: 79 79 50 61 72 73 65 72 29 20 29 3b 0a 20 20 69 yyParser) );. i
2810: 66 28 20 70 50 61 72 73 65 72 20 29 7b 0a 20 20 f( pParser ){.
2820: 20 20 70 50 61 72 73 65 72 2d 3e 79 79 69 64 78 pParser->yyidx
2830: 20 3d 20 2d 31 3b 0a 23 69 66 64 65 66 20 59 59 = -1;.#ifdef YY
2840: 54 52 41 43 4b 4d 41 58 53 54 41 43 4b 44 45 50 TRACKMAXSTACKDEP
2850: 54 48 0a 20 20 20 20 70 50 61 72 73 65 72 2d 3e TH. pParser->
2860: 79 79 69 64 78 4d 61 78 20 3d 20 30 3b 0a 23 65 yyidxMax = 0;.#e
2870: 6e 64 69 66 0a 23 69 66 20 59 59 53 54 41 43 4b ndif.#if YYSTACK
2880: 44 45 50 54 48 3c 3d 30 0a 20 20 20 20 70 50 61 DEPTH<=0. pPa
2890: 72 73 65 72 2d 3e 79 79 73 74 61 63 6b 20 3d 20 rser->yystack =
28a0: 4e 55 4c 4c 3b 0a 20 20 20 20 70 50 61 72 73 65 NULL;. pParse
28b0: 72 2d 3e 79 79 73 74 6b 73 7a 20 3d 20 30 3b 0a r->yystksz = 0;.
28c0: 20 20 20 20 79 79 47 72 6f 77 53 74 61 63 6b 28 yyGrowStack(
28d0: 70 50 61 72 73 65 72 29 3b 0a 23 65 6e 64 69 66 pParser);.#endif
28e0: 0a 20 20 7d 0a 20 20 72 65 74 75 72 6e 20 70 50 . }. return pP
28f0: 61 72 73 65 72 3b 0a 7d 0a 0a 2f 2a 20 54 68 65 arser;.}../* The
2900: 20 66 6f 6c 6c 6f 77 69 6e 67 20 66 75 6e 63 74 following funct
2910: 69 6f 6e 20 64 65 6c 65 74 65 73 20 74 68 65 20 ion deletes the
2920: 76 61 6c 75 65 20 61 73 73 6f 63 69 61 74 65 64 value associated
2930: 20 77 69 74 68 20 61 0a 2a 2a 20 73 79 6d 62 6f with a.** symbo
2940: 6c 2e 20 20 54 68 65 20 73 79 6d 62 6f 6c 20 63 l. The symbol c
2950: 61 6e 20 62 65 20 65 69 74 68 65 72 20 61 20 74 an be either a t
2960: 65 72 6d 69 6e 61 6c 20 6f 72 20 6e 6f 6e 74 65 erminal or nonte
2970: 72 6d 69 6e 61 6c 2e 0a 2a 2a 20 22 79 79 6d 61 rminal..** "yyma
2980: 6a 6f 72 22 20 69 73 20 74 68 65 20 73 79 6d 62 jor" is the symb
2990: 6f 6c 20 63 6f 64 65 2c 20 61 6e 64 20 22 79 79 ol code, and "yy
29a0: 70 6d 69 6e 6f 72 22 20 69 73 20 61 20 70 6f 69 pminor" is a poi
29b0: 6e 74 65 72 20 74 6f 0a 2a 2a 20 74 68 65 20 76 nter to.** the v
29c0: 61 6c 75 65 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 alue..*/.static
29d0: 76 6f 69 64 20 79 79 5f 64 65 73 74 72 75 63 74 void yy_destruct
29e0: 6f 72 28 0a 20 20 79 79 50 61 72 73 65 72 20 2a or(. yyParser *
29f0: 79 79 70 50 61 72 73 65 72 2c 20 20 20 20 2f 2a yypParser, /*
2a00: 20 54 68 65 20 70 61 72 73 65 72 20 2a 2f 0a 20 The parser */.
2a10: 20 59 59 43 4f 44 45 54 59 50 45 20 79 79 6d 61 YYCODETYPE yyma
2a20: 6a 6f 72 2c 20 20 20 20 20 2f 2a 20 54 79 70 65 jor, /* Type
2a30: 20 63 6f 64 65 20 66 6f 72 20 6f 62 6a 65 63 74 code for object
2a40: 20 74 6f 20 64 65 73 74 72 6f 79 20 2a 2f 0a 20 to destroy */.
2a50: 20 59 59 4d 49 4e 4f 52 54 59 50 45 20 2a 79 79 YYMINORTYPE *yy
2a60: 70 6d 69 6e 6f 72 20 20 20 2f 2a 20 54 68 65 20 pminor /* The
2a70: 6f 62 6a 65 63 74 20 74 6f 20 62 65 20 64 65 73 object to be des
2a80: 74 72 6f 79 65 64 20 2a 2f 0a 29 7b 0a 20 20 50 troyed */.){. P
2a90: 61 72 73 65 41 52 47 5f 46 45 54 43 48 3b 0a 20 arseARG_FETCH;.
2aa0: 20 73 77 69 74 63 68 28 20 79 79 6d 61 6a 6f 72 switch( yymajor
2ab0: 20 29 7b 0a 20 20 20 20 2f 2a 20 48 65 72 65 20 ){. /* Here
2ac0: 69 73 20 69 6e 73 65 72 74 65 64 20 74 68 65 20 is inserted the
2ad0: 61 63 74 69 6f 6e 73 20 77 68 69 63 68 20 74 61 actions which ta
2ae0: 6b 65 20 70 6c 61 63 65 20 77 68 65 6e 20 61 0a ke place when a.
2af0: 20 20 20 20 2a 2a 20 74 65 72 6d 69 6e 61 6c 20 ** terminal
2b00: 6f 72 20 6e 6f 6e 2d 74 65 72 6d 69 6e 61 6c 20 or non-terminal
2b10: 69 73 20 64 65 73 74 72 6f 79 65 64 2e 20 20 54 is destroyed. T
2b20: 68 69 73 20 63 61 6e 20 68 61 70 70 65 6e 0a 20 his can happen.
2b30: 20 20 20 2a 2a 20 77 68 65 6e 20 74 68 65 20 73 ** when the s
2b40: 79 6d 62 6f 6c 20 69 73 20 70 6f 70 70 65 64 20 ymbol is popped
2b50: 66 72 6f 6d 20 74 68 65 20 73 74 61 63 6b 20 64 from the stack d
2b60: 75 72 69 6e 67 20 61 0a 20 20 20 20 2a 2a 20 72 uring a. ** r
2b70: 65 64 75 63 65 20 6f 72 20 64 75 72 69 6e 67 20 educe or during
2b80: 65 72 72 6f 72 20 70 72 6f 63 65 73 73 69 6e 67 error processing
2b90: 20 6f 72 20 77 68 65 6e 20 61 20 70 61 72 73 65 or when a parse
2ba0: 72 20 69 73 20 0a 20 20 20 20 2a 2a 20 62 65 69 r is . ** bei
2bb0: 6e 67 20 64 65 73 74 72 6f 79 65 64 20 62 65 66 ng destroyed bef
2bc0: 6f 72 65 20 69 74 20 69 73 20 66 69 6e 69 73 68 ore it is finish
2bd0: 65 64 20 70 61 72 73 69 6e 67 2e 0a 20 20 20 20 ed parsing..
2be0: 2a 2a 0a 20 20 20 20 2a 2a 20 4e 6f 74 65 3a 20 **. ** Note:
2bf0: 64 75 72 69 6e 67 20 61 20 72 65 64 75 63 65 2c during a reduce,
2c00: 20 74 68 65 20 6f 6e 6c 79 20 73 79 6d 62 6f 6c the only symbol
2c10: 73 20 64 65 73 74 72 6f 79 65 64 20 61 72 65 20 s destroyed are
2c20: 74 68 6f 73 65 0a 20 20 20 20 2a 2a 20 77 68 69 those. ** whi
2c30: 63 68 20 61 70 70 65 61 72 20 6f 6e 20 74 68 65 ch appear on the
2c40: 20 52 48 53 20 6f 66 20 74 68 65 20 72 75 6c 65 RHS of the rule
2c50: 2c 20 62 75 74 20 77 68 69 63 68 20 61 72 65 20 , but which are
2c60: 6e 6f 74 20 75 73 65 64 0a 20 20 20 20 2a 2a 20 not used. **
2c70: 69 6e 73 69 64 65 20 74 68 65 20 43 20 63 6f 64 inside the C cod
2c80: 65 2e 0a 20 20 20 20 2a 2f 0a 25 25 0a 20 20 20 e.. */.%%.
2c90: 20 64 65 66 61 75 6c 74 3a 20 20 62 72 65 61 6b default: break
2ca0: 3b 20 20 20 2f 2a 20 49 66 20 6e 6f 20 64 65 73 ; /* If no des
2cb0: 74 72 75 63 74 6f 72 20 61 63 74 69 6f 6e 20 73 tructor action s
2cc0: 70 65 63 69 66 69 65 64 3a 20 64 6f 20 6e 6f 74 pecified: do not
2cd0: 68 69 6e 67 20 2a 2f 0a 20 20 7d 0a 7d 0a 0a 2f hing */. }.}../
2ce0: 2a 0a 2a 2a 20 50 6f 70 20 74 68 65 20 70 61 72 *.** Pop the par
2cf0: 73 65 72 27 73 20 73 74 61 63 6b 20 6f 6e 63 65 ser's stack once
2d00: 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 74 68 65 72 65 ..**.** If there
2d10: 20 69 73 20 61 20 64 65 73 74 72 75 63 74 6f 72 is a destructor
2d20: 20 72 6f 75 74 69 6e 65 20 61 73 73 6f 63 69 61 routine associa
2d30: 74 65 64 20 77 69 74 68 20 74 68 65 20 74 6f 6b ted with the tok
2d40: 65 6e 20 77 68 69 63 68 0a 2a 2a 20 69 73 20 70 en which.** is p
2d50: 6f 70 70 65 64 20 66 72 6f 6d 20 74 68 65 20 73 opped from the s
2d60: 74 61 63 6b 2c 20 74 68 65 6e 20 63 61 6c 6c 20 tack, then call
2d70: 69 74 2e 0a 2a 2a 0a 2a 2a 20 52 65 74 75 72 6e it..**.** Return
2d80: 20 74 68 65 20 6d 61 6a 6f 72 20 74 6f 6b 65 6e the major token
2d90: 20 6e 75 6d 62 65 72 20 66 6f 72 20 74 68 65 20 number for the
2da0: 73 79 6d 62 6f 6c 20 70 6f 70 70 65 64 2e 0a 2a symbol popped..*
2db0: 2f 0a 73 74 61 74 69 63 20 69 6e 74 20 79 79 5f /.static int yy_
2dc0: 70 6f 70 5f 70 61 72 73 65 72 5f 73 74 61 63 6b pop_parser_stack
2dd0: 28 79 79 50 61 72 73 65 72 20 2a 70 50 61 72 73 (yyParser *pPars
2de0: 65 72 29 7b 0a 20 20 59 59 43 4f 44 45 54 59 50 er){. YYCODETYP
2df0: 45 20 79 79 6d 61 6a 6f 72 3b 0a 20 20 79 79 53 E yymajor;. yyS
2e00: 74 61 63 6b 45 6e 74 72 79 20 2a 79 79 74 6f 73 tackEntry *yytos
2e10: 20 3d 20 26 70 50 61 72 73 65 72 2d 3e 79 79 73 = &pParser->yys
2e20: 74 61 63 6b 5b 70 50 61 72 73 65 72 2d 3e 79 79 tack[pParser->yy
2e30: 69 64 78 5d 3b 0a 0a 20 20 2f 2a 20 54 68 65 72 idx];.. /* Ther
2e40: 65 20 69 73 20 6e 6f 20 6d 65 63 68 61 6e 69 73 e is no mechanis
2e50: 6d 20 62 79 20 77 68 69 63 68 20 74 68 65 20 70 m by which the p
2e60: 61 72 73 65 72 20 73 74 61 63 6b 20 63 61 6e 20 arser stack can
2e70: 62 65 20 70 6f 70 70 65 64 20 62 65 6c 6f 77 0a be popped below.
2e80: 20 20 2a 2a 20 65 6d 70 74 79 20 69 6e 20 53 51 ** empty in SQ
2e90: 4c 69 74 65 2e 20 20 2a 2f 0a 20 20 69 66 28 20 Lite. */. if(
2ea0: 4e 45 56 45 52 28 70 50 61 72 73 65 72 2d 3e 79 NEVER(pParser->y
2eb0: 79 69 64 78 3c 30 29 20 29 20 72 65 74 75 72 6e yidx<0) ) return
2ec0: 20 30 3b 0a 23 69 66 6e 64 65 66 20 4e 44 45 42 0;.#ifndef NDEB
2ed0: 55 47 0a 20 20 69 66 28 20 79 79 54 72 61 63 65 UG. if( yyTrace
2ee0: 46 49 4c 45 20 26 26 20 70 50 61 72 73 65 72 2d FILE && pParser-
2ef0: 3e 79 79 69 64 78 3e 3d 30 20 29 7b 0a 20 20 20 >yyidx>=0 ){.
2f00: 20 66 70 72 69 6e 74 66 28 79 79 54 72 61 63 65 fprintf(yyTrace
2f10: 46 49 4c 45 2c 22 25 73 50 6f 70 70 69 6e 67 20 FILE,"%sPopping
2f20: 25 73 5c 6e 22 2c 0a 20 20 20 20 20 20 79 79 54 %s\n",. yyT
2f30: 72 61 63 65 50 72 6f 6d 70 74 2c 0a 20 20 20 20 racePrompt,.
2f40: 20 20 79 79 54 6f 6b 65 6e 4e 61 6d 65 5b 79 79 yyTokenName[yy
2f50: 74 6f 73 2d 3e 6d 61 6a 6f 72 5d 29 3b 0a 20 20 tos->major]);.
2f60: 7d 0a 23 65 6e 64 69 66 0a 20 20 79 79 6d 61 6a }.#endif. yymaj
2f70: 6f 72 20 3d 20 79 79 74 6f 73 2d 3e 6d 61 6a 6f or = yytos->majo
2f80: 72 3b 0a 20 20 79 79 5f 64 65 73 74 72 75 63 74 r;. yy_destruct
2f90: 6f 72 28 70 50 61 72 73 65 72 2c 20 79 79 6d 61 or(pParser, yyma
2fa0: 6a 6f 72 2c 20 26 79 79 74 6f 73 2d 3e 6d 69 6e jor, &yytos->min
2fb0: 6f 72 29 3b 0a 20 20 70 50 61 72 73 65 72 2d 3e or);. pParser->
2fc0: 79 79 69 64 78 2d 2d 3b 0a 20 20 72 65 74 75 72 yyidx--;. retur
2fd0: 6e 20 79 79 6d 61 6a 6f 72 3b 0a 7d 0a 0a 2f 2a n yymajor;.}../*
2fe0: 20 0a 2a 2a 20 44 65 61 6c 6c 6f 63 61 74 65 20 .** Deallocate
2ff0: 61 6e 64 20 64 65 73 74 72 6f 79 20 61 20 70 61 and destroy a pa
3000: 72 73 65 72 2e 20 20 44 65 73 74 72 75 63 74 6f rser. Destructo
3010: 72 73 20 61 72 65 20 61 6c 6c 20 63 61 6c 6c 65 rs are all calle
3020: 64 20 66 6f 72 0a 2a 2a 20 61 6c 6c 20 73 74 61 d for.** all sta
3030: 63 6b 20 65 6c 65 6d 65 6e 74 73 20 62 65 66 6f ck elements befo
3040: 72 65 20 73 68 75 74 74 69 6e 67 20 74 68 65 20 re shutting the
3050: 70 61 72 73 65 72 20 64 6f 77 6e 2e 0a 2a 2a 0a parser down..**.
3060: 2a 2a 20 49 6e 70 75 74 73 3a 0a 2a 2a 20 3c 75 ** Inputs:.** <u
3070: 6c 3e 0a 2a 2a 20 3c 6c 69 3e 20 20 41 20 70 6f l>.** <li> A po
3080: 69 6e 74 65 72 20 74 6f 20 74 68 65 20 70 61 72 inter to the par
3090: 73 65 72 2e 20 20 54 68 69 73 20 73 68 6f 75 6c ser. This shoul
30a0: 64 20 62 65 20 61 20 70 6f 69 6e 74 65 72 0a 2a d be a pointer.*
30b0: 2a 20 20 20 20 20 20 20 6f 62 74 61 69 6e 65 64 * obtained
30c0: 20 66 72 6f 6d 20 50 61 72 73 65 41 6c 6c 6f 63 from ParseAlloc
30d0: 2e 0a 2a 2a 20 3c 6c 69 3e 20 20 41 20 70 6f 69 ..** <li> A poi
30e0: 6e 74 65 72 20 74 6f 20 61 20 66 75 6e 63 74 69 nter to a functi
30f0: 6f 6e 20 75 73 65 64 20 74 6f 20 72 65 63 6c 61 on used to recla
3100: 69 6d 20 6d 65 6d 6f 72 79 20 6f 62 74 61 69 6e im memory obtain
3110: 65 64 0a 2a 2a 20 20 20 20 20 20 20 66 72 6f 6d ed.** from
3120: 20 6d 61 6c 6c 6f 63 2e 0a 2a 2a 20 3c 2f 75 6c malloc..** </ul
3130: 3e 0a 2a 2f 0a 76 6f 69 64 20 50 61 72 73 65 46 >.*/.void ParseF
3140: 72 65 65 28 0a 20 20 76 6f 69 64 20 2a 70 2c 20 ree(. void *p,
3150: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3160: 20 20 20 2f 2a 20 54 68 65 20 70 61 72 73 65 72 /* The parser
3170: 20 74 6f 20 62 65 20 64 65 6c 65 74 65 64 20 2a to be deleted *
3180: 2f 0a 20 20 76 6f 69 64 20 28 2a 66 72 65 65 50 /. void (*freeP
3190: 72 6f 63 29 28 76 6f 69 64 2a 29 20 20 20 20 20 roc)(void*)
31a0: 2f 2a 20 46 75 6e 63 74 69 6f 6e 20 75 73 65 64 /* Function used
31b0: 20 74 6f 20 72 65 63 6c 61 69 6d 20 6d 65 6d 6f to reclaim memo
31c0: 72 79 20 2a 2f 0a 29 7b 0a 20 20 79 79 50 61 72 ry */.){. yyPar
31d0: 73 65 72 20 2a 70 50 61 72 73 65 72 20 3d 20 28 ser *pParser = (
31e0: 79 79 50 61 72 73 65 72 2a 29 70 3b 0a 20 20 2f yyParser*)p;. /
31f0: 2a 20 49 6e 20 53 51 4c 69 74 65 2c 20 77 65 20 * In SQLite, we
3200: 6e 65 76 65 72 20 74 72 79 20 74 6f 20 64 65 73 never try to des
3210: 74 72 6f 79 20 61 20 70 61 72 73 65 72 20 74 68 troy a parser th
3220: 61 74 20 77 61 73 20 6e 6f 74 20 73 75 63 63 65 at was not succe
3230: 73 73 66 75 6c 6c 79 0a 20 20 2a 2a 20 63 72 65 ssfully. ** cre
3240: 61 74 65 64 20 69 6e 20 74 68 65 20 66 69 72 73 ated in the firs
3250: 74 20 70 6c 61 63 65 2e 20 2a 2f 0a 20 20 69 66 t place. */. if
3260: 28 20 4e 45 56 45 52 28 70 50 61 72 73 65 72 3d ( NEVER(pParser=
3270: 3d 30 29 20 29 20 72 65 74 75 72 6e 3b 0a 20 20 =0) ) return;.
3280: 77 68 69 6c 65 28 20 70 50 61 72 73 65 72 2d 3e while( pParser->
3290: 79 79 69 64 78 3e 3d 30 20 29 20 79 79 5f 70 6f yyidx>=0 ) yy_po
32a0: 70 5f 70 61 72 73 65 72 5f 73 74 61 63 6b 28 70 p_parser_stack(p
32b0: 50 61 72 73 65 72 29 3b 0a 23 69 66 20 59 59 53 Parser);.#if YYS
32c0: 54 41 43 4b 44 45 50 54 48 3c 3d 30 0a 20 20 66 TACKDEPTH<=0. f
32d0: 72 65 65 28 70 50 61 72 73 65 72 2d 3e 79 79 73 ree(pParser->yys
32e0: 74 61 63 6b 29 3b 0a 23 65 6e 64 69 66 0a 20 20 tack);.#endif.
32f0: 28 2a 66 72 65 65 50 72 6f 63 29 28 28 76 6f 69 (*freeProc)((voi
3300: 64 2a 29 70 50 61 72 73 65 72 29 3b 0a 7d 0a 0a d*)pParser);.}..
3310: 2f 2a 0a 2a 2a 20 52 65 74 75 72 6e 20 74 68 65 /*.** Return the
3320: 20 70 65 61 6b 20 64 65 70 74 68 20 6f 66 20 74 peak depth of t
3330: 68 65 20 73 74 61 63 6b 20 66 6f 72 20 61 20 70 he stack for a p
3340: 61 72 73 65 72 2e 0a 2a 2f 0a 23 69 66 64 65 66 arser..*/.#ifdef
3350: 20 59 59 54 52 41 43 4b 4d 41 58 53 54 41 43 4b YYTRACKMAXSTACK
3360: 44 45 50 54 48 0a 69 6e 74 20 50 61 72 73 65 53 DEPTH.int ParseS
3370: 74 61 63 6b 50 65 61 6b 28 76 6f 69 64 20 2a 70 tackPeak(void *p
3380: 29 7b 0a 20 20 79 79 50 61 72 73 65 72 20 2a 70 ){. yyParser *p
3390: 50 61 72 73 65 72 20 3d 20 28 79 79 50 61 72 73 Parser = (yyPars
33a0: 65 72 2a 29 70 3b 0a 20 20 72 65 74 75 72 6e 20 er*)p;. return
33b0: 70 50 61 72 73 65 72 2d 3e 79 79 69 64 78 4d 61 pParser->yyidxMa
33c0: 78 3b 0a 7d 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a x;.}.#endif../*.
33d0: 2a 2a 20 46 69 6e 64 20 74 68 65 20 61 70 70 72 ** Find the appr
33e0: 6f 70 72 69 61 74 65 20 61 63 74 69 6f 6e 20 66 opriate action f
33f0: 6f 72 20 61 20 70 61 72 73 65 72 20 67 69 76 65 or a parser give
3400: 6e 20 74 68 65 20 74 65 72 6d 69 6e 61 6c 0a 2a n the terminal.*
3410: 2a 20 6c 6f 6f 6b 2d 61 68 65 61 64 20 74 6f 6b * look-ahead tok
3420: 65 6e 20 69 4c 6f 6f 6b 41 68 65 61 64 2e 0a 2a en iLookAhead..*
3430: 2a 0a 2a 2a 20 49 66 20 74 68 65 20 6c 6f 6f 6b *.** If the look
3440: 2d 61 68 65 61 64 20 74 6f 6b 65 6e 20 69 73 20 -ahead token is
3450: 59 59 4e 4f 43 4f 44 45 2c 20 74 68 65 6e 20 63 YYNOCODE, then c
3460: 68 65 63 6b 20 74 6f 20 73 65 65 20 69 66 20 74 heck to see if t
3470: 68 65 20 61 63 74 69 6f 6e 20 69 73 0a 2a 2a 20 he action is.**
3480: 69 6e 64 65 70 65 6e 64 65 6e 74 20 6f 66 20 74 independent of t
3490: 68 65 20 6c 6f 6f 6b 2d 61 68 65 61 64 2e 20 20 he look-ahead.
34a0: 49 66 20 69 74 20 69 73 2c 20 72 65 74 75 72 6e If it is, return
34b0: 20 74 68 65 20 61 63 74 69 6f 6e 2c 20 6f 74 68 the action, oth
34c0: 65 72 77 69 73 65 0a 2a 2a 20 72 65 74 75 72 6e erwise.** return
34d0: 20 59 59 5f 4e 4f 5f 41 43 54 49 4f 4e 2e 0a 2a YY_NO_ACTION..*
34e0: 2f 0a 73 74 61 74 69 63 20 69 6e 74 20 79 79 5f /.static int yy_
34f0: 66 69 6e 64 5f 73 68 69 66 74 5f 61 63 74 69 6f find_shift_actio
3500: 6e 28 0a 20 20 79 79 50 61 72 73 65 72 20 2a 70 n(. yyParser *p
3510: 50 61 72 73 65 72 2c 20 20 20 20 20 20 20 20 2f Parser, /
3520: 2a 20 54 68 65 20 70 61 72 73 65 72 20 2a 2f 0a * The parser */.
3530: 20 20 59 59 43 4f 44 45 54 59 50 45 20 69 4c 6f YYCODETYPE iLo
3540: 6f 6b 41 68 65 61 64 20 20 20 20 20 2f 2a 20 54 okAhead /* T
3550: 68 65 20 6c 6f 6f 6b 2d 61 68 65 61 64 20 74 6f he look-ahead to
3560: 6b 65 6e 20 2a 2f 0a 29 7b 0a 20 20 69 6e 74 20 ken */.){. int
3570: 69 3b 0a 20 20 69 6e 74 20 73 74 61 74 65 6e 6f i;. int stateno
3580: 20 3d 20 70 50 61 72 73 65 72 2d 3e 79 79 73 74 = pParser->yyst
3590: 61 63 6b 5b 70 50 61 72 73 65 72 2d 3e 79 79 69 ack[pParser->yyi
35a0: 64 78 5d 2e 73 74 61 74 65 6e 6f 3b 0a 20 0a 20 dx].stateno;. .
35b0: 20 69 66 28 20 73 74 61 74 65 6e 6f 3e 59 59 5f if( stateno>YY_
35c0: 53 48 49 46 54 5f 43 4f 55 4e 54 0a 20 20 20 7c SHIFT_COUNT. |
35d0: 7c 20 28 69 20 3d 20 79 79 5f 73 68 69 66 74 5f | (i = yy_shift_
35e0: 6f 66 73 74 5b 73 74 61 74 65 6e 6f 5d 29 3d 3d ofst[stateno])==
35f0: 59 59 5f 53 48 49 46 54 5f 55 53 45 5f 44 46 4c YY_SHIFT_USE_DFL
3600: 54 20 29 7b 0a 20 20 20 20 72 65 74 75 72 6e 20 T ){. return
3610: 79 79 5f 64 65 66 61 75 6c 74 5b 73 74 61 74 65 yy_default[state
3620: 6e 6f 5d 3b 0a 20 20 7d 0a 20 20 61 73 73 65 72 no];. }. asser
3630: 74 28 20 69 4c 6f 6f 6b 41 68 65 61 64 21 3d 59 t( iLookAhead!=Y
3640: 59 4e 4f 43 4f 44 45 20 29 3b 0a 20 20 69 20 2b YNOCODE );. i +
3650: 3d 20 69 4c 6f 6f 6b 41 68 65 61 64 3b 0a 20 20 = iLookAhead;.
3660: 69 66 28 20 69 3c 30 20 7c 7c 20 69 3e 3d 59 59 if( i<0 || i>=YY
3670: 5f 41 43 54 54 41 42 5f 43 4f 55 4e 54 20 7c 7c _ACTTAB_COUNT ||
3680: 20 79 79 5f 6c 6f 6f 6b 61 68 65 61 64 5b 69 5d yy_lookahead[i]
3690: 21 3d 69 4c 6f 6f 6b 41 68 65 61 64 20 29 7b 0a !=iLookAhead ){.
36a0: 20 20 20 20 69 66 28 20 69 4c 6f 6f 6b 41 68 65 if( iLookAhe
36b0: 61 64 3e 30 20 29 7b 0a 23 69 66 64 65 66 20 59 ad>0 ){.#ifdef Y
36c0: 59 46 41 4c 4c 42 41 43 4b 0a 20 20 20 20 20 20 YFALLBACK.
36d0: 59 59 43 4f 44 45 54 59 50 45 20 69 46 61 6c 6c YYCODETYPE iFall
36e0: 62 61 63 6b 3b 20 20 20 20 20 20 20 20 20 20 20 back;
36f0: 20 2f 2a 20 46 61 6c 6c 62 61 63 6b 20 74 6f 6b /* Fallback tok
3700: 65 6e 20 2a 2f 0a 20 20 20 20 20 20 69 66 28 20 en */. if(
3710: 69 4c 6f 6f 6b 41 68 65 61 64 3c 73 69 7a 65 6f iLookAhead<sizeo
3720: 66 28 79 79 46 61 6c 6c 62 61 63 6b 29 2f 73 69 f(yyFallback)/si
3730: 7a 65 6f 66 28 79 79 46 61 6c 6c 62 61 63 6b 5b zeof(yyFallback[
3740: 30 5d 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 0]).
3750: 20 26 26 20 28 69 46 61 6c 6c 62 61 63 6b 20 3d && (iFallback =
3760: 20 79 79 46 61 6c 6c 62 61 63 6b 5b 69 4c 6f 6f yyFallback[iLoo
3770: 6b 41 68 65 61 64 5d 29 21 3d 30 20 29 7b 0a 23 kAhead])!=0 ){.#
3780: 69 66 6e 64 65 66 20 4e 44 45 42 55 47 0a 20 20 ifndef NDEBUG.
3790: 20 20 20 20 20 20 69 66 28 20 79 79 54 72 61 63 if( yyTrac
37a0: 65 46 49 4c 45 20 29 7b 0a 20 20 20 20 20 20 20 eFILE ){.
37b0: 20 20 20 66 70 72 69 6e 74 66 28 79 79 54 72 61 fprintf(yyTra
37c0: 63 65 46 49 4c 45 2c 20 22 25 73 46 41 4c 4c 42 ceFILE, "%sFALLB
37d0: 41 43 4b 20 25 73 20 3d 3e 20 25 73 5c 6e 22 2c ACK %s => %s\n",
37e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 79 79 . yy
37f0: 54 72 61 63 65 50 72 6f 6d 70 74 2c 20 79 79 54 TracePrompt, yyT
3800: 6f 6b 65 6e 4e 61 6d 65 5b 69 4c 6f 6f 6b 41 68 okenName[iLookAh
3810: 65 61 64 5d 2c 20 79 79 54 6f 6b 65 6e 4e 61 6d ead], yyTokenNam
3820: 65 5b 69 46 61 6c 6c 62 61 63 6b 5d 29 3b 0a 20 e[iFallback]);.
3830: 20 20 20 20 20 20 20 7d 0a 23 65 6e 64 69 66 0a }.#endif.
3840: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 79 return y
3850: 79 5f 66 69 6e 64 5f 73 68 69 66 74 5f 61 63 74 y_find_shift_act
3860: 69 6f 6e 28 70 50 61 72 73 65 72 2c 20 69 46 61 ion(pParser, iFa
3870: 6c 6c 62 61 63 6b 29 3b 0a 20 20 20 20 20 20 7d llback);. }
3880: 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 66 20 59 .#endif.#ifdef Y
3890: 59 57 49 4c 44 43 41 52 44 0a 20 20 20 20 20 20 YWILDCARD.
38a0: 7b 0a 20 20 20 20 20 20 20 20 69 6e 74 20 6a 20 {. int j
38b0: 3d 20 69 20 2d 20 69 4c 6f 6f 6b 41 68 65 61 64 = i - iLookAhead
38c0: 20 2b 20 59 59 57 49 4c 44 43 41 52 44 3b 0a 20 + YYWILDCARD;.
38d0: 20 20 20 20 20 20 20 69 66 28 20 0a 23 69 66 20 if( .#if
38e0: 59 59 5f 53 48 49 46 54 5f 4d 49 4e 2b 59 59 57 YY_SHIFT_MIN+YYW
38f0: 49 4c 44 43 41 52 44 3c 30 0a 20 20 20 20 20 20 ILDCARD<0.
3900: 20 20 20 20 6a 3e 3d 30 20 26 26 0a 23 65 6e 64 j>=0 &&.#end
3910: 69 66 0a 23 69 66 20 59 59 5f 53 48 49 46 54 5f if.#if YY_SHIFT_
3920: 4d 41 58 2b 59 59 57 49 4c 44 43 41 52 44 3e 3d MAX+YYWILDCARD>=
3930: 59 59 5f 41 43 54 54 41 42 5f 43 4f 55 4e 54 0a YY_ACTTAB_COUNT.
3940: 20 20 20 20 20 20 20 20 20 20 6a 3c 59 59 5f 41 j<YY_A
3950: 43 54 54 41 42 5f 43 4f 55 4e 54 20 26 26 0a 23 CTTAB_COUNT &&.#
3960: 65 6e 64 69 66 0a 20 20 20 20 20 20 20 20 20 20 endif.
3970: 79 79 5f 6c 6f 6f 6b 61 68 65 61 64 5b 6a 5d 3d yy_lookahead[j]=
3980: 3d 59 59 57 49 4c 44 43 41 52 44 0a 20 20 20 20 =YYWILDCARD.
3990: 20 20 20 20 29 7b 0a 23 69 66 6e 64 65 66 20 4e ){.#ifndef N
39a0: 44 45 42 55 47 0a 20 20 20 20 20 20 20 20 20 20 DEBUG.
39b0: 69 66 28 20 79 79 54 72 61 63 65 46 49 4c 45 20 if( yyTraceFILE
39c0: 29 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 ){. f
39d0: 70 72 69 6e 74 66 28 79 79 54 72 61 63 65 46 49 printf(yyTraceFI
39e0: 4c 45 2c 20 22 25 73 57 49 4c 44 43 41 52 44 20 LE, "%sWILDCARD
39f0: 25 73 20 3d 3e 20 25 73 5c 6e 22 2c 0a 20 20 20 %s => %s\n",.
3a00: 20 20 20 20 20 20 20 20 20 20 20 20 79 79 54 72 yyTr
3a10: 61 63 65 50 72 6f 6d 70 74 2c 20 79 79 54 6f 6b acePrompt, yyTok
3a20: 65 6e 4e 61 6d 65 5b 69 4c 6f 6f 6b 41 68 65 61 enName[iLookAhea
3a30: 64 5d 2c 20 79 79 54 6f 6b 65 6e 4e 61 6d 65 5b d], yyTokenName[
3a40: 59 59 57 49 4c 44 43 41 52 44 5d 29 3b 0a 20 20 YYWILDCARD]);.
3a50: 20 20 20 20 20 20 20 20 7d 0a 23 65 6e 64 69 66 }.#endif
3a60: 20 2f 2a 20 4e 44 45 42 55 47 20 2a 2f 0a 20 20 /* NDEBUG */.
3a70: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 79 return y
3a80: 79 5f 61 63 74 69 6f 6e 5b 6a 5d 3b 0a 20 20 20 y_action[j];.
3a90: 20 20 20 20 20 7d 0a 20 20 20 20 20 20 7d 0a 23 }. }.#
3aa0: 65 6e 64 69 66 20 2f 2a 20 59 59 57 49 4c 44 43 endif /* YYWILDC
3ab0: 41 52 44 20 2a 2f 0a 20 20 20 20 7d 0a 20 20 20 ARD */. }.
3ac0: 20 72 65 74 75 72 6e 20 79 79 5f 64 65 66 61 75 return yy_defau
3ad0: 6c 74 5b 73 74 61 74 65 6e 6f 5d 3b 0a 20 20 7d lt[stateno];. }
3ae0: 65 6c 73 65 7b 0a 20 20 20 20 72 65 74 75 72 6e else{. return
3af0: 20 79 79 5f 61 63 74 69 6f 6e 5b 69 5d 3b 0a 20 yy_action[i];.
3b00: 20 7d 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 46 69 6e 64 }.}../*.** Find
3b10: 20 74 68 65 20 61 70 70 72 6f 70 72 69 61 74 65 the appropriate
3b20: 20 61 63 74 69 6f 6e 20 66 6f 72 20 61 20 70 61 action for a pa
3b30: 72 73 65 72 20 67 69 76 65 6e 20 74 68 65 20 6e rser given the n
3b40: 6f 6e 2d 74 65 72 6d 69 6e 61 6c 0a 2a 2a 20 6c on-terminal.** l
3b50: 6f 6f 6b 2d 61 68 65 61 64 20 74 6f 6b 65 6e 20 ook-ahead token
3b60: 69 4c 6f 6f 6b 41 68 65 61 64 2e 0a 2a 2a 0a 2a iLookAhead..**.*
3b70: 2a 20 49 66 20 74 68 65 20 6c 6f 6f 6b 2d 61 68 * If the look-ah
3b80: 65 61 64 20 74 6f 6b 65 6e 20 69 73 20 59 59 4e ead token is YYN
3b90: 4f 43 4f 44 45 2c 20 74 68 65 6e 20 63 68 65 63 OCODE, then chec
3ba0: 6b 20 74 6f 20 73 65 65 20 69 66 20 74 68 65 20 k to see if the
3bb0: 61 63 74 69 6f 6e 20 69 73 0a 2a 2a 20 69 6e 64 action is.** ind
3bc0: 65 70 65 6e 64 65 6e 74 20 6f 66 20 74 68 65 20 ependent of the
3bd0: 6c 6f 6f 6b 2d 61 68 65 61 64 2e 20 20 49 66 20 look-ahead. If
3be0: 69 74 20 69 73 2c 20 72 65 74 75 72 6e 20 74 68 it is, return th
3bf0: 65 20 61 63 74 69 6f 6e 2c 20 6f 74 68 65 72 77 e action, otherw
3c00: 69 73 65 0a 2a 2a 20 72 65 74 75 72 6e 20 59 59 ise.** return YY
3c10: 5f 4e 4f 5f 41 43 54 49 4f 4e 2e 0a 2a 2f 0a 73 _NO_ACTION..*/.s
3c20: 74 61 74 69 63 20 69 6e 74 20 79 79 5f 66 69 6e tatic int yy_fin
3c30: 64 5f 72 65 64 75 63 65 5f 61 63 74 69 6f 6e 28 d_reduce_action(
3c40: 0a 20 20 69 6e 74 20 73 74 61 74 65 6e 6f 2c 20 . int stateno,
3c50: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 /*
3c60: 43 75 72 72 65 6e 74 20 73 74 61 74 65 20 6e 75 Current state nu
3c70: 6d 62 65 72 20 2a 2f 0a 20 20 59 59 43 4f 44 45 mber */. YYCODE
3c80: 54 59 50 45 20 69 4c 6f 6f 6b 41 68 65 61 64 20 TYPE iLookAhead
3c90: 20 20 20 20 2f 2a 20 54 68 65 20 6c 6f 6f 6b 2d /* The look-
3ca0: 61 68 65 61 64 20 74 6f 6b 65 6e 20 2a 2f 0a 29 ahead token */.)
3cb0: 7b 0a 20 20 69 6e 74 20 69 3b 0a 23 69 66 64 65 {. int i;.#ifde
3cc0: 66 20 59 59 45 52 52 4f 52 53 59 4d 42 4f 4c 0a f YYERRORSYMBOL.
3cd0: 20 20 69 66 28 20 73 74 61 74 65 6e 6f 3e 59 59 if( stateno>YY
3ce0: 5f 52 45 44 55 43 45 5f 43 4f 55 4e 54 20 29 7b _REDUCE_COUNT ){
3cf0: 0a 20 20 20 20 72 65 74 75 72 6e 20 79 79 5f 64 . return yy_d
3d00: 65 66 61 75 6c 74 5b 73 74 61 74 65 6e 6f 5d 3b efault[stateno];
3d10: 0a 20 20 7d 0a 23 65 6c 73 65 0a 20 20 61 73 73 . }.#else. ass
3d20: 65 72 74 28 20 73 74 61 74 65 6e 6f 3c 3d 59 59 ert( stateno<=YY
3d30: 5f 52 45 44 55 43 45 5f 43 4f 55 4e 54 20 29 3b _REDUCE_COUNT );
3d40: 0a 23 65 6e 64 69 66 0a 20 20 69 20 3d 20 79 79 .#endif. i = yy
3d50: 5f 72 65 64 75 63 65 5f 6f 66 73 74 5b 73 74 61 _reduce_ofst[sta
3d60: 74 65 6e 6f 5d 3b 0a 20 20 61 73 73 65 72 74 28 teno];. assert(
3d70: 20 69 21 3d 59 59 5f 52 45 44 55 43 45 5f 55 53 i!=YY_REDUCE_US
3d80: 45 5f 44 46 4c 54 20 29 3b 0a 20 20 61 73 73 65 E_DFLT );. asse
3d90: 72 74 28 20 69 4c 6f 6f 6b 41 68 65 61 64 21 3d rt( iLookAhead!=
3da0: 59 59 4e 4f 43 4f 44 45 20 29 3b 0a 20 20 69 20 YYNOCODE );. i
3db0: 2b 3d 20 69 4c 6f 6f 6b 41 68 65 61 64 3b 0a 23 += iLookAhead;.#
3dc0: 69 66 64 65 66 20 59 59 45 52 52 4f 52 53 59 4d ifdef YYERRORSYM
3dd0: 42 4f 4c 0a 20 20 69 66 28 20 69 3c 30 20 7c 7c BOL. if( i<0 ||
3de0: 20 69 3e 3d 59 59 5f 41 43 54 54 41 42 5f 43 4f i>=YY_ACTTAB_CO
3df0: 55 4e 54 20 7c 7c 20 79 79 5f 6c 6f 6f 6b 61 68 UNT || yy_lookah
3e00: 65 61 64 5b 69 5d 21 3d 69 4c 6f 6f 6b 41 68 65 ead[i]!=iLookAhe
3e10: 61 64 20 29 7b 0a 20 20 20 20 72 65 74 75 72 6e ad ){. return
3e20: 20 79 79 5f 64 65 66 61 75 6c 74 5b 73 74 61 74 yy_default[stat
3e30: 65 6e 6f 5d 3b 0a 20 20 7d 0a 23 65 6c 73 65 0a eno];. }.#else.
3e40: 20 20 61 73 73 65 72 74 28 20 69 3e 3d 30 20 26 assert( i>=0 &
3e50: 26 20 69 3c 59 59 5f 41 43 54 54 41 42 5f 43 4f & i<YY_ACTTAB_CO
3e60: 55 4e 54 20 29 3b 0a 20 20 61 73 73 65 72 74 28 UNT );. assert(
3e70: 20 79 79 5f 6c 6f 6f 6b 61 68 65 61 64 5b 69 5d yy_lookahead[i]
3e80: 3d 3d 69 4c 6f 6f 6b 41 68 65 61 64 20 29 3b 0a ==iLookAhead );.
3e90: 23 65 6e 64 69 66 0a 20 20 72 65 74 75 72 6e 20 #endif. return
3ea0: 79 79 5f 61 63 74 69 6f 6e 5b 69 5d 3b 0a 7d 0a yy_action[i];.}.
3eb0: 0a 2f 2a 0a 2a 2a 20 54 68 65 20 66 6f 6c 6c 6f ./*.** The follo
3ec0: 77 69 6e 67 20 72 6f 75 74 69 6e 65 20 69 73 20 wing routine is
3ed0: 63 61 6c 6c 65 64 20 69 66 20 74 68 65 20 73 74 called if the st
3ee0: 61 63 6b 20 6f 76 65 72 66 6c 6f 77 73 2e 0a 2a ack overflows..*
3ef0: 2f 0a 73 74 61 74 69 63 20 76 6f 69 64 20 79 79 /.static void yy
3f00: 53 74 61 63 6b 4f 76 65 72 66 6c 6f 77 28 79 79 StackOverflow(yy
3f10: 50 61 72 73 65 72 20 2a 79 79 70 50 61 72 73 65 Parser *yypParse
3f20: 72 2c 20 59 59 4d 49 4e 4f 52 54 59 50 45 20 2a r, YYMINORTYPE *
3f30: 79 79 70 4d 69 6e 6f 72 29 7b 0a 20 20 20 50 61 yypMinor){. Pa
3f40: 72 73 65 41 52 47 5f 46 45 54 43 48 3b 0a 20 20 rseARG_FETCH;.
3f50: 20 79 79 70 50 61 72 73 65 72 2d 3e 79 79 69 64 yypParser->yyid
3f60: 78 2d 2d 3b 0a 23 69 66 6e 64 65 66 20 4e 44 45 x--;.#ifndef NDE
3f70: 42 55 47 0a 20 20 20 69 66 28 20 79 79 54 72 61 BUG. if( yyTra
3f80: 63 65 46 49 4c 45 20 29 7b 0a 20 20 20 20 20 66 ceFILE ){. f
3f90: 70 72 69 6e 74 66 28 79 79 54 72 61 63 65 46 49 printf(yyTraceFI
3fa0: 4c 45 2c 22 25 73 53 74 61 63 6b 20 4f 76 65 72 LE,"%sStack Over
3fb0: 66 6c 6f 77 21 5c 6e 22 2c 79 79 54 72 61 63 65 flow!\n",yyTrace
3fc0: 50 72 6f 6d 70 74 29 3b 0a 20 20 20 7d 0a 23 65 Prompt);. }.#e
3fd0: 6e 64 69 66 0a 20 20 20 77 68 69 6c 65 28 20 79 ndif. while( y
3fe0: 79 70 50 61 72 73 65 72 2d 3e 79 79 69 64 78 3e ypParser->yyidx>
3ff0: 3d 30 20 29 20 79 79 5f 70 6f 70 5f 70 61 72 73 =0 ) yy_pop_pars
4000: 65 72 5f 73 74 61 63 6b 28 79 79 70 50 61 72 73 er_stack(yypPars
4010: 65 72 29 3b 0a 20 20 20 2f 2a 20 48 65 72 65 20 er);. /* Here
4020: 63 6f 64 65 20 69 73 20 69 6e 73 65 72 74 65 64 code is inserted
4030: 20 77 68 69 63 68 20 77 69 6c 6c 20 65 78 65 63 which will exec
4040: 75 74 65 20 69 66 20 74 68 65 20 70 61 72 73 65 ute if the parse
4050: 72 0a 20 20 20 2a 2a 20 73 74 61 63 6b 20 65 76 r. ** stack ev
4060: 65 72 79 20 6f 76 65 72 66 6c 6f 77 73 20 2a 2f ery overflows */
4070: 0a 25 25 0a 20 20 20 50 61 72 73 65 41 52 47 5f .%%. ParseARG_
4080: 53 54 4f 52 45 3b 20 2f 2a 20 53 75 70 70 72 65 STORE; /* Suppre
4090: 73 73 20 77 61 72 6e 69 6e 67 20 61 62 6f 75 74 ss warning about
40a0: 20 75 6e 75 73 65 64 20 25 65 78 74 72 61 5f 61 unused %extra_a
40b0: 72 67 75 6d 65 6e 74 20 76 61 72 20 2a 2f 0a 7d rgument var */.}
40c0: 0a 0a 2f 2a 0a 2a 2a 20 50 65 72 66 6f 72 6d 20 ../*.** Perform
40d0: 61 20 73 68 69 66 74 20 61 63 74 69 6f 6e 2e 0a a shift action..
40e0: 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 64 20 79 */.static void y
40f0: 79 5f 73 68 69 66 74 28 0a 20 20 79 79 50 61 72 y_shift(. yyPar
4100: 73 65 72 20 2a 79 79 70 50 61 72 73 65 72 2c 20 ser *yypParser,
4110: 20 20 20 20 20 20 20 20 20 2f 2a 20 54 68 65 20 /* The
4120: 70 61 72 73 65 72 20 74 6f 20 62 65 20 73 68 69 parser to be shi
4130: 66 74 65 64 20 2a 2f 0a 20 20 69 6e 74 20 79 79 fted */. int yy
4140: 4e 65 77 53 74 61 74 65 2c 20 20 20 20 20 20 20 NewState,
4150: 20 20 20 20 20 20 20 20 2f 2a 20 54 68 65 20 6e /* The n
4160: 65 77 20 73 74 61 74 65 20 74 6f 20 73 68 69 66 ew state to shif
4170: 74 20 69 6e 20 2a 2f 0a 20 20 69 6e 74 20 79 79 t in */. int yy
4180: 4d 61 6a 6f 72 2c 20 20 20 20 20 20 20 20 20 20 Major,
4190: 20 20 20 20 20 20 20 20 2f 2a 20 54 68 65 20 6d /* The m
41a0: 61 6a 6f 72 20 74 6f 6b 65 6e 20 74 6f 20 73 68 ajor token to sh
41b0: 69 66 74 20 69 6e 20 2a 2f 0a 20 20 59 59 4d 49 ift in */. YYMI
41c0: 4e 4f 52 54 59 50 45 20 2a 79 79 70 4d 69 6e 6f NORTYPE *yypMino
41d0: 72 20 20 20 20 20 20 20 20 20 2f 2a 20 50 6f 69 r /* Poi
41e0: 6e 74 65 72 20 74 6f 20 74 68 65 20 6d 69 6e 6f nter to the mino
41f0: 72 20 74 6f 6b 65 6e 20 74 6f 20 73 68 69 66 74 r token to shift
4200: 20 69 6e 20 2a 2f 0a 29 7b 0a 20 20 79 79 53 74 in */.){. yySt
4210: 61 63 6b 45 6e 74 72 79 20 2a 79 79 74 6f 73 3b ackEntry *yytos;
4220: 0a 20 20 79 79 70 50 61 72 73 65 72 2d 3e 79 79 . yypParser->yy
4230: 69 64 78 2b 2b 3b 0a 23 69 66 64 65 66 20 59 59 idx++;.#ifdef YY
4240: 54 52 41 43 4b 4d 41 58 53 54 41 43 4b 44 45 50 TRACKMAXSTACKDEP
4250: 54 48 0a 20 20 69 66 28 20 79 79 70 50 61 72 73 TH. if( yypPars
4260: 65 72 2d 3e 79 79 69 64 78 3e 79 79 70 50 61 72 er->yyidx>yypPar
4270: 73 65 72 2d 3e 79 79 69 64 78 4d 61 78 20 29 7b ser->yyidxMax ){
4280: 0a 20 20 20 20 79 79 70 50 61 72 73 65 72 2d 3e . yypParser->
4290: 79 79 69 64 78 4d 61 78 20 3d 20 79 79 70 50 61 yyidxMax = yypPa
42a0: 72 73 65 72 2d 3e 79 79 69 64 78 3b 0a 20 20 7d rser->yyidx;. }
42b0: 0a 23 65 6e 64 69 66 0a 23 69 66 20 59 59 53 54 .#endif.#if YYST
42c0: 41 43 4b 44 45 50 54 48 3e 30 20 0a 20 20 69 66 ACKDEPTH>0 . if
42d0: 28 20 79 79 70 50 61 72 73 65 72 2d 3e 79 79 69 ( yypParser->yyi
42e0: 64 78 3e 3d 59 59 53 54 41 43 4b 44 45 50 54 48 dx>=YYSTACKDEPTH
42f0: 20 29 7b 0a 20 20 20 20 79 79 53 74 61 63 6b 4f ){. yyStackO
4300: 76 65 72 66 6c 6f 77 28 79 79 70 50 61 72 73 65 verflow(yypParse
4310: 72 2c 20 79 79 70 4d 69 6e 6f 72 29 3b 0a 20 20 r, yypMinor);.
4320: 20 20 72 65 74 75 72 6e 3b 0a 20 20 7d 0a 23 65 return;. }.#e
4330: 6c 73 65 0a 20 20 69 66 28 20 79 79 70 50 61 72 lse. if( yypPar
4340: 73 65 72 2d 3e 79 79 69 64 78 3e 3d 79 79 70 50 ser->yyidx>=yypP
4350: 61 72 73 65 72 2d 3e 79 79 73 74 6b 73 7a 20 29 arser->yystksz )
4360: 7b 0a 20 20 20 20 79 79 47 72 6f 77 53 74 61 63 {. yyGrowStac
4370: 6b 28 79 79 70 50 61 72 73 65 72 29 3b 0a 20 20 k(yypParser);.
4380: 20 20 69 66 28 20 79 79 70 50 61 72 73 65 72 2d if( yypParser-
4390: 3e 79 79 69 64 78 3e 3d 79 79 70 50 61 72 73 65 >yyidx>=yypParse
43a0: 72 2d 3e 79 79 73 74 6b 73 7a 20 29 7b 0a 20 20 r->yystksz ){.
43b0: 20 20 20 20 79 79 53 74 61 63 6b 4f 76 65 72 66 yyStackOverf
43c0: 6c 6f 77 28 79 79 70 50 61 72 73 65 72 2c 20 79 low(yypParser, y
43d0: 79 70 4d 69 6e 6f 72 29 3b 0a 20 20 20 20 20 20 ypMinor);.
43e0: 72 65 74 75 72 6e 3b 0a 20 20 20 20 7d 0a 20 20 return;. }.
43f0: 7d 0a 23 65 6e 64 69 66 0a 20 20 79 79 74 6f 73 }.#endif. yytos
4400: 20 3d 20 26 79 79 70 50 61 72 73 65 72 2d 3e 79 = &yypParser->y
4410: 79 73 74 61 63 6b 5b 79 79 70 50 61 72 73 65 72 ystack[yypParser
4420: 2d 3e 79 79 69 64 78 5d 3b 0a 20 20 79 79 74 6f ->yyidx];. yyto
4430: 73 2d 3e 73 74 61 74 65 6e 6f 20 3d 20 28 59 59 s->stateno = (YY
4440: 41 43 54 49 4f 4e 54 59 50 45 29 79 79 4e 65 77 ACTIONTYPE)yyNew
4450: 53 74 61 74 65 3b 0a 20 20 79 79 74 6f 73 2d 3e State;. yytos->
4460: 6d 61 6a 6f 72 20 3d 20 28 59 59 43 4f 44 45 54 major = (YYCODET
4470: 59 50 45 29 79 79 4d 61 6a 6f 72 3b 0a 20 20 79 YPE)yyMajor;. y
4480: 79 74 6f 73 2d 3e 6d 69 6e 6f 72 20 3d 20 2a 79 ytos->minor = *y
4490: 79 70 4d 69 6e 6f 72 3b 0a 23 69 66 6e 64 65 66 ypMinor;.#ifndef
44a0: 20 4e 44 45 42 55 47 0a 20 20 69 66 28 20 79 79 NDEBUG. if( yy
44b0: 54 72 61 63 65 46 49 4c 45 20 26 26 20 79 79 70 TraceFILE && yyp
44c0: 50 61 72 73 65 72 2d 3e 79 79 69 64 78 3e 30 20 Parser->yyidx>0
44d0: 29 7b 0a 20 20 20 20 69 6e 74 20 69 3b 0a 20 20 ){. int i;.
44e0: 20 20 66 70 72 69 6e 74 66 28 79 79 54 72 61 63 fprintf(yyTrac
44f0: 65 46 49 4c 45 2c 22 25 73 53 68 69 66 74 20 25 eFILE,"%sShift %
4500: 64 5c 6e 22 2c 79 79 54 72 61 63 65 50 72 6f 6d d\n",yyTraceProm
4510: 70 74 2c 79 79 4e 65 77 53 74 61 74 65 29 3b 0a pt,yyNewState);.
4520: 20 20 20 20 66 70 72 69 6e 74 66 28 79 79 54 72 fprintf(yyTr
4530: 61 63 65 46 49 4c 45 2c 22 25 73 53 74 61 63 6b aceFILE,"%sStack
4540: 3a 22 2c 79 79 54 72 61 63 65 50 72 6f 6d 70 74 :",yyTracePrompt
4550: 29 3b 0a 20 20 20 20 66 6f 72 28 69 3d 31 3b 20 );. for(i=1;
4560: 69 3c 3d 79 79 70 50 61 72 73 65 72 2d 3e 79 79 i<=yypParser->yy
4570: 69 64 78 3b 20 69 2b 2b 29 0a 20 20 20 20 20 20 idx; i++).
4580: 66 70 72 69 6e 74 66 28 79 79 54 72 61 63 65 46 fprintf(yyTraceF
4590: 49 4c 45 2c 22 20 25 73 22 2c 79 79 54 6f 6b 65 ILE," %s",yyToke
45a0: 6e 4e 61 6d 65 5b 79 79 70 50 61 72 73 65 72 2d nName[yypParser-
45b0: 3e 79 79 73 74 61 63 6b 5b 69 5d 2e 6d 61 6a 6f >yystack[i].majo
45c0: 72 5d 29 3b 0a 20 20 20 20 66 70 72 69 6e 74 66 r]);. fprintf
45d0: 28 79 79 54 72 61 63 65 46 49 4c 45 2c 22 5c 6e (yyTraceFILE,"\n
45e0: 22 29 3b 0a 20 20 7d 0a 23 65 6e 64 69 66 0a 7d ");. }.#endif.}
45f0: 0a 0a 2f 2a 20 54 68 65 20 66 6f 6c 6c 6f 77 69 ../* The followi
4600: 6e 67 20 74 61 62 6c 65 20 63 6f 6e 74 61 69 6e ng table contain
4610: 73 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 s information ab
4620: 6f 75 74 20 65 76 65 72 79 20 72 75 6c 65 20 74 out every rule t
4630: 68 61 74 0a 2a 2a 20 69 73 20 75 73 65 64 20 64 hat.** is used d
4640: 75 72 69 6e 67 20 74 68 65 20 72 65 64 75 63 65 uring the reduce
4650: 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 63 6f 6e 73 ..*/.static cons
4660: 74 20 73 74 72 75 63 74 20 7b 0a 20 20 59 59 43 t struct {. YYC
4670: 4f 44 45 54 59 50 45 20 6c 68 73 3b 20 20 20 20 ODETYPE lhs;
4680: 20 20 20 20 20 2f 2a 20 53 79 6d 62 6f 6c 20 6f /* Symbol o
4690: 6e 20 74 68 65 20 6c 65 66 74 2d 68 61 6e 64 20 n the left-hand
46a0: 73 69 64 65 20 6f 66 20 74 68 65 20 72 75 6c 65 side of the rule
46b0: 20 2a 2f 0a 20 20 75 6e 73 69 67 6e 65 64 20 63 */. unsigned c
46c0: 68 61 72 20 6e 72 68 73 3b 20 20 20 20 20 2f 2a har nrhs; /*
46d0: 20 4e 75 6d 62 65 72 20 6f 66 20 72 69 67 68 74 Number of right
46e0: 2d 68 61 6e 64 20 73 69 64 65 20 73 79 6d 62 6f -hand side symbo
46f0: 6c 73 20 69 6e 20 74 68 65 20 72 75 6c 65 20 2a ls in the rule *
4700: 2f 0a 7d 20 79 79 52 75 6c 65 49 6e 66 6f 5b 5d /.} yyRuleInfo[]
4710: 20 3d 20 7b 0a 25 25 0a 7d 3b 0a 0a 73 74 61 74 = {.%%.};..stat
4720: 69 63 20 76 6f 69 64 20 79 79 5f 61 63 63 65 70 ic void yy_accep
4730: 74 28 79 79 50 61 72 73 65 72 2a 29 3b 20 20 2f t(yyParser*); /
4740: 2a 20 46 6f 72 77 61 72 64 20 44 65 63 6c 61 72 * Forward Declar
4750: 61 74 69 6f 6e 20 2a 2f 0a 0a 2f 2a 0a 2a 2a 20 ation */../*.**
4760: 50 65 72 66 6f 72 6d 20 61 20 72 65 64 75 63 65 Perform a reduce
4770: 20 61 63 74 69 6f 6e 20 61 6e 64 20 74 68 65 20 action and the
4780: 73 68 69 66 74 20 74 68 61 74 20 6d 75 73 74 20 shift that must
4790: 69 6d 6d 65 64 69 61 74 65 6c 79 0a 2a 2a 20 66 immediately.** f
47a0: 6f 6c 6c 6f 77 20 74 68 65 20 72 65 64 75 63 65 ollow the reduce
47b0: 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 64 ..*/.static void
47c0: 20 79 79 5f 72 65 64 75 63 65 28 0a 20 20 79 79 yy_reduce(. yy
47d0: 50 61 72 73 65 72 20 2a 79 79 70 50 61 72 73 65 Parser *yypParse
47e0: 72 2c 20 20 20 20 20 20 20 20 20 2f 2a 20 54 68 r, /* Th
47f0: 65 20 70 61 72 73 65 72 20 2a 2f 0a 20 20 69 6e e parser */. in
4800: 74 20 79 79 72 75 6c 65 6e 6f 20 20 20 20 20 20 t yyruleno
4810: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 75 /* Nu
4820: 6d 62 65 72 20 6f 66 20 74 68 65 20 72 75 6c 65 mber of the rule
4830: 20 62 79 20 77 68 69 63 68 20 74 6f 20 72 65 64 by which to red
4840: 75 63 65 20 2a 2f 0a 29 7b 0a 20 20 69 6e 74 20 uce */.){. int
4850: 79 79 67 6f 74 6f 3b 20 20 20 20 20 20 20 20 20 yygoto;
4860: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 54 /* T
4870: 68 65 20 6e 65 78 74 20 73 74 61 74 65 20 2a 2f he next state */
4880: 0a 20 20 69 6e 74 20 79 79 61 63 74 3b 20 20 20 . int yyact;
4890: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
48a0: 20 20 20 2f 2a 20 54 68 65 20 6e 65 78 74 20 61 /* The next a
48b0: 63 74 69 6f 6e 20 2a 2f 0a 20 20 59 59 4d 49 4e ction */. YYMIN
48c0: 4f 52 54 59 50 45 20 79 79 67 6f 74 6f 6d 69 6e ORTYPE yygotomin
48d0: 6f 72 3b 20 20 20 20 20 20 20 20 2f 2a 20 54 68 or; /* Th
48e0: 65 20 4c 48 53 20 6f 66 20 74 68 65 20 72 75 6c e LHS of the rul
48f0: 65 20 72 65 64 75 63 65 64 20 2a 2f 0a 20 20 79 e reduced */. y
4900: 79 53 74 61 63 6b 45 6e 74 72 79 20 2a 79 79 6d yStackEntry *yym
4910: 73 70 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f sp; /
4920: 2a 20 54 68 65 20 74 6f 70 20 6f 66 20 74 68 65 * The top of the
4930: 20 70 61 72 73 65 72 27 73 20 73 74 61 63 6b 20 parser's stack
4940: 2a 2f 0a 20 20 69 6e 74 20 79 79 73 69 7a 65 3b */. int yysize;
4950: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4960: 20 20 20 20 20 2f 2a 20 41 6d 6f 75 6e 74 20 74 /* Amount t
4970: 6f 20 70 6f 70 20 74 68 65 20 73 74 61 63 6b 20 o pop the stack
4980: 2a 2f 0a 20 20 50 61 72 73 65 41 52 47 5f 46 45 */. ParseARG_FE
4990: 54 43 48 3b 0a 20 20 79 79 6d 73 70 20 3d 20 26 TCH;. yymsp = &
49a0: 79 79 70 50 61 72 73 65 72 2d 3e 79 79 73 74 61 yypParser->yysta
49b0: 63 6b 5b 79 79 70 50 61 72 73 65 72 2d 3e 79 79 ck[yypParser->yy
49c0: 69 64 78 5d 3b 0a 23 69 66 6e 64 65 66 20 4e 44 idx];.#ifndef ND
49d0: 45 42 55 47 0a 20 20 69 66 28 20 79 79 54 72 61 EBUG. if( yyTra
49e0: 63 65 46 49 4c 45 20 26 26 20 79 79 72 75 6c 65 ceFILE && yyrule
49f0: 6e 6f 3e 3d 30 20 0a 20 20 20 20 20 20 20 20 26 no>=0 . &
4a00: 26 20 79 79 72 75 6c 65 6e 6f 3c 28 69 6e 74 29 & yyruleno<(int)
4a10: 28 73 69 7a 65 6f 66 28 79 79 52 75 6c 65 4e 61 (sizeof(yyRuleNa
4a20: 6d 65 29 2f 73 69 7a 65 6f 66 28 79 79 52 75 6c me)/sizeof(yyRul
4a30: 65 4e 61 6d 65 5b 30 5d 29 29 20 29 7b 0a 20 20 eName[0])) ){.
4a40: 20 20 66 70 72 69 6e 74 66 28 79 79 54 72 61 63 fprintf(yyTrac
4a50: 65 46 49 4c 45 2c 20 22 25 73 52 65 64 75 63 65 eFILE, "%sReduce
4a60: 20 5b 25 73 5d 2e 5c 6e 22 2c 20 79 79 54 72 61 [%s].\n", yyTra
4a70: 63 65 50 72 6f 6d 70 74 2c 0a 20 20 20 20 20 20 cePrompt,.
4a80: 79 79 52 75 6c 65 4e 61 6d 65 5b 79 79 72 75 6c yyRuleName[yyrul
4a90: 65 6e 6f 5d 29 3b 0a 20 20 7d 0a 23 65 6e 64 69 eno]);. }.#endi
4aa0: 66 20 2f 2a 20 4e 44 45 42 55 47 20 2a 2f 0a 0a f /* NDEBUG */..
4ab0: 20 20 2f 2a 20 53 69 6c 65 6e 63 65 20 63 6f 6d /* Silence com
4ac0: 70 6c 61 69 6e 74 73 20 66 72 6f 6d 20 70 75 72 plaints from pur
4ad0: 69 66 79 20 61 62 6f 75 74 20 79 79 67 6f 74 6f ify about yygoto
4ae0: 6d 69 6e 6f 72 20 62 65 69 6e 67 20 75 6e 69 6e minor being unin
4af0: 69 74 69 61 6c 69 7a 65 64 0a 20 20 2a 2a 20 69 itialized. ** i
4b00: 6e 20 73 6f 6d 65 20 63 61 73 65 73 20 77 68 65 n some cases whe
4b10: 6e 20 69 74 20 69 73 20 63 6f 70 69 65 64 20 69 n it is copied i
4b20: 6e 74 6f 20 74 68 65 20 73 74 61 63 6b 20 61 66 nto the stack af
4b30: 74 65 72 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e ter the followin
4b40: 67 0a 20 20 2a 2a 20 73 77 69 74 63 68 2e 20 20 g. ** switch.
4b50: 79 79 67 6f 74 6f 6d 69 6e 6f 72 20 69 73 20 75 yygotominor is u
4b60: 6e 69 6e 69 74 69 61 6c 69 7a 65 64 20 77 68 65 ninitialized whe
4b70: 6e 20 61 20 72 75 6c 65 20 72 65 64 75 63 65 73 n a rule reduces
4b80: 20 74 68 61 74 20 64 6f 65 73 0a 20 20 2a 2a 20 that does. **
4b90: 6e 6f 74 20 73 65 74 20 74 68 65 20 76 61 6c 75 not set the valu
4ba0: 65 20 6f 66 20 69 74 73 20 6c 65 66 74 2d 68 61 e of its left-ha
4bb0: 6e 64 20 73 69 64 65 20 6e 6f 6e 74 65 72 6d 69 nd side nontermi
4bc0: 6e 61 6c 2e 20 20 4c 65 61 76 69 6e 67 20 74 68 nal. Leaving th
4bd0: 65 0a 20 20 2a 2a 20 76 61 6c 75 65 20 6f 66 20 e. ** value of
4be0: 74 68 65 20 6e 6f 6e 74 65 72 6d 69 6e 61 6c 20 the nonterminal
4bf0: 75 6e 69 6e 69 74 69 61 6c 69 7a 65 64 20 69 73 uninitialized is
4c00: 20 75 74 74 65 72 6c 79 20 68 61 72 6d 6c 65 73 utterly harmles
4c10: 73 20 61 73 20 6c 6f 6e 67 0a 20 20 2a 2a 20 61 s as long. ** a
4c20: 73 20 74 68 65 20 76 61 6c 75 65 20 69 73 20 6e s the value is n
4c30: 65 76 65 72 20 75 73 65 64 2e 20 20 53 6f 20 72 ever used. So r
4c40: 65 61 6c 6c 79 20 74 68 65 20 6f 6e 6c 79 20 74 eally the only t
4c50: 68 69 6e 67 20 74 68 69 73 20 63 6f 64 65 0a 20 hing this code.
4c60: 20 2a 2a 20 61 63 63 6f 6d 70 6c 69 73 68 65 73 ** accomplishes
4c70: 20 69 73 20 74 6f 20 71 75 69 65 74 65 6e 20 70 is to quieten p
4c80: 75 72 69 66 79 2e 20 20 0a 20 20 2a 2a 0a 20 20 urify. . **.
4c90: 2a 2a 20 32 30 30 37 2d 30 31 2d 31 36 3a 20 20 ** 2007-01-16:
4ca0: 54 68 65 20 77 69 72 65 73 68 61 72 6b 20 70 72 The wireshark pr
4cb0: 6f 6a 65 63 74 20 28 77 77 77 2e 77 69 72 65 73 oject (www.wires
4cc0: 68 61 72 6b 2e 6f 72 67 29 20 72 65 70 6f 72 74 hark.org) report
4cd0: 73 20 74 68 61 74 0a 20 20 2a 2a 20 77 69 74 68 s that. ** with
4ce0: 6f 75 74 20 74 68 69 73 20 63 6f 64 65 2c 20 74 out this code, t
4cf0: 68 65 69 72 20 70 61 72 73 65 72 20 73 65 67 66 heir parser segf
4d00: 61 75 6c 74 73 2e 20 20 49 27 6d 20 6e 6f 74 20 aults. I'm not
4d10: 73 75 72 65 20 77 68 61 74 20 74 68 65 72 65 0a sure what there.
4d20: 20 20 2a 2a 20 70 61 72 73 65 72 20 69 73 20 64 ** parser is d
4d30: 6f 69 6e 67 20 74 6f 20 6d 61 6b 65 20 74 68 69 oing to make thi
4d40: 73 20 68 61 70 70 65 6e 2e 20 20 54 68 69 73 20 s happen. This
4d50: 69 73 20 74 68 65 20 73 65 63 6f 6e 64 20 62 75 is the second bu
4d60: 67 20 72 65 70 6f 72 74 0a 20 20 2a 2a 20 66 72 g report. ** fr
4d70: 6f 6d 20 77 69 72 65 73 68 61 72 6b 20 74 68 69 om wireshark thi
4d80: 73 20 77 65 65 6b 2e 20 20 43 6c 65 61 72 6c 79 s week. Clearly
4d90: 20 74 68 65 79 20 61 72 65 20 73 74 72 65 73 73 they are stress
4da0: 69 6e 67 20 4c 65 6d 6f 6e 20 69 6e 20 77 61 79 ing Lemon in way
4db0: 73 0a 20 20 2a 2a 20 74 68 61 74 20 69 74 20 68 s. ** that it h
4dc0: 61 73 20 6e 6f 74 20 62 65 65 6e 20 70 72 65 76 as not been prev
4dd0: 69 6f 75 73 6c 79 20 73 74 72 65 73 73 65 64 2e iously stressed.
4de0: 2e 2e 20 20 28 53 51 4c 69 74 65 20 74 69 63 6b .. (SQLite tick
4df0: 65 74 20 23 32 31 37 32 29 0a 20 20 2a 2f 0a 20 et #2172). */.
4e00: 20 2f 2a 6d 65 6d 73 65 74 28 26 79 79 67 6f 74 /*memset(&yygot
4e10: 6f 6d 69 6e 6f 72 2c 20 30 2c 20 73 69 7a 65 6f ominor, 0, sizeo
4e20: 66 28 79 79 67 6f 74 6f 6d 69 6e 6f 72 29 29 3b f(yygotominor));
4e30: 2a 2f 0a 20 20 79 79 67 6f 74 6f 6d 69 6e 6f 72 */. yygotominor
4e40: 20 3d 20 79 79 7a 65 72 6f 6d 69 6e 6f 72 3b 0a = yyzerominor;.
4e50: 0a 0a 20 20 73 77 69 74 63 68 28 20 79 79 72 75 .. switch( yyru
4e60: 6c 65 6e 6f 20 29 7b 0a 20 20 2f 2a 20 42 65 67 leno ){. /* Beg
4e70: 69 6e 6e 69 6e 67 20 68 65 72 65 20 61 72 65 20 inning here are
4e80: 74 68 65 20 72 65 64 75 63 74 69 6f 6e 20 63 61 the reduction ca
4e90: 73 65 73 2e 20 20 41 20 74 79 70 69 63 61 6c 20 ses. A typical
4ea0: 65 78 61 6d 70 6c 65 0a 20 20 2a 2a 20 66 6f 6c example. ** fol
4eb0: 6c 6f 77 73 3a 0a 20 20 2a 2a 20 20 20 63 61 73 lows:. ** cas
4ec0: 65 20 30 3a 0a 20 20 2a 2a 20 20 23 6c 69 6e 65 e 0:. ** #line
4ed0: 20 3c 6c 69 6e 65 6e 6f 3e 20 3c 67 72 61 6d 6d <lineno> <gramm
4ee0: 61 72 66 69 6c 65 3e 0a 20 20 2a 2a 20 20 20 20 arfile>. **
4ef0: 20 7b 20 2e 2e 2e 20 7d 20 20 20 20 20 20 20 20 { ... }
4f00: 20 20 20 2f 2f 20 55 73 65 72 20 73 75 70 70 6c // User suppl
4f10: 69 65 64 20 63 6f 64 65 0a 20 20 2a 2a 20 20 23 ied code. ** #
4f20: 6c 69 6e 65 20 3c 6c 69 6e 65 6e 6f 3e 20 3c 74 line <lineno> <t
4f30: 68 69 73 66 69 6c 65 3e 0a 20 20 2a 2a 20 20 20 hisfile>. **
4f40: 20 20 62 72 65 61 6b 3b 0a 20 20 2a 2f 0a 25 25 break;. */.%%
4f50: 0a 20 20 7d 3b 0a 20 20 61 73 73 65 72 74 28 20 . };. assert(
4f60: 79 79 72 75 6c 65 6e 6f 3e 3d 30 20 26 26 20 79 yyruleno>=0 && y
4f70: 79 72 75 6c 65 6e 6f 3c 73 69 7a 65 6f 66 28 79 yruleno<sizeof(y
4f80: 79 52 75 6c 65 49 6e 66 6f 29 2f 73 69 7a 65 6f yRuleInfo)/sizeo
4f90: 66 28 79 79 52 75 6c 65 49 6e 66 6f 5b 30 5d 29 f(yyRuleInfo[0])
4fa0: 20 29 3b 0a 20 20 79 79 67 6f 74 6f 20 3d 20 79 );. yygoto = y
4fb0: 79 52 75 6c 65 49 6e 66 6f 5b 79 79 72 75 6c 65 yRuleInfo[yyrule
4fc0: 6e 6f 5d 2e 6c 68 73 3b 0a 20 20 79 79 73 69 7a no].lhs;. yysiz
4fd0: 65 20 3d 20 79 79 52 75 6c 65 49 6e 66 6f 5b 79 e = yyRuleInfo[y
4fe0: 79 72 75 6c 65 6e 6f 5d 2e 6e 72 68 73 3b 0a 20 yruleno].nrhs;.
4ff0: 20 79 79 70 50 61 72 73 65 72 2d 3e 79 79 69 64 yypParser->yyid
5000: 78 20 2d 3d 20 79 79 73 69 7a 65 3b 0a 20 20 79 x -= yysize;. y
5010: 79 61 63 74 20 3d 20 79 79 5f 66 69 6e 64 5f 72 yact = yy_find_r
5020: 65 64 75 63 65 5f 61 63 74 69 6f 6e 28 79 79 6d educe_action(yym
5030: 73 70 5b 2d 79 79 73 69 7a 65 5d 2e 73 74 61 74 sp[-yysize].stat
5040: 65 6e 6f 2c 28 59 59 43 4f 44 45 54 59 50 45 29 eno,(YYCODETYPE)
5050: 79 79 67 6f 74 6f 29 3b 0a 20 20 69 66 28 20 79 yygoto);. if( y
5060: 79 61 63 74 20 3c 20 59 59 4e 53 54 41 54 45 20 yact < YYNSTATE
5070: 29 7b 0a 23 69 66 64 65 66 20 4e 44 45 42 55 47 ){.#ifdef NDEBUG
5080: 0a 20 20 20 20 2f 2a 20 49 66 20 77 65 20 61 72 . /* If we ar
5090: 65 20 6e 6f 74 20 64 65 62 75 67 67 69 6e 67 20 e not debugging
50a0: 61 6e 64 20 74 68 65 20 72 65 64 75 63 65 20 61 and the reduce a
50b0: 63 74 69 6f 6e 20 70 6f 70 70 65 64 20 61 74 20 ction popped at
50c0: 6c 65 61 73 74 0a 20 20 20 20 2a 2a 20 6f 6e 65 least. ** one
50d0: 20 65 6c 65 6d 65 6e 74 20 6f 66 66 20 74 68 65 element off the
50e0: 20 73 74 61 63 6b 2c 20 74 68 65 6e 20 77 65 20 stack, then we
50f0: 63 61 6e 20 70 75 73 68 20 74 68 65 20 6e 65 77 can push the new
5100: 20 65 6c 65 6d 65 6e 74 20 62 61 63 6b 0a 20 20 element back.
5110: 20 20 2a 2a 20 6f 6e 74 6f 20 74 68 65 20 73 74 ** onto the st
5120: 61 63 6b 20 68 65 72 65 2c 20 61 6e 64 20 73 6b ack here, and sk
5130: 69 70 20 74 68 65 20 73 74 61 63 6b 20 6f 76 65 ip the stack ove
5140: 72 66 6c 6f 77 20 74 65 73 74 20 69 6e 20 79 79 rflow test in yy
5150: 5f 73 68 69 66 74 28 29 2e 0a 20 20 20 20 2a 2a _shift().. **
5160: 20 54 68 61 74 20 67 69 76 65 73 20 61 20 73 69 That gives a si
5170: 67 6e 69 66 69 63 61 6e 74 20 73 70 65 65 64 20 gnificant speed
5180: 69 6d 70 72 6f 76 65 6d 65 6e 74 2e 20 2a 2f 0a improvement. */.
5190: 20 20 20 20 69 66 28 20 79 79 73 69 7a 65 20 29 if( yysize )
51a0: 7b 0a 20 20 20 20 20 20 79 79 70 50 61 72 73 65 {. yypParse
51b0: 72 2d 3e 79 79 69 64 78 2b 2b 3b 0a 20 20 20 20 r->yyidx++;.
51c0: 20 20 79 79 6d 73 70 20 2d 3d 20 79 79 73 69 7a yymsp -= yysiz
51d0: 65 2d 31 3b 0a 20 20 20 20 20 20 79 79 6d 73 70 e-1;. yymsp
51e0: 2d 3e 73 74 61 74 65 6e 6f 20 3d 20 28 59 59 41 ->stateno = (YYA
51f0: 43 54 49 4f 4e 54 59 50 45 29 79 79 61 63 74 3b CTIONTYPE)yyact;
5200: 0a 20 20 20 20 20 20 79 79 6d 73 70 2d 3e 6d 61 . yymsp->ma
5210: 6a 6f 72 20 3d 20 28 59 59 43 4f 44 45 54 59 50 jor = (YYCODETYP
5220: 45 29 79 79 67 6f 74 6f 3b 0a 20 20 20 20 20 20 E)yygoto;.
5230: 79 79 6d 73 70 2d 3e 6d 69 6e 6f 72 20 3d 20 79 yymsp->minor = y
5240: 79 67 6f 74 6f 6d 69 6e 6f 72 3b 0a 20 20 20 20 ygotominor;.
5250: 7d 65 6c 73 65 0a 23 65 6e 64 69 66 0a 20 20 20 }else.#endif.
5260: 20 7b 0a 20 20 20 20 20 20 79 79 5f 73 68 69 66 {. yy_shif
5270: 74 28 79 79 70 50 61 72 73 65 72 2c 79 79 61 63 t(yypParser,yyac
5280: 74 2c 79 79 67 6f 74 6f 2c 26 79 79 67 6f 74 6f t,yygoto,&yygoto
5290: 6d 69 6e 6f 72 29 3b 0a 20 20 20 20 7d 0a 20 20 minor);. }.
52a0: 7d 65 6c 73 65 7b 0a 20 20 20 20 61 73 73 65 72 }else{. asser
52b0: 74 28 20 79 79 61 63 74 20 3d 3d 20 59 59 4e 53 t( yyact == YYNS
52c0: 54 41 54 45 20 2b 20 59 59 4e 52 55 4c 45 20 2b TATE + YYNRULE +
52d0: 20 31 20 29 3b 0a 20 20 20 20 79 79 5f 61 63 63 1 );. yy_acc
52e0: 65 70 74 28 79 79 70 50 61 72 73 65 72 29 3b 0a ept(yypParser);.
52f0: 20 20 7d 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 }.}../*.** The
5300: 20 66 6f 6c 6c 6f 77 69 6e 67 20 63 6f 64 65 20 following code
5310: 65 78 65 63 75 74 65 73 20 77 68 65 6e 20 74 68 executes when th
5320: 65 20 70 61 72 73 65 20 66 61 69 6c 73 0a 2a 2f e parse fails.*/
5330: 0a 23 69 66 6e 64 65 66 20 59 59 4e 4f 45 52 52 .#ifndef YYNOERR
5340: 4f 52 52 45 43 4f 56 45 52 59 0a 73 74 61 74 69 ORRECOVERY.stati
5350: 63 20 76 6f 69 64 20 79 79 5f 70 61 72 73 65 5f c void yy_parse_
5360: 66 61 69 6c 65 64 28 0a 20 20 79 79 50 61 72 73 failed(. yyPars
5370: 65 72 20 2a 79 79 70 50 61 72 73 65 72 20 20 20 er *yypParser
5380: 20 20 20 20 20 20 20 20 2f 2a 20 54 68 65 20 70 /* The p
5390: 61 72 73 65 72 20 2a 2f 0a 29 7b 0a 20 20 50 61 arser */.){. Pa
53a0: 72 73 65 41 52 47 5f 46 45 54 43 48 3b 0a 23 69 rseARG_FETCH;.#i
53b0: 66 6e 64 65 66 20 4e 44 45 42 55 47 0a 20 20 69 fndef NDEBUG. i
53c0: 66 28 20 79 79 54 72 61 63 65 46 49 4c 45 20 29 f( yyTraceFILE )
53d0: 7b 0a 20 20 20 20 66 70 72 69 6e 74 66 28 79 79 {. fprintf(yy
53e0: 54 72 61 63 65 46 49 4c 45 2c 22 25 73 46 61 69 TraceFILE,"%sFai
53f0: 6c 21 5c 6e 22 2c 79 79 54 72 61 63 65 50 72 6f l!\n",yyTracePro
5400: 6d 70 74 29 3b 0a 20 20 7d 0a 23 65 6e 64 69 66 mpt);. }.#endif
5410: 0a 20 20 77 68 69 6c 65 28 20 79 79 70 50 61 72 . while( yypPar
5420: 73 65 72 2d 3e 79 79 69 64 78 3e 3d 30 20 29 20 ser->yyidx>=0 )
5430: 79 79 5f 70 6f 70 5f 70 61 72 73 65 72 5f 73 74 yy_pop_parser_st
5440: 61 63 6b 28 79 79 70 50 61 72 73 65 72 29 3b 0a ack(yypParser);.
5450: 20 20 2f 2a 20 48 65 72 65 20 63 6f 64 65 20 69 /* Here code i
5460: 73 20 69 6e 73 65 72 74 65 64 20 77 68 69 63 68 s inserted which
5470: 20 77 69 6c 6c 20 62 65 20 65 78 65 63 75 74 65 will be execute
5480: 64 20 77 68 65 6e 65 76 65 72 20 74 68 65 0a 20 d whenever the.
5490: 20 2a 2a 20 70 61 72 73 65 72 20 66 61 69 6c 73 ** parser fails
54a0: 20 2a 2f 0a 25 25 0a 20 20 50 61 72 73 65 41 52 */.%%. ParseAR
54b0: 47 5f 53 54 4f 52 45 3b 20 2f 2a 20 53 75 70 70 G_STORE; /* Supp
54c0: 72 65 73 73 20 77 61 72 6e 69 6e 67 20 61 62 6f ress warning abo
54d0: 75 74 20 75 6e 75 73 65 64 20 25 65 78 74 72 61 ut unused %extra
54e0: 5f 61 72 67 75 6d 65 6e 74 20 76 61 72 69 61 62 _argument variab
54f0: 6c 65 20 2a 2f 0a 7d 0a 23 65 6e 64 69 66 20 2f le */.}.#endif /
5500: 2a 20 59 59 4e 4f 45 52 52 4f 52 52 45 43 4f 56 * YYNOERRORRECOV
5510: 45 52 59 20 2a 2f 0a 0a 2f 2a 0a 2a 2a 20 54 68 ERY */../*.** Th
5520: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 63 6f 64 65 e following code
5530: 20 65 78 65 63 75 74 65 73 20 77 68 65 6e 20 61 executes when a
5540: 20 73 79 6e 74 61 78 20 65 72 72 6f 72 20 66 69 syntax error fi
5550: 72 73 74 20 6f 63 63 75 72 73 2e 0a 2a 2f 0a 73 rst occurs..*/.s
5560: 74 61 74 69 63 20 76 6f 69 64 20 79 79 5f 73 79 tatic void yy_sy
5570: 6e 74 61 78 5f 65 72 72 6f 72 28 0a 20 20 79 79 ntax_error(. yy
5580: 50 61 72 73 65 72 20 2a 79 79 70 50 61 72 73 65 Parser *yypParse
5590: 72 2c 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 r, /*
55a0: 54 68 65 20 70 61 72 73 65 72 20 2a 2f 0a 20 20 The parser */.
55b0: 69 6e 74 20 79 79 6d 61 6a 6f 72 2c 20 20 20 20 int yymajor,
55c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
55d0: 2a 20 54 68 65 20 6d 61 6a 6f 72 20 74 79 70 65 * The major type
55e0: 20 6f 66 20 74 68 65 20 65 72 72 6f 72 20 74 6f of the error to
55f0: 6b 65 6e 20 2a 2f 0a 20 20 59 59 4d 49 4e 4f 52 ken */. YYMINOR
5600: 54 59 50 45 20 79 79 6d 69 6e 6f 72 20 20 20 20 TYPE yyminor
5610: 20 20 20 20 20 20 20 20 2f 2a 20 54 68 65 20 6d /* The m
5620: 69 6e 6f 72 20 74 79 70 65 20 6f 66 20 74 68 65 inor type of the
5630: 20 65 72 72 6f 72 20 74 6f 6b 65 6e 20 2a 2f 0a error token */.
5640: 29 7b 0a 20 20 50 61 72 73 65 41 52 47 5f 46 45 ){. ParseARG_FE
5650: 54 43 48 3b 0a 23 64 65 66 69 6e 65 20 54 4f 4b TCH;.#define TOK
5660: 45 4e 20 28 79 79 6d 69 6e 6f 72 2e 79 79 30 29 EN (yyminor.yy0)
5670: 0a 25 25 0a 20 20 50 61 72 73 65 41 52 47 5f 53 .%%. ParseARG_S
5680: 54 4f 52 45 3b 20 2f 2a 20 53 75 70 70 72 65 73 TORE; /* Suppres
5690: 73 20 77 61 72 6e 69 6e 67 20 61 62 6f 75 74 20 s warning about
56a0: 75 6e 75 73 65 64 20 25 65 78 74 72 61 5f 61 72 unused %extra_ar
56b0: 67 75 6d 65 6e 74 20 76 61 72 69 61 62 6c 65 20 gument variable
56c0: 2a 2f 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20 */.}../*.** The
56d0: 66 6f 6c 6c 6f 77 69 6e 67 20 69 73 20 65 78 65 following is exe
56e0: 63 75 74 65 64 20 77 68 65 6e 20 74 68 65 20 70 cuted when the p
56f0: 61 72 73 65 72 20 61 63 63 65 70 74 73 0a 2a 2f arser accepts.*/
5700: 0a 73 74 61 74 69 63 20 76 6f 69 64 20 79 79 5f .static void yy_
5710: 61 63 63 65 70 74 28 0a 20 20 79 79 50 61 72 73 accept(. yyPars
5720: 65 72 20 2a 79 79 70 50 61 72 73 65 72 20 20 20 er *yypParser
5730: 20 20 20 20 20 20 20 20 2f 2a 20 54 68 65 20 70 /* The p
5740: 61 72 73 65 72 20 2a 2f 0a 29 7b 0a 20 20 50 61 arser */.){. Pa
5750: 72 73 65 41 52 47 5f 46 45 54 43 48 3b 0a 23 69 rseARG_FETCH;.#i
5760: 66 6e 64 65 66 20 4e 44 45 42 55 47 0a 20 20 69 fndef NDEBUG. i
5770: 66 28 20 79 79 54 72 61 63 65 46 49 4c 45 20 29 f( yyTraceFILE )
5780: 7b 0a 20 20 20 20 66 70 72 69 6e 74 66 28 79 79 {. fprintf(yy
5790: 54 72 61 63 65 46 49 4c 45 2c 22 25 73 41 63 63 TraceFILE,"%sAcc
57a0: 65 70 74 21 5c 6e 22 2c 79 79 54 72 61 63 65 50 ept!\n",yyTraceP
57b0: 72 6f 6d 70 74 29 3b 0a 20 20 7d 0a 23 65 6e 64 rompt);. }.#end
57c0: 69 66 0a 20 20 77 68 69 6c 65 28 20 79 79 70 50 if. while( yypP
57d0: 61 72 73 65 72 2d 3e 79 79 69 64 78 3e 3d 30 20 arser->yyidx>=0
57e0: 29 20 79 79 5f 70 6f 70 5f 70 61 72 73 65 72 5f ) yy_pop_parser_
57f0: 73 74 61 63 6b 28 79 79 70 50 61 72 73 65 72 29 stack(yypParser)
5800: 3b 0a 20 20 2f 2a 20 48 65 72 65 20 63 6f 64 65 ;. /* Here code
5810: 20 69 73 20 69 6e 73 65 72 74 65 64 20 77 68 69 is inserted whi
5820: 63 68 20 77 69 6c 6c 20 62 65 20 65 78 65 63 75 ch will be execu
5830: 74 65 64 20 77 68 65 6e 65 76 65 72 20 74 68 65 ted whenever the
5840: 0a 20 20 2a 2a 20 70 61 72 73 65 72 20 61 63 63 . ** parser acc
5850: 65 70 74 73 20 2a 2f 0a 25 25 0a 20 20 50 61 72 epts */.%%. Par
5860: 73 65 41 52 47 5f 53 54 4f 52 45 3b 20 2f 2a 20 seARG_STORE; /*
5870: 53 75 70 70 72 65 73 73 20 77 61 72 6e 69 6e 67 Suppress warning
5880: 20 61 62 6f 75 74 20 75 6e 75 73 65 64 20 25 65 about unused %e
5890: 78 74 72 61 5f 61 72 67 75 6d 65 6e 74 20 76 61 xtra_argument va
58a0: 72 69 61 62 6c 65 20 2a 2f 0a 7d 0a 0a 2f 2a 20 riable */.}../*
58b0: 54 68 65 20 6d 61 69 6e 20 70 61 72 73 65 72 20 The main parser
58c0: 70 72 6f 67 72 61 6d 2e 0a 2a 2a 20 54 68 65 20 program..** The
58d0: 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 69 first argument i
58e0: 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 s a pointer to a
58f0: 20 73 74 72 75 63 74 75 72 65 20 6f 62 74 61 69 structure obtai
5900: 6e 65 64 20 66 72 6f 6d 0a 2a 2a 20 22 50 61 72 ned from.** "Par
5910: 73 65 41 6c 6c 6f 63 22 20 77 68 69 63 68 20 64 seAlloc" which d
5920: 65 73 63 72 69 62 65 73 20 74 68 65 20 63 75 72 escribes the cur
5930: 72 65 6e 74 20 73 74 61 74 65 20 6f 66 20 74 68 rent state of th
5940: 65 20 70 61 72 73 65 72 2e 0a 2a 2a 20 54 68 65 e parser..** The
5950: 20 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e 74 second argument
5960: 20 69 73 20 74 68 65 20 6d 61 6a 6f 72 20 74 6f is the major to
5970: 6b 65 6e 20 6e 75 6d 62 65 72 2e 20 20 54 68 65 ken number. The
5980: 20 74 68 69 72 64 20 69 73 0a 2a 2a 20 74 68 65 third is.** the
5990: 20 6d 69 6e 6f 72 20 74 6f 6b 65 6e 2e 20 20 54 minor token. T
59a0: 68 65 20 66 6f 75 72 74 68 20 6f 70 74 69 6f 6e he fourth option
59b0: 61 6c 20 61 72 67 75 6d 65 6e 74 20 69 73 20 77 al argument is w
59c0: 68 61 74 65 76 65 72 20 74 68 65 0a 2a 2a 20 75 hatever the.** u
59d0: 73 65 72 20 77 61 6e 74 73 20 28 61 6e 64 20 73 ser wants (and s
59e0: 70 65 63 69 66 69 65 64 20 69 6e 20 74 68 65 20 pecified in the
59f0: 67 72 61 6d 6d 61 72 29 20 61 6e 64 20 69 73 20 grammar) and is
5a00: 61 76 61 69 6c 61 62 6c 65 20 66 6f 72 0a 2a 2a available for.**
5a10: 20 75 73 65 20 62 79 20 74 68 65 20 61 63 74 69 use by the acti
5a20: 6f 6e 20 72 6f 75 74 69 6e 65 73 2e 0a 2a 2a 0a on routines..**.
5a30: 2a 2a 20 49 6e 70 75 74 73 3a 0a 2a 2a 20 3c 75 ** Inputs:.** <u
5a40: 6c 3e 0a 2a 2a 20 3c 6c 69 3e 20 41 20 70 6f 69 l>.** <li> A poi
5a50: 6e 74 65 72 20 74 6f 20 74 68 65 20 70 61 72 73 nter to the pars
5a60: 65 72 20 28 61 6e 20 6f 70 61 71 75 65 20 73 74 er (an opaque st
5a70: 72 75 63 74 75 72 65 2e 29 0a 2a 2a 20 3c 6c 69 ructure.).** <li
5a80: 3e 20 54 68 65 20 6d 61 6a 6f 72 20 74 6f 6b 65 > The major toke
5a90: 6e 20 6e 75 6d 62 65 72 2e 0a 2a 2a 20 3c 6c 69 n number..** <li
5aa0: 3e 20 54 68 65 20 6d 69 6e 6f 72 20 74 6f 6b 65 > The minor toke
5ab0: 6e 20 6e 75 6d 62 65 72 2e 0a 2a 2a 20 3c 6c 69 n number..** <li
5ac0: 3e 20 41 6e 20 6f 70 74 69 6f 6e 20 61 72 67 75 > An option argu
5ad0: 6d 65 6e 74 20 6f 66 20 61 20 67 72 61 6d 6d 61 ment of a gramma
5ae0: 72 2d 73 70 65 63 69 66 69 65 64 20 74 79 70 65 r-specified type
5af0: 2e 0a 2a 2a 20 3c 2f 75 6c 3e 0a 2a 2a 0a 2a 2a ..** </ul>.**.**
5b00: 20 4f 75 74 70 75 74 73 3a 0a 2a 2a 20 4e 6f 6e Outputs:.** Non
5b10: 65 2e 0a 2a 2f 0a 76 6f 69 64 20 50 61 72 73 65 e..*/.void Parse
5b20: 28 0a 20 20 76 6f 69 64 20 2a 79 79 70 2c 20 20 (. void *yyp,
5b30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5b40: 20 2f 2a 20 54 68 65 20 70 61 72 73 65 72 20 2a /* The parser *
5b50: 2f 0a 20 20 69 6e 74 20 79 79 6d 61 6a 6f 72 2c /. int yymajor,
5b60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5b70: 20 2f 2a 20 54 68 65 20 6d 61 6a 6f 72 20 74 6f /* The major to
5b80: 6b 65 6e 20 63 6f 64 65 20 6e 75 6d 62 65 72 20 ken code number
5b90: 2a 2f 0a 20 20 50 61 72 73 65 54 4f 4b 45 4e 54 */. ParseTOKENT
5ba0: 59 50 45 20 79 79 6d 69 6e 6f 72 20 20 20 20 20 YPE yyminor
5bb0: 20 20 2f 2a 20 54 68 65 20 76 61 6c 75 65 20 66 /* The value f
5bc0: 6f 72 20 74 68 65 20 74 6f 6b 65 6e 20 2a 2f 0a or the token */.
5bd0: 20 20 50 61 72 73 65 41 52 47 5f 50 44 45 43 4c ParseARG_PDECL
5be0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
5bf0: 2a 20 4f 70 74 69 6f 6e 61 6c 20 25 65 78 74 72 * Optional %extr
5c00: 61 5f 61 72 67 75 6d 65 6e 74 20 70 61 72 61 6d a_argument param
5c10: 65 74 65 72 20 2a 2f 0a 29 7b 0a 20 20 59 59 4d eter */.){. YYM
5c20: 49 4e 4f 52 54 59 50 45 20 79 79 6d 69 6e 6f 72 INORTYPE yyminor
5c30: 75 6e 69 6f 6e 3b 0a 20 20 69 6e 74 20 79 79 61 union;. int yya
5c40: 63 74 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f ct; /
5c50: 2a 20 54 68 65 20 70 61 72 73 65 72 20 61 63 74 * The parser act
5c60: 69 6f 6e 2e 20 2a 2f 0a 23 69 66 20 21 64 65 66 ion. */.#if !def
5c70: 69 6e 65 64 28 59 59 45 52 52 4f 52 53 59 4d 42 ined(YYERRORSYMB
5c80: 4f 4c 29 20 26 26 20 21 64 65 66 69 6e 65 64 28 OL) && !defined(
5c90: 59 59 4e 4f 45 52 52 4f 52 52 45 43 4f 56 45 52 YYNOERRORRECOVER
5ca0: 59 29 0a 20 20 69 6e 74 20 79 79 65 6e 64 6f 66 Y). int yyendof
5cb0: 69 6e 70 75 74 3b 20 20 20 20 20 2f 2a 20 54 72 input; /* Tr
5cc0: 75 65 20 69 66 20 77 65 20 61 72 65 20 61 74 20 ue if we are at
5cd0: 74 68 65 20 65 6e 64 20 6f 66 20 69 6e 70 75 74 the end of input
5ce0: 20 2a 2f 0a 23 65 6e 64 69 66 0a 23 69 66 64 65 */.#endif.#ifde
5cf0: 66 20 59 59 45 52 52 4f 52 53 59 4d 42 4f 4c 0a f YYERRORSYMBOL.
5d00: 20 20 69 6e 74 20 79 79 65 72 72 6f 72 68 69 74 int yyerrorhit
5d10: 20 3d 20 30 3b 20 20 20 2f 2a 20 54 72 75 65 20 = 0; /* True
5d20: 69 66 20 79 79 6d 61 6a 6f 72 20 68 61 73 20 69 if yymajor has i
5d30: 6e 76 6f 6b 65 64 20 61 6e 20 65 72 72 6f 72 20 nvoked an error
5d40: 2a 2f 0a 23 65 6e 64 69 66 0a 20 20 79 79 50 61 */.#endif. yyPa
5d50: 72 73 65 72 20 2a 79 79 70 50 61 72 73 65 72 3b rser *yypParser;
5d60: 20 20 2f 2a 20 54 68 65 20 70 61 72 73 65 72 20 /* The parser
5d70: 2a 2f 0a 0a 20 20 2f 2a 20 28 72 65 29 69 6e 69 */.. /* (re)ini
5d80: 74 69 61 6c 69 7a 65 20 74 68 65 20 70 61 72 73 tialize the pars
5d90: 65 72 2c 20 69 66 20 6e 65 63 65 73 73 61 72 79 er, if necessary
5da0: 20 2a 2f 0a 20 20 79 79 70 50 61 72 73 65 72 20 */. yypParser
5db0: 3d 20 28 79 79 50 61 72 73 65 72 2a 29 79 79 70 = (yyParser*)yyp
5dc0: 3b 0a 20 20 69 66 28 20 79 79 70 50 61 72 73 65 ;. if( yypParse
5dd0: 72 2d 3e 79 79 69 64 78 3c 30 20 29 7b 0a 23 69 r->yyidx<0 ){.#i
5de0: 66 20 59 59 53 54 41 43 4b 44 45 50 54 48 3c 3d f YYSTACKDEPTH<=
5df0: 30 0a 20 20 20 20 69 66 28 20 79 79 70 50 61 72 0. if( yypPar
5e00: 73 65 72 2d 3e 79 79 73 74 6b 73 7a 20 3c 3d 30 ser->yystksz <=0
5e10: 20 29 7b 0a 20 20 20 20 20 20 2f 2a 6d 65 6d 73 ){. /*mems
5e20: 65 74 28 26 79 79 6d 69 6e 6f 72 75 6e 69 6f 6e et(&yyminorunion
5e30: 2c 20 30 2c 20 73 69 7a 65 6f 66 28 79 79 6d 69 , 0, sizeof(yymi
5e40: 6e 6f 72 75 6e 69 6f 6e 29 29 3b 2a 2f 0a 20 20 norunion));*/.
5e50: 20 20 20 20 79 79 6d 69 6e 6f 72 75 6e 69 6f 6e yyminorunion
5e60: 20 3d 20 79 79 7a 65 72 6f 6d 69 6e 6f 72 3b 0a = yyzerominor;.
5e70: 20 20 20 20 20 20 79 79 53 74 61 63 6b 4f 76 65 yyStackOve
5e80: 72 66 6c 6f 77 28 79 79 70 50 61 72 73 65 72 2c rflow(yypParser,
5e90: 20 26 79 79 6d 69 6e 6f 72 75 6e 69 6f 6e 29 3b &yyminorunion);
5ea0: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0a 20 . return;.
5eb0: 20 20 20 7d 0a 23 65 6e 64 69 66 0a 20 20 20 20 }.#endif.
5ec0: 79 79 70 50 61 72 73 65 72 2d 3e 79 79 69 64 78 yypParser->yyidx
5ed0: 20 3d 20 30 3b 0a 20 20 20 20 79 79 70 50 61 72 = 0;. yypPar
5ee0: 73 65 72 2d 3e 79 79 65 72 72 63 6e 74 20 3d 20 ser->yyerrcnt =
5ef0: 2d 31 3b 0a 20 20 20 20 79 79 70 50 61 72 73 65 -1;. yypParse
5f00: 72 2d 3e 79 79 73 74 61 63 6b 5b 30 5d 2e 73 74 r->yystack[0].st
5f10: 61 74 65 6e 6f 20 3d 20 30 3b 0a 20 20 20 20 79 ateno = 0;. y
5f20: 79 70 50 61 72 73 65 72 2d 3e 79 79 73 74 61 63 ypParser->yystac
5f30: 6b 5b 30 5d 2e 6d 61 6a 6f 72 20 3d 20 30 3b 0a k[0].major = 0;.
5f40: 20 20 7d 0a 20 20 79 79 6d 69 6e 6f 72 75 6e 69 }. yyminoruni
5f50: 6f 6e 2e 79 79 30 20 3d 20 79 79 6d 69 6e 6f 72 on.yy0 = yyminor
5f60: 3b 0a 23 69 66 20 21 64 65 66 69 6e 65 64 28 59 ;.#if !defined(Y
5f70: 59 45 52 52 4f 52 53 59 4d 42 4f 4c 29 20 26 26 YERRORSYMBOL) &&
5f80: 20 21 64 65 66 69 6e 65 64 28 59 59 4e 4f 45 52 !defined(YYNOER
5f90: 52 4f 52 52 45 43 4f 56 45 52 59 29 0a 20 20 79 RORRECOVERY). y
5fa0: 79 65 6e 64 6f 66 69 6e 70 75 74 20 3d 20 28 79 yendofinput = (y
5fb0: 79 6d 61 6a 6f 72 3d 3d 30 29 3b 0a 23 65 6e 64 ymajor==0);.#end
5fc0: 69 66 0a 20 20 50 61 72 73 65 41 52 47 5f 53 54 if. ParseARG_ST
5fd0: 4f 52 45 3b 0a 0a 23 69 66 6e 64 65 66 20 4e 44 ORE;..#ifndef ND
5fe0: 45 42 55 47 0a 20 20 69 66 28 20 79 79 54 72 61 EBUG. if( yyTra
5ff0: 63 65 46 49 4c 45 20 29 7b 0a 20 20 20 20 66 70 ceFILE ){. fp
6000: 72 69 6e 74 66 28 79 79 54 72 61 63 65 46 49 4c rintf(yyTraceFIL
6010: 45 2c 22 25 73 49 6e 70 75 74 20 25 73 5c 6e 22 E,"%sInput %s\n"
6020: 2c 79 79 54 72 61 63 65 50 72 6f 6d 70 74 2c 79 ,yyTracePrompt,y
6030: 79 54 6f 6b 65 6e 4e 61 6d 65 5b 79 79 6d 61 6a yTokenName[yymaj
6040: 6f 72 5d 29 3b 0a 20 20 7d 0a 23 65 6e 64 69 66 or]);. }.#endif
6050: 0a 0a 20 20 64 6f 7b 0a 20 20 20 20 79 79 61 63 .. do{. yyac
6060: 74 20 3d 20 79 79 5f 66 69 6e 64 5f 73 68 69 66 t = yy_find_shif
6070: 74 5f 61 63 74 69 6f 6e 28 79 79 70 50 61 72 73 t_action(yypPars
6080: 65 72 2c 28 59 59 43 4f 44 45 54 59 50 45 29 79 er,(YYCODETYPE)y
6090: 79 6d 61 6a 6f 72 29 3b 0a 20 20 20 20 69 66 28 ymajor);. if(
60a0: 20 79 79 61 63 74 3c 59 59 4e 53 54 41 54 45 20 yyact<YYNSTATE
60b0: 29 7b 0a 20 20 20 20 20 20 79 79 5f 73 68 69 66 ){. yy_shif
60c0: 74 28 79 79 70 50 61 72 73 65 72 2c 79 79 61 63 t(yypParser,yyac
60d0: 74 2c 79 79 6d 61 6a 6f 72 2c 26 79 79 6d 69 6e t,yymajor,&yymin
60e0: 6f 72 75 6e 69 6f 6e 29 3b 0a 20 20 20 20 20 20 orunion);.
60f0: 79 79 70 50 61 72 73 65 72 2d 3e 79 79 65 72 72 yypParser->yyerr
6100: 63 6e 74 2d 2d 3b 0a 20 20 20 20 20 20 79 79 6d cnt--;. yym
6110: 61 6a 6f 72 20 3d 20 59 59 4e 4f 43 4f 44 45 3b ajor = YYNOCODE;
6120: 0a 20 20 20 20 7d 65 6c 73 65 20 69 66 28 20 79 . }else if( y
6130: 79 61 63 74 20 3c 20 59 59 4e 53 54 41 54 45 20 yact < YYNSTATE
6140: 2b 20 59 59 4e 52 55 4c 45 20 29 7b 0a 20 20 20 + YYNRULE ){.
6150: 20 20 20 79 79 5f 72 65 64 75 63 65 28 79 79 70 yy_reduce(yyp
6160: 50 61 72 73 65 72 2c 79 79 61 63 74 2d 59 59 4e Parser,yyact-YYN
6170: 53 54 41 54 45 29 3b 0a 20 20 20 20 7d 65 6c 73 STATE);. }els
6180: 65 7b 0a 20 20 20 20 20 20 61 73 73 65 72 74 28 e{. assert(
6190: 20 79 79 61 63 74 20 3d 3d 20 59 59 5f 45 52 52 yyact == YY_ERR
61a0: 4f 52 5f 41 43 54 49 4f 4e 20 29 3b 0a 23 69 66 OR_ACTION );.#if
61b0: 64 65 66 20 59 59 45 52 52 4f 52 53 59 4d 42 4f def YYERRORSYMBO
61c0: 4c 0a 20 20 20 20 20 20 69 6e 74 20 79 79 6d 78 L. int yymx
61d0: 3b 0a 23 65 6e 64 69 66 0a 23 69 66 6e 64 65 66 ;.#endif.#ifndef
61e0: 20 4e 44 45 42 55 47 0a 20 20 20 20 20 20 69 66 NDEBUG. if
61f0: 28 20 79 79 54 72 61 63 65 46 49 4c 45 20 29 7b ( yyTraceFILE ){
6200: 0a 20 20 20 20 20 20 20 20 66 70 72 69 6e 74 66 . fprintf
6210: 28 79 79 54 72 61 63 65 46 49 4c 45 2c 22 25 73 (yyTraceFILE,"%s
6220: 53 79 6e 74 61 78 20 45 72 72 6f 72 21 5c 6e 22 Syntax Error!\n"
6230: 2c 79 79 54 72 61 63 65 50 72 6f 6d 70 74 29 3b ,yyTracePrompt);
6240: 0a 20 20 20 20 20 20 7d 0a 23 65 6e 64 69 66 0a . }.#endif.
6250: 23 69 66 64 65 66 20 59 59 45 52 52 4f 52 53 59 #ifdef YYERRORSY
6260: 4d 42 4f 4c 0a 20 20 20 20 20 20 2f 2a 20 41 20 MBOL. /* A
6270: 73 79 6e 74 61 78 20 65 72 72 6f 72 20 68 61 73 syntax error has
6280: 20 6f 63 63 75 72 72 65 64 2e 0a 20 20 20 20 20 occurred..
6290: 20 2a 2a 20 54 68 65 20 72 65 73 70 6f 6e 73 65 ** The response
62a0: 20 74 6f 20 61 6e 20 65 72 72 6f 72 20 64 65 70 to an error dep
62b0: 65 6e 64 73 20 75 70 6f 6e 20 77 68 65 74 68 65 ends upon whethe
62c0: 72 20 6f 72 20 6e 6f 74 20 74 68 65 0a 20 20 20 r or not the.
62d0: 20 20 20 2a 2a 20 67 72 61 6d 6d 61 72 20 64 65 ** grammar de
62e0: 66 69 6e 65 73 20 61 6e 20 65 72 72 6f 72 20 74 fines an error t
62f0: 6f 6b 65 6e 20 22 45 52 52 4f 52 22 2e 20 20 0a oken "ERROR". .
6300: 20 20 20 20 20 20 2a 2a 0a 20 20 20 20 20 20 2a **. *
6310: 2a 20 54 68 69 73 20 69 73 20 77 68 61 74 20 77 * This is what w
6320: 65 20 64 6f 20 69 66 20 74 68 65 20 67 72 61 6d e do if the gram
6330: 6d 61 72 20 64 6f 65 73 20 64 65 66 69 6e 65 20 mar does define
6340: 45 52 52 4f 52 3a 0a 20 20 20 20 20 20 2a 2a 0a ERROR:. **.
6350: 20 20 20 20 20 20 2a 2a 20 20 2a 20 43 61 6c 6c ** * Call
6360: 20 74 68 65 20 25 73 79 6e 74 61 78 5f 65 72 72 the %syntax_err
6370: 6f 72 20 66 75 6e 63 74 69 6f 6e 2e 0a 20 20 20 or function..
6380: 20 20 20 2a 2a 0a 20 20 20 20 20 20 2a 2a 20 20 **. **
6390: 2a 20 42 65 67 69 6e 20 70 6f 70 70 69 6e 67 20 * Begin popping
63a0: 74 68 65 20 73 74 61 63 6b 20 75 6e 74 69 6c 20 the stack until
63b0: 77 65 20 65 6e 74 65 72 20 61 20 73 74 61 74 65 we enter a state
63c0: 20 77 68 65 72 65 0a 20 20 20 20 20 20 2a 2a 20 where. **
63d0: 20 20 20 69 74 20 69 73 20 6c 65 67 61 6c 20 74 it is legal t
63e0: 6f 20 73 68 69 66 74 20 74 68 65 20 65 72 72 6f o shift the erro
63f0: 72 20 73 79 6d 62 6f 6c 2c 20 74 68 65 6e 20 73 r symbol, then s
6400: 68 69 66 74 0a 20 20 20 20 20 20 2a 2a 20 20 20 hift. **
6410: 20 74 68 65 20 65 72 72 6f 72 20 73 79 6d 62 6f the error symbo
6420: 6c 2e 0a 20 20 20 20 20 20 2a 2a 0a 20 20 20 20 l.. **.
6430: 20 20 2a 2a 20 20 2a 20 53 65 74 20 74 68 65 20 ** * Set the
6440: 65 72 72 6f 72 20 63 6f 75 6e 74 20 74 6f 20 74 error count to t
6450: 68 72 65 65 2e 0a 20 20 20 20 20 20 2a 2a 0a 20 hree.. **.
6460: 20 20 20 20 20 2a 2a 20 20 2a 20 42 65 67 69 6e ** * Begin
6470: 20 61 63 63 65 70 74 69 6e 67 20 61 6e 64 20 73 accepting and s
6480: 68 69 66 74 69 6e 67 20 6e 65 77 20 74 6f 6b 65 hifting new toke
6490: 6e 73 2e 20 20 4e 6f 20 6e 65 77 20 65 72 72 6f ns. No new erro
64a0: 72 0a 20 20 20 20 20 20 2a 2a 20 20 20 20 70 72 r. ** pr
64b0: 6f 63 65 73 73 69 6e 67 20 77 69 6c 6c 20 6f 63 ocessing will oc
64c0: 63 75 72 20 75 6e 74 69 6c 20 74 68 72 65 65 20 cur until three
64d0: 74 6f 6b 65 6e 73 20 68 61 76 65 20 62 65 65 6e tokens have been
64e0: 0a 20 20 20 20 20 20 2a 2a 20 20 20 20 73 68 69 . ** shi
64f0: 66 74 65 64 20 73 75 63 63 65 73 73 66 75 6c 6c fted successfull
6500: 79 2e 0a 20 20 20 20 20 20 2a 2a 0a 20 20 20 20 y.. **.
6510: 20 20 2a 2f 0a 20 20 20 20 20 20 69 66 28 20 79 */. if( y
6520: 79 70 50 61 72 73 65 72 2d 3e 79 79 65 72 72 63 ypParser->yyerrc
6530: 6e 74 3c 30 20 29 7b 0a 20 20 20 20 20 20 20 20 nt<0 ){.
6540: 79 79 5f 73 79 6e 74 61 78 5f 65 72 72 6f 72 28 yy_syntax_error(
6550: 79 79 70 50 61 72 73 65 72 2c 79 79 6d 61 6a 6f yypParser,yymajo
6560: 72 2c 79 79 6d 69 6e 6f 72 75 6e 69 6f 6e 29 3b r,yyminorunion);
6570: 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 79 . }. y
6580: 79 6d 78 20 3d 20 79 79 70 50 61 72 73 65 72 2d ymx = yypParser-
6590: 3e 79 79 73 74 61 63 6b 5b 79 79 70 50 61 72 73 >yystack[yypPars
65a0: 65 72 2d 3e 79 79 69 64 78 5d 2e 6d 61 6a 6f 72 er->yyidx].major
65b0: 3b 0a 20 20 20 20 20 20 69 66 28 20 79 79 6d 78 ;. if( yymx
65c0: 3d 3d 59 59 45 52 52 4f 52 53 59 4d 42 4f 4c 20 ==YYERRORSYMBOL
65d0: 7c 7c 20 79 79 65 72 72 6f 72 68 69 74 20 29 7b || yyerrorhit ){
65e0: 0a 23 69 66 6e 64 65 66 20 4e 44 45 42 55 47 0a .#ifndef NDEBUG.
65f0: 20 20 20 20 20 20 20 20 69 66 28 20 79 79 54 72 if( yyTr
6600: 61 63 65 46 49 4c 45 20 29 7b 0a 20 20 20 20 20 aceFILE ){.
6610: 20 20 20 20 20 66 70 72 69 6e 74 66 28 79 79 54 fprintf(yyT
6620: 72 61 63 65 46 49 4c 45 2c 22 25 73 44 69 73 63 raceFILE,"%sDisc
6630: 61 72 64 20 69 6e 70 75 74 20 74 6f 6b 65 6e 20 ard input token
6640: 25 73 5c 6e 22 2c 0a 20 20 20 20 20 20 20 20 20 %s\n",.
6650: 20 20 20 20 79 79 54 72 61 63 65 50 72 6f 6d 70 yyTracePromp
6660: 74 2c 79 79 54 6f 6b 65 6e 4e 61 6d 65 5b 79 79 t,yyTokenName[yy
6670: 6d 61 6a 6f 72 5d 29 3b 0a 20 20 20 20 20 20 20 major]);.
6680: 20 7d 0a 23 65 6e 64 69 66 0a 20 20 20 20 20 20 }.#endif.
6690: 20 20 79 79 5f 64 65 73 74 72 75 63 74 6f 72 28 yy_destructor(
66a0: 79 79 70 50 61 72 73 65 72 2c 20 28 59 59 43 4f yypParser, (YYCO
66b0: 44 45 54 59 50 45 29 79 79 6d 61 6a 6f 72 2c 26 DETYPE)yymajor,&
66c0: 79 79 6d 69 6e 6f 72 75 6e 69 6f 6e 29 3b 0a 20 yyminorunion);.
66d0: 20 20 20 20 20 20 20 79 79 6d 61 6a 6f 72 20 3d yymajor =
66e0: 20 59 59 4e 4f 43 4f 44 45 3b 0a 20 20 20 20 20 YYNOCODE;.
66f0: 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20 20 20 }else{.
6700: 20 77 68 69 6c 65 28 0a 20 20 20 20 20 20 20 20 while(.
6710: 20 20 79 79 70 50 61 72 73 65 72 2d 3e 79 79 69 yypParser->yyi
6720: 64 78 20 3e 3d 20 30 20 26 26 0a 20 20 20 20 20 dx >= 0 &&.
6730: 20 20 20 20 20 79 79 6d 78 20 21 3d 20 59 59 45 yymx != YYE
6740: 52 52 4f 52 53 59 4d 42 4f 4c 20 26 26 0a 20 20 RRORSYMBOL &&.
6750: 20 20 20 20 20 20 20 20 28 79 79 61 63 74 20 3d (yyact =
6760: 20 79 79 5f 66 69 6e 64 5f 72 65 64 75 63 65 5f yy_find_reduce_
6770: 61 63 74 69 6f 6e 28 0a 20 20 20 20 20 20 20 20 action(.
6780: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
6790: 79 79 70 50 61 72 73 65 72 2d 3e 79 79 73 74 61 yypParser->yysta
67a0: 63 6b 5b 79 79 70 50 61 72 73 65 72 2d 3e 79 79 ck[yypParser->yy
67b0: 69 64 78 5d 2e 73 74 61 74 65 6e 6f 2c 0a 20 20 idx].stateno,.
67c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
67d0: 20 20 20 20 20 20 59 59 45 52 52 4f 52 53 59 4d YYERRORSYM
67e0: 42 4f 4c 29 29 20 3e 3d 20 59 59 4e 53 54 41 54 BOL)) >= YYNSTAT
67f0: 45 0a 20 20 20 20 20 20 20 20 29 7b 0a 20 20 20 E. ){.
6800: 20 20 20 20 20 20 20 79 79 5f 70 6f 70 5f 70 61 yy_pop_pa
6810: 72 73 65 72 5f 73 74 61 63 6b 28 79 79 70 50 61 rser_stack(yypPa
6820: 72 73 65 72 29 3b 0a 20 20 20 20 20 20 20 20 7d rser);. }
6830: 0a 20 20 20 20 20 20 20 20 69 66 28 20 79 79 70 . if( yyp
6840: 50 61 72 73 65 72 2d 3e 79 79 69 64 78 20 3c 20 Parser->yyidx <
6850: 30 20 7c 7c 20 79 79 6d 61 6a 6f 72 3d 3d 30 20 0 || yymajor==0
6860: 29 7b 0a 20 20 20 20 20 20 20 20 20 20 79 79 5f ){. yy_
6870: 64 65 73 74 72 75 63 74 6f 72 28 79 79 70 50 61 destructor(yypPa
6880: 72 73 65 72 2c 28 59 59 43 4f 44 45 54 59 50 45 rser,(YYCODETYPE
6890: 29 79 79 6d 61 6a 6f 72 2c 26 79 79 6d 69 6e 6f )yymajor,&yymino
68a0: 72 75 6e 69 6f 6e 29 3b 0a 20 20 20 20 20 20 20 runion);.
68b0: 20 20 20 79 79 5f 70 61 72 73 65 5f 66 61 69 6c yy_parse_fail
68c0: 65 64 28 79 79 70 50 61 72 73 65 72 29 3b 0a 20 ed(yypParser);.
68d0: 20 20 20 20 20 20 20 20 20 79 79 6d 61 6a 6f 72 yymajor
68e0: 20 3d 20 59 59 4e 4f 43 4f 44 45 3b 0a 20 20 20 = YYNOCODE;.
68f0: 20 20 20 20 20 7d 65 6c 73 65 20 69 66 28 20 79 }else if( y
6900: 79 6d 78 21 3d 59 59 45 52 52 4f 52 53 59 4d 42 ymx!=YYERRORSYMB
6910: 4f 4c 20 29 7b 0a 20 20 20 20 20 20 20 20 20 20 OL ){.
6920: 59 59 4d 49 4e 4f 52 54 59 50 45 20 75 32 3b 0a YYMINORTYPE u2;.
6930: 20 20 20 20 20 20 20 20 20 20 75 32 2e 59 59 45 u2.YYE
6940: 52 52 53 59 4d 44 54 20 3d 20 30 3b 0a 20 20 20 RRSYMDT = 0;.
6950: 20 20 20 20 20 20 20 79 79 5f 73 68 69 66 74 28 yy_shift(
6960: 79 79 70 50 61 72 73 65 72 2c 79 79 61 63 74 2c yypParser,yyact,
6970: 59 59 45 52 52 4f 52 53 59 4d 42 4f 4c 2c 26 75 YYERRORSYMBOL,&u
6980: 32 29 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 2);. }.
6990: 20 20 20 20 7d 0a 20 20 20 20 20 20 79 79 70 50 }. yypP
69a0: 61 72 73 65 72 2d 3e 79 79 65 72 72 63 6e 74 20 arser->yyerrcnt
69b0: 3d 20 33 3b 0a 20 20 20 20 20 20 79 79 65 72 72 = 3;. yyerr
69c0: 6f 72 68 69 74 20 3d 20 31 3b 0a 23 65 6c 69 66 orhit = 1;.#elif
69d0: 20 64 65 66 69 6e 65 64 28 59 59 4e 4f 45 52 52 defined(YYNOERR
69e0: 4f 52 52 45 43 4f 56 45 52 59 29 0a 20 20 20 20 ORRECOVERY).
69f0: 20 20 2f 2a 20 49 66 20 74 68 65 20 59 59 4e 4f /* If the YYNO
6a00: 45 52 52 4f 52 52 45 43 4f 56 45 52 59 20 6d 61 ERRORRECOVERY ma
6a10: 63 72 6f 20 69 73 20 64 65 66 69 6e 65 64 2c 20 cro is defined,
6a20: 74 68 65 6e 20 64 6f 20 6e 6f 74 20 61 74 74 65 then do not atte
6a30: 6d 70 74 20 74 6f 0a 20 20 20 20 20 20 2a 2a 20 mpt to. **
6a40: 64 6f 20 61 6e 79 20 6b 69 6e 64 20 6f 66 20 65 do any kind of e
6a50: 72 72 6f 72 20 72 65 63 6f 76 65 72 79 2e 20 20 rror recovery.
6a60: 49 6e 73 74 65 61 64 2c 20 73 69 6d 70 6c 79 20 Instead, simply
6a70: 69 6e 76 6f 6b 65 20 74 68 65 20 73 79 6e 74 61 invoke the synta
6a80: 78 0a 20 20 20 20 20 20 2a 2a 20 65 72 72 6f 72 x. ** error
6a90: 20 72 6f 75 74 69 6e 65 20 61 6e 64 20 63 6f 6e routine and con
6aa0: 74 69 6e 75 65 20 67 6f 69 6e 67 20 61 73 20 69 tinue going as i
6ab0: 66 20 6e 6f 74 68 69 6e 67 20 68 61 64 20 68 61 f nothing had ha
6ac0: 70 70 65 6e 65 64 2e 0a 20 20 20 20 20 20 2a 2a ppened.. **
6ad0: 0a 20 20 20 20 20 20 2a 2a 20 41 70 70 6c 69 63 . ** Applic
6ae0: 61 74 69 6f 6e 73 20 63 61 6e 20 73 65 74 20 74 ations can set t
6af0: 68 69 73 20 6d 61 63 72 6f 20 28 66 6f 72 20 65 his macro (for e
6b00: 78 61 6d 70 6c 65 20 69 6e 73 69 64 65 20 25 69 xample inside %i
6b10: 6e 63 6c 75 64 65 29 20 69 66 0a 20 20 20 20 20 nclude) if.
6b20: 20 2a 2a 20 74 68 65 79 20 69 6e 74 65 6e 64 20 ** they intend
6b30: 74 6f 20 61 62 61 6e 64 6f 6e 20 74 68 65 20 70 to abandon the p
6b40: 61 72 73 65 20 75 70 6f 6e 20 74 68 65 20 66 69 arse upon the fi
6b50: 72 73 74 20 73 79 6e 74 61 78 20 65 72 72 6f 72 rst syntax error
6b60: 20 73 65 65 6e 2e 0a 20 20 20 20 20 20 2a 2f 0a seen.. */.
6b70: 20 20 20 20 20 20 79 79 5f 73 79 6e 74 61 78 5f yy_syntax_
6b80: 65 72 72 6f 72 28 79 79 70 50 61 72 73 65 72 2c error(yypParser,
6b90: 79 79 6d 61 6a 6f 72 2c 79 79 6d 69 6e 6f 72 75 yymajor,yyminoru
6ba0: 6e 69 6f 6e 29 3b 0a 20 20 20 20 20 20 79 79 5f nion);. yy_
6bb0: 64 65 73 74 72 75 63 74 6f 72 28 79 79 70 50 61 destructor(yypPa
6bc0: 72 73 65 72 2c 28 59 59 43 4f 44 45 54 59 50 45 rser,(YYCODETYPE
6bd0: 29 79 79 6d 61 6a 6f 72 2c 26 79 79 6d 69 6e 6f )yymajor,&yymino
6be0: 72 75 6e 69 6f 6e 29 3b 0a 20 20 20 20 20 20 79 runion);. y
6bf0: 79 6d 61 6a 6f 72 20 3d 20 59 59 4e 4f 43 4f 44 ymajor = YYNOCOD
6c00: 45 3b 0a 20 20 20 20 20 20 0a 23 65 6c 73 65 20 E;. .#else
6c10: 20 2f 2a 20 59 59 45 52 52 4f 52 53 59 4d 42 4f /* YYERRORSYMBO
6c20: 4c 20 69 73 20 6e 6f 74 20 64 65 66 69 6e 65 64 L is not defined
6c30: 20 2a 2f 0a 20 20 20 20 20 20 2f 2a 20 54 68 69 */. /* Thi
6c40: 73 20 69 73 20 77 68 61 74 20 77 65 20 64 6f 20 s is what we do
6c50: 69 66 20 74 68 65 20 67 72 61 6d 6d 61 72 20 64 if the grammar d
6c60: 6f 65 73 20 6e 6f 74 20 64 65 66 69 6e 65 20 45 oes not define E
6c70: 52 52 4f 52 3a 0a 20 20 20 20 20 20 2a 2a 0a 20 RROR:. **.
6c80: 20 20 20 20 20 2a 2a 20 20 2a 20 52 65 70 6f 72 ** * Repor
6c90: 74 20 61 6e 20 65 72 72 6f 72 20 6d 65 73 73 61 t an error messa
6ca0: 67 65 2c 20 61 6e 64 20 74 68 72 6f 77 20 61 77 ge, and throw aw
6cb0: 61 79 20 74 68 65 20 69 6e 70 75 74 20 74 6f 6b ay the input tok
6cc0: 65 6e 2e 0a 20 20 20 20 20 20 2a 2a 0a 20 20 20 en.. **.
6cd0: 20 20 20 2a 2a 20 20 2a 20 49 66 20 74 68 65 20 ** * If the
6ce0: 69 6e 70 75 74 20 74 6f 6b 65 6e 20 69 73 20 24 input token is $
6cf0: 2c 20 74 68 65 6e 20 66 61 69 6c 20 74 68 65 20 , then fail the
6d00: 70 61 72 73 65 2e 0a 20 20 20 20 20 20 2a 2a 0a parse.. **.
6d10: 20 20 20 20 20 20 2a 2a 20 41 73 20 62 65 66 6f ** As befo
6d20: 72 65 2c 20 73 75 62 73 65 71 75 65 6e 74 20 65 re, subsequent e
6d30: 72 72 6f 72 20 6d 65 73 73 61 67 65 73 20 61 72 rror messages ar
6d40: 65 20 73 75 70 70 72 65 73 73 65 64 20 75 6e 74 e suppressed unt
6d50: 69 6c 0a 20 20 20 20 20 20 2a 2a 20 74 68 72 65 il. ** thre
6d60: 65 20 69 6e 70 75 74 20 74 6f 6b 65 6e 73 20 68 e input tokens h
6d70: 61 76 65 20 62 65 65 6e 20 73 75 63 63 65 73 73 ave been success
6d80: 66 75 6c 6c 79 20 73 68 69 66 74 65 64 2e 0a 20 fully shifted..
6d90: 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 69 66 */. if
6da0: 28 20 79 79 70 50 61 72 73 65 72 2d 3e 79 79 65 ( yypParser->yye
6db0: 72 72 63 6e 74 3c 3d 30 20 29 7b 0a 20 20 20 20 rrcnt<=0 ){.
6dc0: 20 20 20 20 79 79 5f 73 79 6e 74 61 78 5f 65 72 yy_syntax_er
6dd0: 72 6f 72 28 79 79 70 50 61 72 73 65 72 2c 79 79 ror(yypParser,yy
6de0: 6d 61 6a 6f 72 2c 79 79 6d 69 6e 6f 72 75 6e 69 major,yyminoruni
6df0: 6f 6e 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 on);. }.
6e00: 20 20 20 79 79 70 50 61 72 73 65 72 2d 3e 79 79 yypParser->yy
6e10: 65 72 72 63 6e 74 20 3d 20 33 3b 0a 20 20 20 20 errcnt = 3;.
6e20: 20 20 79 79 5f 64 65 73 74 72 75 63 74 6f 72 28 yy_destructor(
6e30: 79 79 70 50 61 72 73 65 72 2c 28 59 59 43 4f 44 yypParser,(YYCOD
6e40: 45 54 59 50 45 29 79 79 6d 61 6a 6f 72 2c 26 79 ETYPE)yymajor,&y
6e50: 79 6d 69 6e 6f 72 75 6e 69 6f 6e 29 3b 0a 20 20 yminorunion);.
6e60: 20 20 20 20 69 66 28 20 79 79 65 6e 64 6f 66 69 if( yyendofi
6e70: 6e 70 75 74 20 29 7b 0a 20 20 20 20 20 20 20 20 nput ){.
6e80: 79 79 5f 70 61 72 73 65 5f 66 61 69 6c 65 64 28 yy_parse_failed(
6e90: 79 79 70 50 61 72 73 65 72 29 3b 0a 20 20 20 20 yypParser);.
6ea0: 20 20 7d 0a 20 20 20 20 20 20 79 79 6d 61 6a 6f }. yymajo
6eb0: 72 20 3d 20 59 59 4e 4f 43 4f 44 45 3b 0a 23 65 r = YYNOCODE;.#e
6ec0: 6e 64 69 66 0a 20 20 20 20 7d 0a 20 20 7d 77 68 ndif. }. }wh
6ed0: 69 6c 65 28 20 79 79 6d 61 6a 6f 72 21 3d 59 59 ile( yymajor!=YY
6ee0: 4e 4f 43 4f 44 45 20 26 26 20 79 79 70 50 61 72 NOCODE && yypPar
6ef0: 73 65 72 2d 3e 79 79 69 64 78 3e 3d 30 20 29 3b ser->yyidx>=0 );
6f00: 0a 20 20 72 65 74 75 72 6e 3b 0a 7d 0a . return;.}.