Products: Visual Parse++: Tutorials: Topics: Other Support:
Visual_Parse++     Visual_Parse++_Features GUI Tutor 1 Reducing a Rule Parsing Technology
DataStruct Why Visual Parse++? GUI Tutor 2 Expression List Stack Documentation
Meta-S Download Trial C++ Tutor 1 Flexible File Format Further Reading
Ordering Accolades Java Tutor 1 Grammar Idioms Consulting Services
Support Our Customers
  Back to home page  Click here for our free informative book "Parsing with Visual Parse++"  
 

Support: Tutorials - Visual Parse++ GUI Tutor 1

"The industry standard visual parsing tool."

GUI Tutor 1
GUI Tutor 2
C++ Tutor 1
JBuilder Java Tutor1
 
   For a 15 day free trial click here To order now click here!  
 

This tutorial shows you how to create a project and to do some debugging with the GUI. We'll use the XML sample provided with Visual Parse++ for this example. It will show you how to:

Create a new workspace

Open a test file and start testing

Step through the test file and interpret what is happening.

 

  1. Start Visual Parse++.

  2. Go to the File menu, and select New Workspace...

  3. Next to the Rule File edit box, there is a button. Click it.

  4. In the Open dialog box that appears, navigate to the XML rule file. It's called XML.ycc, and it's located in the Samples/XML directory where you installed Visual Parse++.  The default directory is Program Files/Sandstone/Visual Parse++ 4.0/Samples/Xml/xml.ycc.

  5. Select XML.ycc and click OK.

  6. The fields in the New Workspace dialog box are filled in with the information.

  7. Click the OK button.

  8. You will probably get  the message box "Workspace exists: .... Overwrite?" This is because the workspace file already exists.

  9. Click the Yes button or press enter. We will just overwrite the distributed workspace, and create a new one. 

  10. A file named XML.ypw will get created in the same directory as the rule file, and the file XML.ycc will get opened in an edit window.

  11. Select Debug/Compile, or click the Compile button on the toolbar. It's next to the Paste button, in the group with all the other Debug buttons.

  12. You'll see messages appear in the message window (toward the bottom of the screen) describing the compile progress. Wait until you see the Compile complete message

  13. Select the Debug/Open Test File menu selection. You will have 3 choices, Binary, Unicode, or Character. Select Character. Alternatively, you can click the Start button on the toolbar.

  14. You should be in the Samples/XML directory. If not, navigate there.

  15. Select 001.xml and press Open.

  16. The test file is opened and you'll see the start of the file in the marquee at the top of the screen.

  17. Press F10 or click the Step button on the toolbar.

  18. Repeat this again.

  19. The first character is processed by the lexer, and the ETagTok expression is highlighted in the rule file.

  20. Continue pressing F10 or click the Step button on the toolbar until the <!DOCTYPE token is recognized. The position in this regular expression is highlighted in red for each character, showing you exactly where you are. After the last character is processed (the E), the state will change from Lexing to Recognized. The state is located on both the right and left of the marquee.

     

  21. Press F10 again or click the Step button on the toolbar. The state will change to Reducing, and the XMLDeclOptNull production will get highlighted. 

  22. This rule says that there is no XMLDecl present in this test file, which is correct. You can see there is no <?xml element in this test file.

  23. Press F10 again or click the Step button on the toolbar. The state changes to Reduced and you see the reduction appear on the parse stack on the left.

     

  24. Press F10 again or click the Step button on the toolbar. This time the MiscListNull production is getting reduced. A MiscList of comments and processing instructions can appear before the DTD. This production just says that there aren't any in this test file.

  25. Step again (F10 or click the Step button on the toolbar) and the state changes to Reduced, and the MisList production appears on the stack.

  26. Step again, and the state changes to Shift, and the <!DOCTYPE production is shifted onto the stack.

  27. Step again, and the state changes back to Lexing, and the {ws} regular expression is recognized

  28. Step again, and the state changes to RecognizedIgnore. The white space was recognized and ignored because this expression had the %ignore parameter specified, which means to recognize the token (in this case a single space), but not to pass it to the parser.

  29. Step 4 more times. This will recognize the 'doc' token.

  30. Step again and the 'doc' is shifted on the stack.

  31. Step 2 more times to recognize and ignore the next space.

  32. Step 2 more times to recognize the '[' token.

  33. Step again, and the state changes to Reducing. The Name production was recognized. The elements on the stack associated with this grammar rule are highlighted (the stack is located on the left side of the screen, in a tree control). In this case there is only one element, the 'doc' token. This is because there is only one symbol on the right hand side of this production.

  34. Step again, and the rule is reduced. The 'doc' token is replaced on the stack with the Name symbol (the left hand side of the production). This is what  reduction does, it pops the right hand side off the stack and replaces it with the left hand side.

  35. Step 2 more times to reduce the ExternalIdOpt production. There is no external id present in this <!DOCTYPE statement.

  36. Step again to shift the '[' onto the stack.

  37. Step 2 more times to ignore the newline character.

  38. Step repeatedly until the <!ELEMENT token is recognized. Notice how easy it is to follow what is going on with the rule file highlighting.

  39. Step 2 more times to reduce the MarkupStuff production.

  40. Step again to shift the <!ELEMENT onto the stack.

  41. Step twice to ignore the blank character.

  42. Step 4 times to recognize the 'doc' token.

  43. Step again to shift the 'doc' token on the stack.

  44. Step 2 more times to ignore the blank.

  45. Step 2 more times to recognize the '(' token.

  46. Step 2 more times to reduce the 'doc' to the Name. Here's a tip about the notation used in on the stack. If you notice, each element on the stack is preceded by a graphic that has either a T or an N in it. The T stands for terminal or token, and the N stands for nonterminal. This makes it easy to see what each symbol represents on the stack. 

  47. Step again to shift the '('.

  48. Step repeatedly to recognize the #PCDATA token.

  49. Step again to shift it on the stack.

  50. Step 2 more times to recognize the ')'.

  51. Step again to shift the ')'.

  52. Step 2 more times to recognize the '>' token.

  53. Step again and the state changes to Reducing. The three tokens on the right hand side of this production are highlighted on the stack.

  54. Step again to reduce the Mixed production.

  55. Continue stepping through the file until state is Accept. You should hear a beep. As you step through the remainder of the data, you'll see all the highlighting effects that you have seen previously in this tutorial.

Go on to GUI Tutor 2 for more hints and tips. That tutorial will show you how to set breakpoints and run through multiple test files. It will also show you how to use some other features, like the lookahead feature, to aid in debugging a grammar.