/ Check-in [c4951833]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improved parser tracing output.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | span-refactor
Files: files | file ages | folders
SHA3-256: c4951833c2b976223c2393d82fd2606068c71cd19612ca9df4e26debab980e32
User & Date: drh 2017-12-24 14:14:21
Context
2017-12-24
17:06
Improved parser tracing output. check-in: 25be5750 user: drh tags: lemon-improvements
17:01
Grammar changes: the sclp non-terminal should always be followed by a scanpt. check-in: 74a0181f user: drh tags: span-refactor
14:14
Improved parser tracing output. check-in: c4951833 user: drh tags: span-refactor
00:18
Remove the ExprSpan object. Instead, keep track of the test of subphrases in the parse using the "scanpt" non-terminal. check-in: 3eab7bdc user: drh tags: span-refactor
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/lempar.c.

   574    574      ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
   575    575   }
   576    576   
   577    577   /*
   578    578   ** Print tracing information for a SHIFT action
   579    579   */
   580    580   #ifndef NDEBUG
   581         -static void yyTraceShift(yyParser *yypParser, int yyNewState){
          581  +static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
   582    582     if( yyTraceFILE ){
   583    583       if( yyNewState<YYNSTATE ){
   584         -      fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
   585         -         yyTracePrompt,yyTokenName[yypParser->yytos->major],
          584  +      fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n",
          585  +         yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
   586    586            yyNewState);
   587    587       }else{
   588         -      fprintf(yyTraceFILE,"%sShift '%s'\n",
   589         -         yyTracePrompt,yyTokenName[yypParser->yytos->major]);
          588  +      fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n",
          589  +         yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
          590  +         yyNewState - YY_MIN_REDUCE);
   590    591       }
   591    592     }
   592    593   }
   593    594   #else
   594         -# define yyTraceShift(X,Y)
          595  +# define yyTraceShift(X,Y,Z)
   595    596   #endif
   596    597   
   597    598   /*
   598    599   ** Perform a shift action.
   599    600   */
   600    601   static void yy_shift(
   601    602     yyParser *yypParser,          /* The parser to be shifted */
................................................................................
   629    630     if( yyNewState > YY_MAX_SHIFT ){
   630    631       yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
   631    632     }
   632    633     yytos = yypParser->yytos;
   633    634     yytos->stateno = (YYACTIONTYPE)yyNewState;
   634    635     yytos->major = (YYCODETYPE)yyMajor;
   635    636     yytos->minor.yy0 = yyMinor;
   636         -  yyTraceShift(yypParser, yyNewState);
          637  +  yyTraceShift(yypParser, yyNewState, "Shift");
   637    638   }
   638    639   
   639    640   /* The following table contains information about every rule that
   640    641   ** is used during the reduce.
   641    642   */
   642    643   static const struct {
   643    644     YYCODETYPE lhs;       /* Symbol on the left-hand side of the rule */
................................................................................
   669    670     yyStackEntry *yymsp;            /* The top of the parser's stack */
   670    671     int yysize;                     /* Amount to pop the stack */
   671    672     ParseARG_FETCH;
   672    673     yymsp = yypParser->yytos;
   673    674   #ifndef NDEBUG
   674    675     if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
   675    676       yysize = yyRuleInfo[yyruleno].nrhs;
   676         -    fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
   677         -      yyRuleName[yyruleno], yymsp[yysize].stateno);
          677  +    if( yysize ){
          678  +      fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
          679  +        yyTracePrompt,
          680  +        yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno);
          681  +    }else{
          682  +      fprintf(yyTraceFILE, "%sReduce %d [%s].\n",
          683  +        yyTracePrompt, yyruleno, yyRuleName[yyruleno]);
          684  +    }
   678    685     }
   679    686   #endif /* NDEBUG */
   680    687   
   681    688     /* Check that the stack is large enough to grow by a single entry
   682    689     ** if the RHS of the rule is empty.  This ensures that there is room
   683    690     ** enough on the stack to push the LHS value */
   684    691     if( yyRuleInfo[yyruleno].nrhs==0 ){
................................................................................
   733    740       yypParser->yytos += yysize;
   734    741       yy_accept(yypParser);
   735    742     }else{
   736    743       yymsp += yysize+1;
   737    744       yypParser->yytos = yymsp;
   738    745       yymsp->stateno = (YYACTIONTYPE)yyact;
   739    746       yymsp->major = (YYCODETYPE)yygoto;
   740         -    yyTraceShift(yypParser, yyact);
          747  +    yyTraceShift(yypParser, yyact, "... then shift");
   741    748     }
   742    749   }
   743    750   
   744    751   /*
   745    752   ** The following code executes when the parse fails
   746    753   */
   747    754   #ifndef YYNOERRORRECOVERY
................................................................................
   844    851   #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
   845    852     yyendofinput = (yymajor==0);
   846    853   #endif
   847    854     ParseARG_STORE;
   848    855   
   849    856   #ifndef NDEBUG
   850    857     if( yyTraceFILE ){
   851         -    fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]);
          858  +    int stateno = yypParser->yytos->stateno;
          859  +    if( stateno < YY_MIN_REDUCE ){
          860  +      fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
          861  +              yyTracePrompt,yyTokenName[yymajor],stateno);
          862  +    }else{
          863  +      fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
          864  +              yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE);
          865  +    }
   852    866     }
   853    867   #endif
   854    868   
   855    869     do{
   856    870       yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
   857    871       if( yyact <= YY_MAX_SHIFTREDUCE ){
   858    872         yy_shift(yypParser,yyact,yymajor,yyminor);