ABNF Parser Generator
Tutorial 4 - Configuring the Parser Trace
In this exercise we will use the grammar from the "expressions" example to examine the features in the parser trace. We will not be doing any debugging or grammar or syntax analysis. We will simply do a walk through of the Parser Configuration and how it controls the view of the traced records.
First click Generate, then follow the intructions below.
There are three exercises here to illustrate the three configuration sections, "Line Range Filter", "Operator Filter - Node Type Operators" and "Operator Filter - Rule Name Operators". To get started, click Configure, check the "Saved Parser Trace" box, save and finish. "Finish" here and in all other demonstrations means to click "Parser", "Display Trace" then "Full Screen" (optional but recommended).
Operator Filter - Rule Name Operators: Right away you will notice the annoying and almost-always useless repetition of the "alpha" and "digit" rule names. It is an obvious demonstration of how uninteresting rules lengthen a trace view and clutter it with useless information. Click Configure and uncheck the "alpha" and "digit" boxes, save and finish. The trace view is a little shorter and cleaner now. Often, there will only be one or a few rules from a large grammar that are of interest and this becomes a very useful feature.
Operator Filter - Node Type Operators: Click Configure and under "Traced Operators" click Check All, save and finish. See why these operators are unchecked by default? The number of saved trace records has gone from 74 to 534. Occasionally you might want to know which alternate or concatenation fails, but it usually only one or a few rule names that are of interest. However, the grammar does not define rules for the expression characters "+", "*", "(" and ")". These are defined directly with terminal TLS operators. If you want to find them in the trace, click Configure and uncheck all but the TLS operator. Save and finish. If we are in synch you will see the "+" character matched by TLS at line 17.
Line Range Filter: If you've completed the above examples you will note that the trace only has 140 lines - considerably less than the 100,000 maximum. In this exercise we will arbitrarily set a small number for the maximum number of lines displayed in order to demonstrate the line range features.
max records: Click Configure and enter 100 in the box labeled "max records". Save and finish. Note that the number of saved records has been clipped to the max of 100.
first N records: Click Configure and note that the "first N records" radio button is selected by default. Type 10 in the "number of records" box, save and finish. You should see that only the first 10 records are now displayed. Now type 100 in the "first record" box, save and finish. You should now see 10 records beginning with record 100. Note that record number refers to the invariant unfiltered record number, not the sequential index number.
last N records: However, it is often the case that we would rather see the last 100 records instead of the first. Click Configure and select the "last N records" radio box. Save and finish. This time you will note that it is the last 100 records that were saved.
record range: It is also possible to select a specific range of records. Click Configure and select the "record range" radio button. For first and last record type 400 and 600 respectively. Save and finish. Note that only those records with unfiltered record numbers between the limits requested are saved.
|
|