Parsifal Software


Trial Copy

Intro. to Parsing

Users Say...

Special Features

Notation Summary

New 2.01 Features

File Trace

Grammar Trace



Expression evaluator (freeware)

XIDEK interpreter kit (freeware)

Lex/Yacc Comparison

If-else ambiguity

Contact Parsifal


AnaGram Parser Generator: File Trace

AnaGram's File Trace tool allows you to try out your grammar on a test file and see how your grammar works before you even build a parser. You can observe how the parser stack changes as you single-step, fast forward, or back up. You can also view the relationship between elements of the stack, sections of your test file, and your syntax file.

sample File Trace window

Starting File Trace:

File Trace can be selected from either the Action Menu or the Control Panel toolbar once your grammar has been analyzed. A file dialog will be presented to allow you to choose a test file. The files shown in the dialog are determined by the setting of the test file mask configuration parameter, which defaults to *.*.

File Trace presents three principal panes: A Parser Stack pane on the left, a Test File pane on the right, and a Rule Stack pane at the bottom.

In the Test File pane, you can distinguish text that has been parsed from unparsed text because it is shown in a different color (the default background color for parsed text is lighter). Initially no text has been parsed, and the caret is positioned at the beginning of the file. The Parse Location box at the lower left of File Trace will show 1:1 for line 1, column 1. The Parse Status box next to it will say "Ready".

Parsing Through Your Test File:

To advance the parse to a desired location, just double-click the left mouse button at that spot in the file. You can also use the cursor keys. Either the Enter key or the single-step button will single-step the parse forward. You will see the changes in the Rule Stack and Parser Stack as your test file characters are shifted in and reductions occur.

If there is a syntax error in the test file, the parse will not advance beyond that point and "Syntax error" will appear in the status box.

When you have parsed the whole test file, the words "Parse complete" will appear in the Parse Status box.

Back up the trace to a previous position by double-clicking at the desired location. You can also reset to the beginning with the "Reset" button, or reload the test file with "Reload". To parse the whole file (or up to a syntax error if there is one) just press "Parse File".

If the parse position is not the same as the caret position, the "Single Step" button will read "Synch Parse" instead. Pressing this button will move the parse position to the caret; i.e. it will "synchronize" the parse with the caret.

As you parse through the test file, you can observe how the Parser and Rule Stacks change. Notice that the Test File, Parser Stack and Rule Stack panes are synched with each other and with your syntax file window. By left-clicking on the stack panes, you can also see which parts of the test file are associated with each level of the stack.

Reduction Choices pane:

If your grammar contains any semantically determined productions (those with more than one reduction token on the left hand side), whenever your test file invokes one of them a Reduction Choices pane will appear in the File Trace window to the left of the Rule Stack. When you select a reduction token, the parse will continue.

Further Information:

When you run File Trace, AnaGram counts the number of times each rule is reduced. You may inspect these counts by opening the Trace Coverage window.

You can have any number of File Traces operating simultaneously. You may also select the Auxiliary Trace window in the Auxiliary Windows popup menu for the Parser Stack pane. It will give you a prebuilt Grammar Trace with the same parser stack contents as your File Trace. This is convenient if, for example, you wish to see the effect of modifying the test data somewhat.

Normally, File Trace reads test files in "text" mode, discarding carriage return characters. If your parser needs to recognize carriage return characters explicitly, you should turn the "test file binary" configuration switch on.

If you have not defined eof or specified an Eof Token parameter, File Trace may show a syntax error when it encounters the end of a test file. This probably does not indicate a problem either with your grammar or your test file.

AnaGram uses short-cut parsing actions in some cases. If you wish to see just the standard four actions, you may want to set the traditional engine switch. Then you will notice that you have to press the single-step or Enter keys more often to advance the parse past the current character.

AnaGram parser generator
Copyright ©1993-2002, Parsifal Software.
All Rights Reserved.

Parsifal Software
Links to: Home page | Trial Copy | Syntax Directed Parsing | Glossary