JHAVEPOP shares with Pascal Pointers, an educational application
developed by Jeffrey Popyack at Drexel University, the goal of helping
students become comfortable with pointers.
Like Pascal Pointers:
|
|
![]() |
| Figure 1: Grid layout with default horizontal spacing equal to half the box width |
// gridsize 2 3 java drawgrid 2.0 smallfontIn this example, the grid (shown in Figure 2) will contain 2 rows and 3 columns, and it will be drawn. The horizontal spacing will be 4 times larger than the default, for example, to prevent the overlap of variable names that appear as box labels.
![]() |
| Figure 2: Grid layout with horizontal spacing equal to twice the box width |
![]() |
| Figure 3: Grid layout with horizontal spacing equal to 0.0 |
| Construct | Java example | C++ example | |||
|---|---|---|---|---|---|
| 1. | Declaration | Node n1; |
Node *n1; |
||
| 2. | Declaration | Node n2 = n1; |
Node *n2 = n1; |
||
| 3. | Declaration | Node n3 = null; |
Node *n3 = NULL; |
||
| 4. | Declaration | Node n4 = new Node('A',null); |
Node *n4 = new Node('A',NULL); |
||
| 5. | Pointer assignment | n1 = n4.next; |
n1 = n4->next; |
||
| 6. | Pointer assignment | n1.next = null; |
n1->next = NULL; |
||
| 7. | Pointer assignment | n3 = new Node('B',null); |
*n3 = new Node('B',NULL); |
||
| 8. | Data assignment | n1.info = n4.next.info; |
n1->info = n4->next->info; |
||
| 9. | Data assignment | n1.next.info = 'C'; |
n1->next->info = 'C'; |
||
| 10. | Memory deallocation | Not available | delete n1; |
||
| 11. | If statement | if (n1==null) {...} else {...}; |
if (n1==NULL) {...} else {...}; |
||
| 12. | While loop | while ( (n1!=null) && (n1.info=='A') ) {...}; |
while ( (n1!=NULL) && (n1->info=='A') ) {...}; |
||
| 13. | For loop | for( n1=n2; n1!=null; n1=n1.next) {...}; |
for( n1=n2; n1!=NULL; n1=n1->next) {...}; |
||
| 14. | Break statement | break; |
break; |
||
| 15. | Linked list creation | Node head = Utils.createList( 'A','B','C',"tail" ); |
Node *head = createList( 'A','B','C',"tail" ); |
||
| 16. | Linked list realignment | n1.redrawListHorizontally(); |
n1->redrawListHorizontally(); |
Node n = new Node( 'A', null ); // 1 2 MIDDLE leftWhen allocating memory, JHAVEPOP picks a grid cell in which to display the new pointer variable and the new Node object in this case. The first two values in the comment specify the row and column of the target cell, presumably different from the one chosen by default. The third value is a string that specifies which of the three reference boxes in that cell (LEFT, MIDDLE, or RIGHT) will be assigned to the pointer variable. The fourth argument is a toggle for the position of the variable name: either to the left of the reference box, like in the example, or above it, when the argument is omitted. Other layout directive examples include:
Node n1; // 1 2 Node n2; // 2 2 ANY leftIn the first example, only the grid cell is specified, thus JHAVEPOP will use this cell but will choose the reference box according to its default algorithm. In the second example, in which the label needs to go to the left of the box, the string ANY is used as the third argument to indicate that any reference box in the cell will do. Indeed, as the following grammar enforces, skipping the third argument is not permitted, unless the last argument is also omitted.
| <EOF> | ::= | The end-of-file marker |
| <TITLE> | ::= | 0 or more non-newline characters |
| <COMMENT> | ::= | "//" |
| <GRIDSIZE> | ::= | "gridsize" (not case-sensitive) |
| <INT> | ::= | 1 or more occurrences of one of the ten decimal digits "0" through "9" |
| <LANGUAGE> | ::= | "java" or "C++" (not case-sensitive) |
| <DRAWGRID> | ::= | "drawgrid" (not case-sensitive) |
| <REAL> | ::= | a single decimal digit optionally followed by a dot and a single decimal digit |
| <SMALLFONT> | ::= | "smallfont" (not case-sensitive) |
| <ENDOFCOMMENT> | ::= | A newline character |
| <NODE> | ::= | "Node" |
| <STAR> | ::= | "*" |
| <IDENTIFIER> | ::= | A letter (that is, a lowercase or lower case letter, or "_", or "$") followed by 0 or more letters and decimal digits |
| <EQUAL> | ::= | "=" |
| <NULL> | ::= | "null" or "NULL" |
| <CREATELIST> | ::= | "Utils.createList" or "createList" |
| <LPAREN> | ::= | "(" |
| <CHARLIST> | ::= | A comma-separated list of one or more <CHAR>'s |
| <CHAR> | ::= | A single quote, followed by a single letter or decimal digit, followed by a single quote |
| <STRING> | ::= | An optional <IDENTIFIER> surrounded by double quotes |
| <RPAREN> | ::= | ")" |
| <SEMICOLON> | ::= | ";" |
| <DELETE> | ::= | "delete" |
| <CHAIN> | ::= | One or more copies of <DEREFERENCEOP> followed by "next" |
| <NEW> | ::= | "new" |
| <COMMA> | ::= | "," |
| <BREAK> | ::= | "break" |
| <WHILE> | ::= | "while" |
| <FOR> | ::= | "for" |
| <IF> | ::= | "if" |
| <ELSE> | ::= | "else" |
| <LBRACE> | ::= | "{" |
| <RBRACE> | ::= | "}" |
| <DEREFERENCEOP> | ::= | "." or "->" |
| <INFO> | ::= | "info" or "data" (not case-sensitive) |
| <LOGICALCONNECTOR> | ::= | "&&" or "| |" |
| <EQUALCOMPARATOR> | ::= | "==" or "!=" |
| <ORDERCOMPARATOR> | ::= | "<" or "<=" or ">" or ">=" |
| <REDRAW> | ::= | "redrawListHorizontally()" |